/* Modern Design System for LumiNote */
:root {
  --bg-dark: #0b0c10;
  --bg-card: rgba(22, 25, 34, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-editor: rgba(14, 17, 23, 0.9);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 50%, #06b6d4 100%);
  --badge-gradient: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(236, 72, 153, 0.2) 100%);
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(139, 92, 246, 0.25);
  --shadow-recording: 0 0 30px rgba(239, 68, 68, 0.35);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
}

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

html, body {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden; /* Lock viewport: NO outer page scrolling */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
}

.container {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Header Styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bg-card-border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.logo:hover {
  opacity: 0.9;
  transform: scale(1.01);
}

.logo-image {
  height: 38px;
  width: 38px;
  filter: drop-shadow(0 4px 8px rgba(139, 92, 246, 0.3));
  transition: transform 0.3s ease;
}

.logo-image:hover {
  transform: rotate(5deg) scale(1.05);
}

.logo-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.model-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--badge-gradient);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c084fc;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Redesigned Custom Model Switcher Dropdown */
.custom-model-switcher {
  position: relative;
  display: inline-block;
  z-index: 50;
}

.model-switcher-btn {
  background: rgba(22, 26, 38, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: var(--text-primary);
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.model-switcher-btn:hover {
  background: rgba(30, 36, 54, 0.95);
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.model-switcher-btn .chevron-icon {
  color: #a78bfa;
  transition: transform 0.25s ease;
}

.custom-model-switcher.open .model-switcher-btn .chevron-icon {
  transform: rotate(180deg);
}

.model-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 270px;
  background: rgba(18, 22, 32, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 100;
}

.custom-model-switcher.open .model-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.model-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.model-option:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.25);
}

.model-option.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.45);
}

.option-icon {
  font-size: 1.1rem;
}

.option-details {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.option-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
}

.option-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.check-icon {
  color: var(--accent-purple);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.model-option.active .check-icon {
  opacity: 1;
}

/* Status Indicator */
.status-indicator-container {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.3s ease;
}

.status-indicator.recording {
  background: var(--error);
  box-shadow: 0 0 10px var(--error);
  animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.status-indicator.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

#statusText {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Main Transcription Interface */
.transcription-interface {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-card-border);
  box-shadow: var(--shadow-lg);
  flex: 1; /* Takes up remaining height */
  min-height: 0; /* CRITICAL FOR FLEX SCROLLING */
  display: flex;
  flex-direction: column;
  margin: 0.75rem 0;
  padding: 1rem 1.25rem;
  overflow: hidden;
  position: relative;
}

/* Editor Header Bar */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editor-title svg {
  color: var(--accent-purple);
}

.edit-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.725rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(6, 182, 212, 0.2);
  white-space: nowrap;
}

.edit-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
}

/* Transcription Output Container (Editable) */
.transcription-output {
  background: var(--bg-editor);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--text-primary);
  width: 100%;
  flex: 1; /* Fills available height inside interface */
  min-height: 0; /* Enables internal scroll bar ONLY inside box */
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-purple) transparent;
}

.transcription-output:focus {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.transcription-output[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  font-style: italic;
  font-size: 1.025rem;
}

/* Live Interim Turn Styling */
.live-turn {
  color: #a78bfa;
  border-bottom: 2px dashed rgba(167, 139, 250, 0.5);
  transition: all 0.2s ease;
}

/* Editor Footer & Stats */
.editor-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0.45rem;
  flex-shrink: 0;
}

.stats-counter {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dot-separator {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Dark Neon Toast Popup */
.copy-feedback {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-20px) scale(0.95);
  background: rgba(15, 18, 28, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: var(--text-primary);
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(139, 92, 246, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

.copy-feedback.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

/* Controls Bar */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  gap: 0.75rem;
  flex-shrink: 0;
}

.utility-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.control-button {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  transition: all 0.25s ease;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.control-button:hover {
  background: rgba(51, 65, 85, 0.8);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.control-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.grammar-button {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
  color: #c084fc;
}

.grammar-button:hover {
  background: rgba(139, 92, 246, 0.3);
  color: #ffffff;
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.35);
}

.grammar-button.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Main Record Button */
.record-button {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.85rem;
  border-radius: var(--radius-full);
  font-size: 0.975rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-glow);
  white-space: nowrap;
}

.record-button:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 35px rgba(139, 92, 246, 0.45);
}

.record-button.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: var(--shadow-recording);
  animation: pulse-button 2s infinite;
}

@keyframes pulse-button {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.record-button:disabled {
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Footer */
.app-footer {
  text-align: center;
  padding-top: 0.6rem;
  padding-bottom: 0.25rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  border-top: 1px solid var(--bg-card-border);
  flex-shrink: 0;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
  .container {
    width: 100%;
    padding: 0.75rem;
  }

  .controls {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.75rem;
  }

  .utility-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .control-button {
    justify-content: center;
  }

  .record-button {
    justify-content: center;
    width: 100%;
    padding: 0.75rem;
  }
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .custom-model-switcher {
    width: 100%;
  }

  .model-switcher-btn {
    width: 100%;
    justify-content: space-between;
  }

  .model-dropdown-menu {
    right: 0;
    left: 0;
    min-width: 100%;
  }
}
