@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* CSS Variables */
:root {
  --primary: #003366; /* Midnight Authority */
  --primary-rgb: 0, 51, 102;
  --accent: #00d4ff; /* Electric Kinetic */
  --accent-rgb: 0, 212, 255;
  --background: #f4f6fc;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-solid: #ffffff;
  --surface-container: rgba(229, 238, 255, 0.6);
  --surface-container-high: rgba(220, 233, 255, 0.8);
  --on-surface: #0b1c30;
  --on-surface-variant: #43474f;
  --error: #ba1a1a;
  --error-bg: #ffdad6;
  
  --shadow-sm: 0 4px 12px rgba(0, 51, 102, 0.04);
  --shadow-md: 0 12px 30px -5px rgba(0, 51, 102, 0.06);
  --shadow-lg: 0 24px 50px -10px rgba(0, 51, 102, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 10% 20%, rgba(229, 238, 255, 0.5) 0%, rgba(244, 246, 252, 1) 90%);
  color: var(--on-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Base Layout */
header {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 51, 102, 0.05);
  padding: 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

@media (max-width: 768px) {
  header {
    padding: 16px 20px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 51, 102, 0.2);
}

.brand-icon svg {
  fill: #ffffff;
  width: 20px;
  height: 20px;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface-variant);
  background: rgba(255, 255, 255, 0.6);
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #cbd5e1;
  border-radius: 50%;
  position: relative;
}

.status-dot.active {
  background: #10b981;
}

.status-dot.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Main Container */
main {
  flex: 1;
  width: 100%;
  max-width: var(--container-max, 1280px);
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  main {
    grid-template-columns: 1.8fr 1fr;
  }
}

/* Setup Panel */
.setup-panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
}

.input-wrapper {
  position: relative;
  display: flex;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--on-surface);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 51, 102, 0.1);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
  background: #ffffff;
}

.btn-toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--on-surface-variant);
}

.grid-cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Toggle Switch */
.switch-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #1a4d80 100%);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(0, 51, 102, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 51, 102, 0.25);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary.connected {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15);
}

/* Translation Interface (Split View) */
.translation-workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dialogue-container {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  height: 520px;
}

@media (max-width: 768px) {
  .dialogue-container {
    height: 600px;
  }
}

.dialogue-pane {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pane-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 51, 102, 0.06);
  color: var(--primary);
}

.dialogue-pane.visitor .pane-badge {
  background: rgba(0, 212, 255, 0.1);
  color: #005669;
}

.pane-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 51, 102, 0.05);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.icon-btn:hover {
  background: #ffffff;
  color: var(--accent);
  transform: translateY(-1px);
}

.dialogue-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialogue-scroll::-webkit-scrollbar {
  width: 4px;
}

.dialogue-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 51, 102, 0.1);
  border-radius: 2px;
}

/* Bubble Styling */
.transcript-bubble {
  max-width: 85%;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.5;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.transcript-bubble.primary {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary) 0%, #1f477b 100%);
  color: #ffffff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 51, 102, 0.1);
}

.transcript-bubble.secondary {
  align-self: flex-start;
  background: #ffffff;
  color: var(--on-surface);
  border: 1px solid rgba(0, 51, 102, 0.05);
  border-bottom-left-radius: 2px;
  box-shadow: var(--shadow-sm);
}

.live-subtitle-container {
  min-height: 60px;
  background: rgba(0, 51, 102, 0.02);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 8px;
  border: 1px dashed rgba(0, 51, 102, 0.08);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.live-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--on-surface);
}

.live-text.empty {
  color: #94a3b8;
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
}

/* Visitor rotation mode */
.dialogue-pane.visitor.flipped {
  transform: rotate(180deg);
}

/* Audio Visualizer & Waveform Overlay */
.visualizer-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 51, 102, 0.03);
}

.wave-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Quick templates panel */
.template-panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.template-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .template-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.template-card {
  background: #ffffff;
  border: 1px solid rgba(0, 51, 102, 0.05);
  padding: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.template-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 51, 102, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
}

.template-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
  line-height: 1.4;
}

.template-subtext {
  font-size: 12px;
  color: var(--on-surface-variant);
  font-style: italic;
}

/* Footer info */
footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: auto;
}

/* Wave Form Canvas for visual feedback */
.visualizer-card {
  background: #0b1c30;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #ffffff;
  box-shadow: var(--shadow-lg);
}

.visualizer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.visualizer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.visualizer-canvas-container {
  height: 80px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#mic-visualizer {
  width: 100%;
  height: 100%;
}

.error-message {
  background: var(--error-bg);
  color: var(--error);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: none;
  animation: slideIn 0.3s ease-out;
  border: 1px solid rgba(186, 26, 26, 0.1);
}
