/* ==========================================================================
   DESIGN SYSTEM & CUSTOM VARIABLES
   ========================================================================== */
:root {
  --bg-app: #0a0e17;
  --bg-card: #131926;
  --bg-card-hover: #182133;
  --border-color: #202b40;
  --border-focus: #6366f1;

  /* Brand Colors */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-secondary: #a855f7;
  --color-accent: #10b981;
  /* Emerald Green */
  --color-warning: #f59e0b;
  /* Amber */

  /* Text Colors */
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-contrast: #ffffff;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --grad-primary-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
  --grad-dark: linear-gradient(180deg, rgba(19, 25, 38, 0.8) 0%, rgba(10, 14, 23, 0.9) 100%);

  /* Shadows & Blur */
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 15px rgba(99, 102, 241, 0.35);
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  --waveform-height: clamp(80px, 10vh, 150px);

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   BASE STYLES & RESET
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LAYOUT & WRAPPER
   ========================================================================== */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Header Styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  background: rgba(19, 25, 38, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

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

.logo-icon {
  font-size: 32px;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: heartbeat 2s infinite alternate;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 1);
  border-radius: 12px;
  padding: 1px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.brand h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.brand h1 span {
  font-weight: 300;
  color: var(--text-secondary);
  text-transform: none;
  font-size: 14px;
  margin-left: 8px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-my-profile {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--text-contrast);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-my-profile:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-logout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--text-contrast);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-logout-header:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
}

.status-indicator.active {
  animation: pulse 1.5s infinite alternate;
}

.status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
}

/* Main Grid Container */
.main-container {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  flex-grow: 1;
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
  }

  .waveform-viewport {
    justify-content: flex-start;
  }
}

/* ==========================================================================
   COMMON CARD COMPONENTS
   ========================================================================== */
.pane {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  /* Prevent grid columns from expanding to fit large children */
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-label i {
  color: var(--color-primary);
}

/* ==========================================================================
   LEFT PANE: SELECT & PLAY VIDEO
   ========================================================================== */

/* Custom Dropdown */
.dropdown-card {
  z-index: 100;
  overflow: visible !important;
}

.custom-select-wrapper {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-display {
  width: 100%;
  padding: 14px 40px 14px 20px;
  background-color: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-smooth);
  position: relative;
}

.custom-select-display:hover {
  border-color: var(--color-primary);
}

.custom-select-display.open {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.custom-select-display.open .select-arrow {
  border-top-color: var(--color-primary);
  transform: translateY(-50%) rotate(180deg);
}

.custom-select-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 15px;
}

.custom-select-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: rgba(15, 21, 33, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.custom-select-dropdown.show {
  display: block;
}

.custom-select-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.custom-option {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 14px;
  color: var(--text-main);
}

.custom-option:hover {
  background: rgba(99, 102, 241, 0.15);
  color: var(--text-contrast);
}

.custom-option.selected {
  background: rgba(99, 102, 241, 0.25);
  color: var(--text-contrast);
  font-weight: 600;
  border-left: 4px solid var(--color-primary);
}

.custom-option-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-option-index {
  color: var(--color-primary);
  font-weight: 600;
  font-family: 'Outfit', monospace;
  font-size: 13px;
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.custom-option-duration {
  color: var(--text-muted);
  font-size: 13px;
}

.custom-option-score {
  font-weight: 700;
  font-size: 14px;
}

.score-emerald {
  color: #10b981;
}

.score-amber {
  color: #f59e0b;
}

.score-red {
  color: #ef4444;
}

.score-none {
  color: var(--text-muted);
  font-weight: 400;
}

.select-arrow {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--text-secondary);
  transition: var(--transition-smooth);
}

/* Video Viewport */
.video-card {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 320px;
}

.video-viewport {
  position: relative;
  width: 100%;
  flex-grow: 1;
  background-color: #020408;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

#main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  background-color: #000;
}

.viewport-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  z-index: 1;
  width: 100%;
}

.placeholder-icon {
  font-size: 54px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  border-radius: 50%;
  padding: 5px;
  transition: var(--transition-smooth);
}

.video-viewport:hover .placeholder-icon {
  transform: scale(1.1);
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.viewport-placeholder p {
  font-size: 14px;
  font-weight: 400;
  max-width: 240px;
}

/* Buttons and CTA Action bar */
.action-bar {
  display: flex;
}

.btn {
  width: 100%;
  padding: 16px 24px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: var(--border-radius-lg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: var(--grad-primary);
  color: var(--text-contrast);
  box-shadow: 0 6px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: var(--grad-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -4px rgba(99, 102, 241, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

/* ==========================================================================
   RIGHT PANE: WAVEFORM DISPLAY & CONTROLS
   ========================================================================== */
.waveform-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.waveform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.waveform-header .card-label {
  margin-bottom: 0;
}

.waveform-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.5;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.waveform-controls.active {
  opacity: 1;
  pointer-events: auto;
}

.control-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.control-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-contrast);
  transform: scale(1.05);
}

.zoom-slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.zoom-slider-container i {
  font-size: 11px;
  color: var(--text-secondary);
}

#wave-zoom-slider {
  width: 80px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  appearance: none;
}

#wave-zoom-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

#wave-zoom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--color-secondary);
}

/* Waveform Viewport & Renderer */
.waveform-viewport {
  position: relative;
  width: 100%;
  flex-grow: 1;
  background-color: #020408;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-height: 180px;
  overflow: hidden;
}

.waveform-workspace-row {
  display: none;
  /* Hidden by default, toggled to flex via JS */
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 4px 20px 6px;
  flex-grow: 1;
  position: relative;
}

#waveform-workspace {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
}

.waveform-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 15px 4px 15px;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
  width: 100%;
  margin-top: 4px;
}

