/* Variables & Design Tokens */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
  
  /* Color Palette */
  --bg-gradient: radial-gradient(circle at 50% 50%, #1e1335 0%, #0c0714 100%);
  --color-surface: rgba(255, 255, 255, 0.05);
  --color-surface-hover: rgba(255, 255, 255, 0.1);
  --color-surface-border: rgba(255, 255, 255, 0.08);
  --color-text-primary: #ffffff;
  --color-text-secondary: #a0a0c0;
  
  /* Amy States Colors */
  --color-idle: #8b5cf6;
  --color-listening: #ec4899;
  --color-thinking: #06b6d4;
  --color-speaking: #10b981;
  --color-error: #ef4444;
  
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.3);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: #0c0714;
  color: var(--color-text-primary);
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: -webkit-fill-available;
  background: var(--bg-gradient);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border-left: 1px solid var(--color-surface-border);
  border-right: 1px solid var(--color-surface-border);
}

/* Header */
.app-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

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

.brand h1 {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  letter-spacing: 0.2em;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #a0a0c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-idle);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--color-idle);
  transition: all 0.5s ease;
}

/* Main Display */
.main-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  position: relative;
}

.assistant-status {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  transition: color 0.3s ease;
}

/* Visualizer Container & Orb */
.visualizer-container {
  position: relative;
  width: min(280px, 35vh);
  height: min(280px, 35vh);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  margin: auto 0;
}

.glow-bg {
  position: absolute;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, var(--color-idle) 0%, rgba(0,0,0,0) 70%);
  opacity: 0.15;
  border-radius: 50%;
  filter: blur(20px);
  transition: all 0.8s ease;
}

.orb {
  position: relative;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 80%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.1);
  transition: all 0.5s ease;
}

.inner-core {
  width: 57%;
  height: 57%;
  background: var(--color-idle);
  border-radius: 50%;
  filter: blur(2px);
  box-shadow: 0 0 30px var(--color-idle);
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2;
}

/* Wave Animations */
.wave {
  position: absolute;
  border: 1px solid var(--color-idle);
  border-radius: 43% 57% 51% 49% / 57% 40% 60% 43%;
  opacity: 0.3;
  width: 100%;
  height: 100%;
  transition: border-color 0.8s ease;
  animation: spin 12s linear infinite;
}

.wave-2 {
  animation-duration: 8s;
  animation-direction: reverse;
  border-radius: 50% 40% 60% 40% / 40% 60% 40% 60%;
  opacity: 0.2;
}

.wave-3 {
  animation-duration: 15s;
  border-radius: 45% 55% 40% 60% / 50% 45% 55% 50%;
  opacity: 0.15;
}

.wave-4 {
  animation-duration: 6s;
  animation-direction: reverse;
  border-radius: 55% 45% 50% 50% / 45% 50% 50% 55%;
  opacity: 0.1;
}

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

/* State Styling & Color Shifts */
/* Listening */
.app-container.listening .brand-dot {
  background-color: var(--color-listening);
  box-shadow: 0 0 12px var(--color-listening);
}
.app-container.listening .glow-bg {
  background: radial-gradient(circle, var(--color-listening) 0%, rgba(0,0,0,0) 70%);
  opacity: 0.3;
}
.app-container.listening .inner-core {
  background: var(--color-listening);
  box-shadow: 0 0 45px var(--color-listening);
  transform: scale(1.15);
}
.app-container.listening .wave {
  border-color: var(--color-listening);
  animation-duration: 4s;
  width: 155%;
  height: 155%;
  opacity: 0.4;
}
.app-container.listening .wave-2 { animation-duration: 3s; width: 180%; height: 180%; }
.app-container.listening .wave-3 { animation-duration: 5s; width: 200%; height: 200%; }

/* Thinking */
.app-container.thinking .brand-dot {
  background-color: var(--color-thinking);
  box-shadow: 0 0 12px var(--color-thinking);
}
.app-container.thinking .glow-bg {
  background: radial-gradient(circle, var(--color-thinking) 0%, rgba(0,0,0,0) 70%);
  opacity: 0.25;
}
.app-container.thinking .inner-core {
  background: var(--color-thinking);
  box-shadow: 0 0 40px var(--color-thinking);
  animation: pulse 1.5s ease-in-out infinite;
}
.app-container.thinking .wave {
  border-color: var(--color-thinking);
  animation-duration: 12s;
  width: 110%;
  height: 110%;
  animation: breath 2s ease-in-out infinite;
}
.app-container.thinking .wave-2 { animation-delay: 0.3s; }
.app-container.thinking .wave-3 { animation-delay: 0.6s; }

