/* ===== CSS VARIABLES ===== */
:root {
  /* Light theme colors */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #333333;
  --text-secondary: #555555;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --border-light: #e9ecef;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-light: rgba(0, 0, 0, 0.05);
  --accent-primary: #667eea;
  --accent-secondary: #764ba2;
  --success: #28a745;
  --success-bg: #d4edda;
  --success-border: #c3e6cb;
  --error: #dc3545;
  --error-bg: #f8d7da;
  --error-border: #f5c6cb;
  --warning: #ffd93d;
  --active-word: #ff6b6b;
  --hover-bg: #e8f4fd;
  --hover-text: #1e88e5;
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --text-primary: #e8e8e8;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --border-color: #333333;
  --border-light: #2a2a2a;
  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-light: rgba(0, 0, 0, 0.3);
  --accent-primary: #4a5fc7;
  --accent-secondary: #5a4a7a;
  --success: #1e7e34;
  --success-bg: #1a2e1a;
  --success-border: #2a4a2a;
  --error: #bd2130;
  --error-bg: #2a1a1a;
  --error-border: #4a2a2a;
  --warning: #cc9900;
  --active-word: #cc4444;
  --hover-bg: #1a2a3a;
  --hover-text: #4a8acc;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== HEADER SECTION ===== */
.header {
  background: linear-gradient(
    135deg,
    var(--accent-primary) 0%,
    var(--accent-secondary) 100%
  );
  color: white;
  padding: 20px 0;
  margin-bottom: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px var(--shadow);
  transition: box-shadow 0.3s ease;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 300;
  flex: 1;
  text-align: center;
}

/* Controls Group */
.controls-group {
  display: flex;
  gap: 15px;
  align-items: center;
}

/* Language Selector */
.language-selector {
  display: flex;
  gap: 5px;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 40px;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.lang-btn.active {
  background: white;
  color: var(--accent-primary);
  border-color: white;
}

/* Theme Selector */
.theme-selector {
  display: flex;
  gap: 5px;
}

.theme-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.theme-btn.active {
  background: white;
  color: var(--accent-primary);
  border-color: white;
}

/* ===== FILE UPLOAD SECTION ===== */
.file-upload-section {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px var(--shadow);
  margin-bottom: 30px;
  border: 1px solid var(--border-light);
  transition: background-color 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.file-upload-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Input Mode Selector */
.input-mode-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.mode-btn {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: var(--text-secondary);
}

.mode-btn:hover {
  background: var(--border-color);
  border-color: var(--text-muted);
}

.mode-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* Input Sections */
.input-section {
  display: none;
}

.input-section.active {
  display: block;
}

/* Shared Input Group Styles */
.file-input-group,
.url-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-input-group label,
.url-input-group label {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* File Input Styles */
.file-input-group input[type="file"] {
  padding: 10px;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.file-input-group input[type="file"]:hover {
  border-color: var(--accent-primary);
  background: var(--hover-bg);
}

.file-input-group input[type="file"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* URL Input Styles */
.url-input-group input[type="url"] {
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.url-input-group input[type="url"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.url-input-group input[type="url"]:valid {
  border-color: var(--success);
}

/* Status Indicators */
.file-name,
.url-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 5px 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  border: 1px solid var(--border-light);
  transition: all 0.3s ease;
}

.file-name.selected,
.url-status.valid {
  color: var(--success);
  background: var(--success-bg);
  border-color: var(--success-border);
}

.url-status.invalid {
  color: var(--error);
  background: var(--error-bg);
  border-color: var(--error-border);
}

/* Load Button */
.load-btn {
  background: linear-gradient(135deg, var(--success) 0%, #20c997 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.2s ease;
  align-self: center;
  min-width: 150px;
}

.load-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.load-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== AUDIO CONTROLS SECTION ===== */
.audio-controls {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px var(--shadow);
  margin-bottom: 30px;
  position: sticky;
  top: 20px;
  z-index: 100;
  border: 1px solid var(--border-light);
  transition: background-color 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

#audio {
  width: 100%;
  margin-bottom: 20px;
  border-radius: 5px;
}

/* Speed Controls */
.speed-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.speed-controls label {
  font-weight: 500;
  color: var(--text-secondary);
}

.speed-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.speed-btn {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.speed-btn:hover {
  background: var(--border-color);
  transform: translateY(-1px);
}

.speed-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* ===== TRANSCRIPT SECTION ===== */
.transcript-container {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px var(--shadow);
  margin-bottom: 30px;
  border: 1px solid var(--border-light);
  transition: background-color 0.3s ease, border-color 0.3s ease,
    box-shadow 0.3s ease;
}

#transcript {
  margin: 0;
  white-space: pre-wrap;
  line-height: 2em;
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: color 0.3s ease;
}

/* Transcript Status Mode */
#transcript.status {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  line-height: 1.4em;
  font-size: 14px;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--border-color);
}

#transcript.status h2 {
  margin-top: 0;
  color: var(--accent-primary);
  text-align: center;
}

#transcript.status .entry {
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 5px;
  border-left: 3px solid var(--accent-primary);
}

#transcript.status progress {
  width: 100%;
  height: 20px;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
}

/* Word Interaction States */
.success {
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 2px 4px;
  border-radius: 3px;
}

.success:hover {
  background-color: var(--hover-bg);
  color: var(--hover-text);
  text-decoration: underline;
}

.active {
  background-color: var(--active-word);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

/* ===== PHONEME DISPLAY ===== */
.phones {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.phones .phone {
  margin-right: 8px;
  font-family: "Monaco", "Menlo", monospace;
  text-transform: uppercase;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 4px;
  border-radius: 3px;
  display: inline-block;
}

.phones .phone:last-child {
  margin-right: 0;
}

.phactive {
  background-color: #ffd93d;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: bold;
}

/* ===== FOOTER ===== */
#footer {
  margin-top: 50px;
  border-top: 2px solid var(--border-color);
  font-size: 14px;
  font-style: italic;
  padding: 20px;
  text-align: center;
  background: var(--bg-secondary);
  border-radius: 10px;
  box-shadow: 0 2px 10px var(--shadow);
  color: var(--text-muted);
  transition: all 0.3s ease;
}

#footer a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
}

#footer a:hover {
  text-decoration: underline;
  color: var(--hover-text);
}

/* ===== DARK MODE SPECIFIC STYLES ===== */
[data-theme="dark"] .phones {
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .phones .phone {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

[data-theme="dark"] .phactive {
  background-color: var(--warning);
  color: var(--bg-primary);
}

/* Dark mode responsive adjustments */
@media (max-width: 768px) {
  .controls-group {
    flex-direction: column;
    gap: 10px;
  }

  .header-content {
    flex-direction: column;
    gap: 15px;
  }

  .header h1 {
    text-align: center;
    margin-bottom: 10px;
  }
}

@media (max-width: 480px) {
  .controls-group {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }

  .theme-btn,
  .lang-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
    min-width: 35px;
  }
}

/* ===== UTILITY CLASSES ===== */
#preloader {
  visibility: hidden;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .file-upload-section,
  .audio-controls {
    padding: 15px;
  }

  .audio-controls {
    top: 15px;
  }

  .file-upload-container {
    gap: 15px;
  }

  .speed-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .speed-buttons {
    justify-content: center;
  }

  .speed-btn {
    flex: 1;
    min-width: 60px;
  }

  .transcript-container {
    padding: 20px;
  }

  #transcript {
    font-size: 1rem;
    line-height: 1.8em;
  }

  .phones {
    font-size: 10px;
    padding: 3px 6px;
  }

  .phones .phone {
    font-size: 9px;
    margin-right: 4px;
    padding: 1px 2px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px;
  }

  .header {
    margin-bottom: 20px;
  }

  .header h1 {
    font-size: 1.3rem;
  }

  .file-upload-section,
  .audio-controls {
    padding: 12px;
  }

  .audio-controls {
    top: 10px;
  }

  .file-upload-container {
    gap: 12px;
  }

  .file-input-group {
    gap: 6px;
  }

  .file-input-group input[type="file"] {
    padding: 8px;
    font-size: 0.8rem;
  }

  .load-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    min-width: 120px;
  }

  .transcript-container {
    padding: 15px;
  }

  #transcript {
    font-size: 0.95rem;
    line-height: 1.6em;
  }

  .speed-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}