.waveform-meta-row.active {
  opacity: 1;
  pointer-events: auto;
}

/* Large glowing circular play button on the left of waveform */
.play-large-btn {
  background: var(--grad-primary);
  border: none;
  color: var(--text-contrast);
  width: 38px;
  height: 38px;
  min-width: 38px;
  /* Prevent shrinking */
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  transition: var(--transition-smooth);
}

.play-large-btn:hover {
  background: var(--grad-primary-hover);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.play-large-btn i {
  margin-left: 2px;
  /* Slight offset to visually center standard play icon */
}

.play-large-btn i.fa-pause {
  margin-left: 0;
}

#waveform,
#user-waveform {
  width: 100%;
  height: var(--waveform-height);
  padding: 10px 0;
  display: none;
  overflow: hidden;
  flex-grow: 1;
  min-width: 0;
}

/* Custom scrollbar for zoomed waveform (targeting Wavesurfer's internal scroll container) */
#waveform>div::-webkit-scrollbar,
#user-waveform>div::-webkit-scrollbar {
  height: 6px;
}

#waveform>div::-webkit-scrollbar-track,
#user-waveform>div::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

#waveform>div::-webkit-scrollbar-thumb,
#user-waveform>div::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
  transition: var(--transition-smooth);
}

#waveform>div::-webkit-scrollbar-thumb:hover,
#user-waveform>div::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

#extracted-audio {
  display: none;
}

/* Wavesurfer scrollContainer override */
#waveform>div,
#user-waveform>div {
  padding-bottom: 0 !important;
  /* Clear vertical timing space */
  overflow-y: hidden !important;
  /* Ensure absolutely no vertical scrolling */
  position: relative !important;
  /* Ensure correct containment layout */
}

/* Container for clean flowing sentence-like line of words at the top of waveform */
.waveform-words-container {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 30px 20px 16px;
  width: 100%;
  z-index: 10;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* Container for translation line below the English text */
.waveform-translation-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 20px 18px;
  width: 100%;
  z-index: 10;
  background: rgba(255, 255, 255, 0.01);
  border-bottom: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 500;
  color: #fbbf24;
  text-align: center;
  line-height: 1.6;
}

/* Beautiful interactive sentence word labels */
.word-label {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-contrast);
  background: transparent;
  border: none;
  padding: 1px 2px;
  margin: 1px 2px;
  /* tiny margin to simulate perfect single spaces between words */
  border-radius: 4px;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.word-label:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Premium real-time karaoke-style active spoken word highlight */