/* Speaking */
.app-container.speaking .brand-dot {
  background-color: var(--color-speaking);
  box-shadow: 0 0 12px var(--color-speaking);
}
.app-container.speaking .glow-bg {
  background: radial-gradient(circle, var(--color-speaking) 0%, rgba(0,0,0,0) 70%);
  opacity: 0.3;
}
.app-container.speaking .inner-core {
  background: var(--color-speaking);
  box-shadow: 0 0 45px var(--color-speaking);
  transform: scale(1.05);
}
.app-container.speaking .wave {
  border-color: var(--color-speaking);
  animation-duration: 5s;
  width: 140%;
  height: 140%;
  animation: speech-pulsing 1.8s ease-in-out infinite;
}
.app-container.speaking .wave-2 { animation-delay: 0.2s; animation-duration: 1.2s; }
.app-container.speaking .wave-3 { animation-delay: 0.4s; animation-duration: 2.2s; }

/* Error State */
.app-container.error-state .brand-dot {
  background-color: var(--color-error);
  box-shadow: 0 0 12px var(--color-error);
}
.app-container.error-state .inner-core {
  background: var(--color-error);
  box-shadow: 0 0 30px var(--color-error);
}
.app-container.error-state .wave {
  border-color: var(--color-error);
}

/* Animations Definitions */
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

@keyframes breath {
  0% { transform: scale(1) rotate(0deg); opacity: 0.1; }
  50% { transform: scale(1.3) rotate(180deg); opacity: 0.3; }
  100% { transform: scale(1) rotate(360deg); opacity: 0.1; }
}

@keyframes speech-pulsing {
  0% { transform: scale(1.1) rotate(0deg); opacity: 0.2; }
  25% { transform: scale(1.4) rotate(90deg); opacity: 0.4; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 0.2; }
  75% { transform: scale(1.5) rotate(270deg); opacity: 0.4; }
  100% { transform: scale(1.1) rotate(360deg); opacity: 0.2; }
}

/* Transcription Bubble */
.transcription-bubble {
  max-width: 85%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-surface-border);
  backdrop-filter: blur(10px);
  padding: 16px 20px;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  color: var(--color-text-secondary);
  font-weight: 300;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
  word-wrap: break-word;
}

.transcription-bubble.active {
  color: var(--color-text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

/* Footer & Buttons */
.app-footer {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  background: linear-gradient(to top, rgba(12, 7, 20, 0.8), transparent);
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  color: var(--color-text-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.icon-btn:hover, .icon-btn:focus {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
  outline: none;
}

.mic-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-idle) 0%, #7c3aed 100%);
  border: none;
  padding: 4px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  justify-content: center;
  align-items: center;
}

.mic-inner {
  width: 100%;
  height: 100%;
  background: #1e1335;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--color-text-primary);
  transition: all 0.3s ease;
}

.mic-btn:hover, .mic-btn:focus {
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.6);
  outline: none;
}

.mic-btn:active {
  transform: scale(0.95);
}

/* Microphone listening styling */
.app-container.listening .mic-btn {
  background: linear-gradient(135deg, var(--color-listening) 0%, #db2777 100%);
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4);
}
.app-container.listening .mic-inner {
  background: #3c0c24;
}

/* Text elements utilities */
.hidden {
  display: none !important;
}

/* Modals & Overlays */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(12, 7, 20, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  display: flex;
  align-items: flex-end; /* Mobile bottom-sheet layout */
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  background: #170f26;
  border-top-left-radius: 30px;
  border-top-right-radius: 30px;
  border-top: 1px solid var(--color-surface-border);
  padding: 24px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
  max-height: 90%;
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

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

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 34px; /* Safety padding at the bottom of the scroll area */
}

.modal-header h2, .drawer-header h2 {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--color-text-primary);
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.form-group select, .form-group input, .form-group textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-surface-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.form-group select:focus, .form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--color-idle);
  background: rgba(255, 255, 255, 0.07);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group.half {
  flex: 1;
}

.help-text {
  font-size: 0.75rem;
  color: #8b8ba8;
  margin-top: 6px;
  line-height: 1.3;
}

/* Range sliders custom look */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-idle);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.3);
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--color-idle) 0%, #7c3aed 100%);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.primary-btn:hover {
  opacity: 0.95;
}

/* History Drawer Styles */
.drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0d0818;
  z-index: 90;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
}

.text-btn:hover {
  color: var(--color-error);
}

/* Chat Messages Bubble inside Drawer */
.chat-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.4;
  font-size: 0.95rem;
  animation: message-fade 0.3s ease forwards;
}

@keyframes message-fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  align-self: flex-end;
  background: var(--color-idle);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-surface-border);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
}

.system-message {
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  margin-top: 20px;
  font-style: italic;
}

@media (max-height: 740px) {
  .app-header {
    padding: 12px 20px;
  }
  .main-display {
    padding: 16px 20px;
  }
  .assistant-status {
    margin-top: 10px;
    font-size: 0.95rem;
  }
  .transcription-bubble {
    padding: 12px 16px;
    font-size: 0.85rem;
    margin-bottom: 10px;
  }
  .app-footer {
    padding: 16px 20px;
  }
  .mic-btn {
    width: 64px;
    height: 64px;
  }
  .icon-btn {
    width: 44px;
    height: 44px;
  }
}
