/**
 * Console Widget Styles
 * Floating terminal widget for Zenpower sites
 * Colors: bg #021014, accent #02f1b1, text #e0e0e0, header-bg #0a1a1f
 */

/* ── Floating trigger button ── */
.cw-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #021014;
  border: 2px solid #02f1b1;
  color: #02f1b1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(2, 241, 177, 0.25), 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: cw-pulse 3s ease-in-out infinite;
}

.cw-trigger:hover {
  box-shadow: 0 0 28px rgba(2, 241, 177, 0.45), 0 4px 16px rgba(0, 0, 0, 0.6);
  transform: scale(1.06);
}

.cw-trigger-icon {
  letter-spacing: -0.05em;
  user-select: none;
}

@keyframes cw-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(2, 241, 177, 0.25), 0 4px 12px rgba(0, 0, 0, 0.5); }
  50%       { box-shadow: 0 0 28px rgba(2, 241, 177, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5); }
}

/* ── Overlay / Panel container ── */
.cw-overlay {
  position: fixed;
  z-index: 900;
  background: #021014;
  border: 1px solid rgba(2, 241, 177, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 24px rgba(2, 241, 177, 0.08);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.cw-overlay-mode {
  /* Default position: bottom-right, above the trigger button area */
  bottom: 96px;
  right: 24px;
  width: 480px;
  height: 360px;
  min-width: 320px;
  min-height: 240px;
}

.cw-panel-mode {
  bottom: 0;
  left: 0;
  right: 0;
  width: 100% !important;
  height: 320px !important;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.cw-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ── Header ── */
.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 36px;
  background: #0a1a1f;
  border-bottom: 1px solid rgba(2, 241, 177, 0.2);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.cw-panel-mode .cw-header {
  cursor: default;
}

.cw-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #02f1b1;
  letter-spacing: 0.12em;
}

.cw-context {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  color: rgba(2, 241, 177, 0.55);
  letter-spacing: 0.05em;
}

.cw-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cw-btn {
  background: none;
  border: none;
  color: rgba(224, 224, 224, 0.6);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease, background 0.15s ease;
  font-family: 'Courier New', Courier, monospace;
}

.cw-btn:hover {
  color: #02f1b1;
  background: rgba(2, 241, 177, 0.08);
}

/* ── Terminal area ── */
.cw-terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px;
  gap: 4px;
}

.cw-output {
  flex: 1;
  overflow-y: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #e0e0e0;
  scrollbar-width: thin;
  scrollbar-color: rgba(2, 241, 177, 0.3) transparent;
}

.cw-output::-webkit-scrollbar {
  width: 4px;
}

.cw-output::-webkit-scrollbar-track {
  background: transparent;
}

.cw-output::-webkit-scrollbar-thumb {
  background: rgba(2, 241, 177, 0.3);
  border-radius: 2px;
}

/* Output line types */
.cw-line {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 0;
}

.cw-system {
  color: rgba(2, 241, 177, 0.7);
}

.cw-input {
  color: rgba(224, 224, 224, 0.5);
  font-style: italic;
}

.cw-output-line {
  color: #e0e0e0;
}

.cw-error {
  color: #ff6b6b;
}

/* ── Input line ── */
.cw-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid rgba(2, 241, 177, 0.1);
  padding-top: 6px;
}

.cw-prompt {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8125rem;
  color: #02f1b1;
  white-space: nowrap;
  flex-shrink: 0;
}

.cw-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8125rem;
  caret-color: #02f1b1;
  width: 100%;
}

/* ── Resize handle ── */
.cw-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  opacity: 0.4;
  background: linear-gradient(
    135deg,
    transparent 30%,
    rgba(2, 241, 177, 0.6) 30%,
    rgba(2, 241, 177, 0.6) 40%,
    transparent 40%,
    transparent 60%,
    rgba(2, 241, 177, 0.6) 60%,
    rgba(2, 241, 177, 0.6) 70%,
    transparent 70%
  );
}

.cw-resize-handle:hover {
  opacity: 0.8;
}

/* ── Mobile: full-width slide-up sheet ── */
@media (max-width: 600px) {
  .cw-trigger {
    bottom: 16px;
    right: 16px;
  }

  .cw-overlay-mode {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100% !important;
    height: 70vh !important;
    border-radius: 12px 12px 0 0;
    border-bottom: none;
  }

  .cw-resize-handle {
    display: none;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .cw-trigger {
    animation: none;
  }

  .cw-overlay,
  .cw-trigger {
    transition: none;
  }
}