.word-label.highlighted {
  color: var(--text-contrast);
  background: var(--grad-primary);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  z-index: 15;
}

/* Loader & Processing Overlays */
.waveform-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.9);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 5;
  padding: 30px;
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  border-right-color: var(--color-secondary);
  animation: spin 1s infinite linear;
}

/* ==========================================================================
   FUTURISTIC VOICE ANALYZER LOADER
   ========================================================================== */
.voice-analyzer-loader {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

/* Futuristic Rotating Rings */
.loader-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed transparent;
}

.loader-ring.outer {
  width: 170px;
  height: 170px;
  border-top-color: var(--color-primary);
  border-bottom-color: var(--color-secondary);
  opacity: 0.5;
  animation: spin-clockwise 6s linear infinite;
}

.loader-ring.inner {
  width: 135px;
  height: 135px;
  border-left-color: var(--color-accent);
  border-right-color: var(--color-primary);
  opacity: 0.75;
  animation: spin-counter-clockwise 4s linear infinite;
}

/* Center Pulsing Core */
.loader-core {
  width: 88px;
  height: 88px;
  background: var(--grad-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.5);
  z-index: 2;
  animation: core-pulse 2s ease-in-out infinite alternate;
}

.loader-core i {
  font-size: 34px;
  color: var(--text-contrast);
  animation: mic-scale 2s ease-in-out infinite;
}

/* Equalizer Waveform Bars */
.loader-wave-bars {
  position: absolute;
  bottom: -15px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 36px;
  z-index: 3;
}

.loader-wave-bars .bar {
  width: 4px;
  height: 8px;
  background: linear-gradient(180deg, var(--color-secondary) 0%, var(--color-primary) 100%);
  border-radius: 2px;
  transform-origin: bottom;
  animation: bounce-bar 1.2s ease-in-out infinite;
}

/* Rhythmic bouncing height for each equalizer sound bar */
.loader-wave-bars .bar:nth-child(1) {
  animation-delay: 0.1s;
  height: 10px;
}

.loader-wave-bars .bar:nth-child(2) {
  animation-delay: 0.4s;
  height: 18px;
}

.loader-wave-bars .bar:nth-child(3) {
  animation-delay: 0.2s;
  height: 26px;
}

.loader-wave-bars .bar:nth-child(4) {
  animation-delay: 0.6s;
  height: 34px;
}

.loader-wave-bars .bar:nth-child(5) {
  animation-delay: 0.3s;
  height: 14px;
}

.loader-wave-bars .bar:nth-child(6) {
  animation-delay: 0.7s;
  height: 30px;
}

.loader-wave-bars .bar:nth-child(7) {
  animation-delay: 0.5s;
  height: 22px;
}

.loader-wave-bars .bar:nth-child(8) {
  animation-delay: 0.8s;
  height: 16px;
}

.loader-wave-bars .bar:nth-child(9) {
  animation-delay: 0.2s;
  height: 10px;
}

/* Premium Fading Breathing Text */
#loader-message {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--text-contrast) 0%, var(--text-secondary) 50%, var(--text-contrast) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shine 2.5s linear infinite, text-breath 2s ease-in-out infinite;
  margin-top: 10px;
}

/* Keyframes */
@keyframes spin-clockwise {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes spin-counter-clockwise {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(-360deg);
  }
}

@keyframes core-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 0 0px rgba(168, 85, 247, 0.3);
  }

  100% {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.8), 0 0 0 10px rgba(168, 85, 247, 0);
  }
}

@keyframes mic-scale {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

@keyframes bounce-bar {

  0%,
  100% {
    transform: scaleY(1);
  }

  50% {
    transform: scaleY(4.2);
  }
}

@keyframes text-shine {
  to {
    background-position: 200% center;
  }
}

@keyframes text-breath {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

/* Cool Shimmering Progress Bar */
.loader-progress-container {
  width: 80%;
  max-width: 280px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  margin-top: 18px;
}

.loader-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-secondary) 50%, var(--color-accent) 100%);
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
  position: relative;
  background-size: 200% 100%;
  animation: progress-shimmer 2s infinite linear;
}

@keyframes progress-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}


/* Score Badge Footer */
.score-badge-footer {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-badge-footer:has(.score-badge-container:not([style*="display: none"])) {
  margin-top: 15px;
  margin-bottom: 10px;
  min-height: 100px;
}

.score-badge-footer:has(.score-badge-container.folded:not([style*="display: none"])) {
  min-height: 40px;
}

.score-badge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 4px 4px;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  text-align: center;
}

.score-badge-container.folded {
  gap: 0;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fold-toggle-icon {
  font-size: 16px;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.score-badge-container.folded .fold-toggle-icon {
  transform: rotate(180deg);
}

.score-explanation {
  font-size: 18px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.65);
  font-style: italic;
  font-weight: 500;
  max-width: 96%;
  white-space: pre-line;
  max-height: 2000px;
  opacity: 1;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  width: 100%;
}

.score-badge-container.folded .score-explanation {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.feedback-table-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 18px;
  margin-bottom: 10px;
  text-align: left;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-style: normal;
}

.feedback-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  margin-bottom: 15px;
  font-style: normal;
  font-size: 14px;
  text-align: left;
  background: rgba(10, 14, 23, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.feedback-table th {
  background-color: rgba(99, 102, 241, 0.12);
  color: var(--text-contrast);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.feedback-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(32, 43, 64, 0.6);
  color: rgba(243, 244, 246, 0.9);
  line-height: 1.5;
}

.feedback-table tr:last-child td {
  border-bottom: none;
}

.feedback-table tr:hover {
  background-color: rgba(255, 255, 255, 0.01);
}

.feedback-table td strong {
  color: var(--color-primary);
}


.score-label {
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-secondary);
}

.score-val {
  font-size: 55px;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  color: var(--text-contrast);
}

/* Performance styling based on score value */
.score-badge-container.excellent {
  border-color: rgba(16, 185, 129, 0.45);
  /* Emerald */
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.score-badge-container.excellent .score-val {
  color: #10b981;
}

.score-badge-container.good {
  border-color: rgba(245, 158, 11, 0.45);
  /* Amber/Orange */
  background: rgba(245, 158, 11, 0.06);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.12);
}

.score-badge-container.good .score-val {
  color: #f59e0b;
}

.score-badge-container.poor {
  border-color: rgba(239, 68, 68, 0.45);
  /* Red */
  background: rgba(239, 68, 68, 0.06);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.12);
}

.score-badge-container.poor .score-val {
  color: #ef4444;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.meta-label {
  color: var(--text-secondary);
}

#wave-duration,
#wave-current-time {
  color: var(--text-main);
  font-weight: 600;
  font-family: monospace;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.65;
  }

  100% {
    transform: scale(1.1);
    opacity: 1;
  }
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }

  20% {
    transform: scale(1.1);
  }

  40% {
    transform: scale(1);
  }

  60% {
    transform: scale(1.15);
  }

  80% {
    transform: scale(1);
  }

  100% {
    transform: scale(1);
  }
}


/* ==========================================================================
   USER RECORDING & COMPARISON STYLES
   ========================================================================== */

.user-waveform-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.01);
  width: 100%;
  height: calc(var(--waveform-height) + 20px);
  transition: var(--transition-smooth);
  text-align: center;
}

.user-waveform-placeholder i {
  font-size: 22px;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 0.8;
}

/* Voice Recording Layout container */
.recording-action-container {
  display: none;
  /* Hidden by default, shown when reference audio is loaded */
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0;
  padding: 0;
  border-top: 1px dashed var(--border-color);
  border-bottom: 1px dashed var(--border-color);
  width: 100%;
}

/* Modern round glowing record button */
.record-mic-btn {
  background: linear-gradient(135deg, #ff4b4b 0%, #dc2626 100%);
  border: none;
  color: var(--text-contrast);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
  transition: var(--transition-smooth);
  position: relative;
}

.record-mic-btn:hover:not(:disabled) {
  transform: scale(1.08);
  background: linear-gradient(135deg, #ff6060 0%, #b91c1c 100%);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.45);
}

.record-mic-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.record-mic-btn:disabled {
  background: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.5;
}

/* Pulsing animation when recording is active */
.record-mic-btn.recording {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: record-pulse 1.5s infinite;
}

.record-mic-btn.recording i {
  animation: mic-shake 0.5s infinite alternate;
}

/* Glowing countdown active state on record button */
.record-mic-btn.countdown-active {
  background: linear-gradient(135deg, #ff4b4b 0%, #dc2626 100%);
  color: var(--text-contrast);
  font-weight: 700;
  font-size: 24px;
  cursor: wait;
  opacity: 1;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  animation: button-pulse 1s infinite alternate;
}

@keyframes button-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  }

  100% {
    transform: scale(1.06);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.8);
  }
}

/* Simultaneous Playback toggle switch styles */
.playback-toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: var(--border-radius-lg);
  transition: var(--transition-smooth);
}

.playback-toggle-container:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

/* Hide default HTML checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .4s;
  border-radius: 50%;
}

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

input:checked+.slider:before {
  transform: translateX(24px);
  background-color: var(--text-contrast);
}

/* Focus styles */
input:focus+.slider {
  box-shadow: 0 0 1px var(--color-primary);
}

/* Animations */
@keyframes record-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes mic-shake {
  0% {
    transform: rotate(-3deg);
  }

  100% {
    transform: rotate(3deg);
  }
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* Tablet viewports (max-width: 768px) */
@media (max-width: 768px) {
  :root {
    --waveform-height: 70px;
  }

  .app-wrapper {
    padding: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 20px;
  }

  .system-status {
    width: 100%;
    justify-content: center;
  }

  .card {
    padding: 16px;
  }

  .video-card {
    min-height: 280px;
  }

  .waveform-card {
    min-height: 420px;
  }

  .btn {
    padding: 14px 20px;
    font-size: 14px;
  }

  .header-controls {
    gap: 8px !important;
  }

  .btn-my-profile,
  .btn-logout-header {
    padding: 5px 12px;
    font-size: 12px;
    gap: 6px;
  }

  .btn-my-profile i,
  .btn-logout-header i {
    font-size: 12px !important;
  }
}

/* Mobile viewports (max-width: 480px) */
@media (max-width: 480px) {
  .brand h1 {
    font-size: 20px;
  }

  .brand h1 span {
    font-size: 12px;
    display: block;
    margin-left: 0;
    margin-top: 4px;
  }

  .logo-icon {
    font-size: 24px;
  }

  .video-viewport {
    min-height: 220px;
  }

  .waveform-viewport {
    min-height: 200px;
  }

  .waveform-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .waveform-controls {
    width: 100%;
    justify-content: space-between;
  }

  .zoom-slider-container {
    flex-grow: 1;
    justify-content: center;
  }

  #wave-zoom-slider {
    width: 100%;
  }

  .waveform-meta-row {
    position: static;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .header-controls {
    gap: 6px !important;
  }

  .btn-my-profile,
  .btn-logout-header {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .btn-my-profile i,
  .btn-logout-header i {
    font-size: 11px !important;
  }
}

/* ==========================================================================
   PREMIUM COUNTDOWN OVERLAY STYLES
   ========================================================================== */
.countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: all;
  border-radius: var(--border-radius-md);
}

.countdown-overlay.show {
  opacity: 1;
}

.words-countdown-overlay {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
}

.countdown-number {
  font-size: 72px;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: countdownPulse 1s infinite ease-out;
  filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
  line-height: 1;
}

.countdown-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 1;
}

@keyframes countdownPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  20% {
    transform: scale(1.1);
    opacity: 1;
  }

  80% {
    transform: scale(1.0);
    opacity: 1;
  }

  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

/* ==========================================================================
   ACTIVE RECORDING STYLES & INDICATORS
   ========================================================================== */
#user-waveform-workspace.recording-active {
  border-color: rgba(239, 68, 68, 0.3) !important;
  box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.05);
}

.user-waveform-placeholder.recording {
  border: 2px solid rgba(239, 68, 68, 0.5) !important;
  background: rgba(239, 68, 68, 0.03) !important;
  color: #f87171 !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.15) !important;
  animation: recordingGlow 2s infinite alternate ease-in-out;
}

.user-waveform-placeholder.recording i {
  background: none !important;
  -webkit-text-fill-color: #ef4444 !important;
  color: #ef4444 !important;
  animation: recordingPulse 1.5s infinite alternate ease-in-out;
}

.user-waveform-placeholder.recording span {
  color: #fca5a5 !important;
  font-weight: 600 !important;
  letter-spacing: 0.5px !important;
}

.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 8px #ef4444;
  animation: dotPulse 1s infinite alternate ease-in-out;
}

@keyframes recordingGlow {
  0% {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.08);
  }

  100% {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
  }
}

@keyframes recordingPulse {
  0% {
    transform: scale(0.95);
    opacity: 0.7;
  }

  100% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes dotPulse {
  0% {
    opacity: 0.4;
    transform: scale(0.8);
  }

  100% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ==========================================================================
   PREMIUM DYNAMIC MODAL STYLES
   ========================================================================== */
.premium-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.premium-modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 32px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transform: scale(0.85) translateY(10px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.premium-modal-box.has-qrcode {
  max-width: 580px;
}

.premium-modal-overlay.active .premium-modal-box {
  transform: scale(1) translateY(0);
}

.premium-modal-box.warning {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(180deg, rgba(25, 20, 30, 0.85) 0%, rgba(19, 25, 38, 0.95) 100%);
}

.premium-modal-icon {
  width: 60px;
  height: 60px;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: #ef4444;
  font-size: 28px;
  animation: pulse-red 2s infinite alternate;
}

.premium-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
}

.premium-modal-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 28px;
  text-align: left;
}

.premium-modal-box:not(.has-qrcode) .premium-modal-body {
  text-align: center;
}

.premium-modal-message {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
}

.premium-modal-qrcode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.premium-modal-qrcode img {
  width: 170px;
  height: 170px;
  object-fit: contain;
  border-radius: 8px;
}

.premium-modal-qrcode span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.premium-modal-btn {
  background: var(--grad-primary);
  color: var(--text-contrast);
  border: none;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.premium-modal-btn:hover {
  background: var(--grad-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.premium-modal-btn:active {
  transform: translateY(0);
}

@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  100% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

/* ==========================================================================
   USER PROFILE & LOGOUT BUTTON STYLES
   ========================================================================== */
.btn-logout:hover {
  color: #ef4444 !important;
  transform: scale(1.15);
}

.user-profile:hover {
  border-color: rgba(99, 102, 241, 0.35) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.1);
}

/* ==========================================================================
   COLLAPSIBLE WAVEFORM SECTION STYLES
   ========================================================================== */
.collapsible-section {
  width: 100%;
  border-bottom: 0px solid var(--border-color);
  background: rgba(255, 255, 255, 0.005);
  transition: var(--transition-smooth);
}

.collapsible-section:last-of-type {
  border-bottom: none;
}

.section-toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  transition: var(--transition-smooth);
}

.section-toggle-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.section-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.section-toggle-header:hover .section-header-title {
  color: var(--text-contrast);
}

.section-icon {
  color: var(--color-primary);
  font-size: 13px;
  transition: var(--transition-smooth);
}

.section-toggle-header:hover .section-icon {
  transform: scale(1.12);
  color: var(--color-accent);
}

.section-fold-icon {
  font-size: 13px;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.section-toggle-header:hover .section-fold-icon {
  color: var(--text-secondary);
}

.collapsible-section.folded .section-fold-icon {
  transform: rotate(-180deg);
}

.collapsible-section.folded .waveform-translation-container,
.collapsible-section.folded .waveform-workspace-row {
  display: none !important;
}

.collapsible-section .waveform-translation-container {
  border-bottom: none;
  background: transparent;
}