/* SpeechEval - Ultra Premium iOS Frosted Glass Theme (Blue & White Color Scheme) */

:root {
  /* iOS Light Theme Backgrounds */
  --bg-color: #f5f7fb;
  --card-bg: rgba(255, 255, 255, 0.45);
  --card-border: rgba(255, 255, 255, 0.6);
  --card-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.05);
  
  /* Text Colors (SF Pro Style) */
  --text-main: #1d1d1f;      /* iOS Dark Charcoal */
  --text-muted: #6e6e73;     /* iOS Label Gray */
  --text-dark: #86868b;      /* iOS Placeholder Gray */
  
  /* iOS Blue & White Color Palette */
  --ios-blue: #007aff;       /* Classic Apple Blue */
  --ios-blue-rgb: 0, 122, 255;
  --ios-blue-light: rgba(0, 122, 255, 0.08);
  --ios-blue-deep: #0056b3;
  --white-pure: #ffffff;
  
  /* Metric Accents */
  --color-total: #007aff;      /* System Blue */
  --color-accuracy: #34c759;   /* System Green */
  --color-fluency: #5ac8fa;    /* System Teal */
  --color-integrity: #af52de;  /* System Purple */
  --color-bad: #ff3b30;        /* System Red */

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Reset and Layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Background Blobs (Premium iOS Style) */
.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #eef3fc 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.45;
  animation: float 25s infinite alternate ease-in-out;
}

.blob-purple {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(175, 82, 222, 0.3) 0%, rgba(90, 200, 250, 0.1) 100%);
  top: -10%;
  right: 10%;
}

.blob-blue {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 122, 255, 0.35) 0%, rgba(90, 200, 250, 0.05) 100%);
  bottom: -15%;
  left: 5%;
  animation-delay: -7s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -60px) scale(1.1); }
  100% { transform: translate(-30px, 30px) scale(0.9); }
}

/* App Container */
.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* iOS Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--ios-blue);
  background: rgba(0, 122, 255, 0.1);
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.15);
}

.logo-text h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text-main);
  background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-deep) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Connection Status Badge */
.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 18px;
  border-radius: 99px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  font-size: 13px;
  font-weight: 600;
}

.status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--color-bad);
  box-shadow: 0 0 6px var(--color-bad);
  transition: all 0.3s ease;
}

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

.status-indicator.connecting {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.2s infinite;
}

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

/* Grid Layout */
.app-grid {
  display: grid;
  grid-template-columns: 1.15fr 1.85fr;
  gap: 28px;
}

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

/* Glassmorphism Cards (Premium iOS Light Look) */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(25px) saturate(200%);
  -webkit-backdrop-filter: blur(25px) saturate(200%);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 20px 48px 0 rgba(31, 38, 135, 0.08);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.title-icon {
  width: 20px;
  height: 20px;
  color: var(--ios-blue);
}

/* Form Controls (iOS Style) */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.select-input, .text-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  color: var(--text-main);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.select-input:focus, .text-input:focus {
  border-color: var(--ios-blue);
  background: var(--white-pure);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.select-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

.select-input option {
  background-color: var(--white-pure);
  color: var(--text-main);
}

.text-input {
  height: 100px;
  resize: none;
  line-height: 1.5;
}

/* Preset Buttons (iOS Pills) */
.preset-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-preset {
  background: rgba(0, 122, 255, 0.06);
  border: 1px solid rgba(0, 122, 255, 0.08);
  border-radius: 20px;
  color: var(--ios-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-preset:hover {
  background: var(--ios-blue);
  color: var(--white-pure);
  border-color: var(--ios-blue);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 122, 255, 0.2);
}

/* Speech Capture / Recorder Section */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  gap: 18px;
}

.pulse-ring {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pulsing radar effects when recording (iOS Pulsing Layer) */
.pulse-ring::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.15);
  transform: scale(1);
  z-index: 1;
  transition: all 0.5s ease;
}

.pulse-ring.active::before {
  animation: radar-pulse 1.8s infinite linear;
  background: rgba(255, 59, 48, 0.18);
}

@keyframes radar-pulse {
  0% { transform: scale(0.95); opacity: 0.95; }
  100% { transform: scale(1.6); opacity: 0; }
}

.record-btn {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: none;
  outline: none;
  background: radial-gradient(circle, var(--ios-blue) 0%, var(--ios-blue-deep) 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 10px 25px rgba(0, 122, 255, 0.25);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.record-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 14px 35px rgba(0, 122, 255, 0.4);
}

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

.record-btn:disabled {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text-dark);
  cursor: not-allowed;
  box-shadow: none;
}

.record-btn.recording {
  background: radial-gradient(circle, var(--color-bad) 0%, #d32f2f 100%);
  box-shadow: 0 10px 25px rgba(255, 59, 48, 0.35);
}

.icon-mic svg {
  width: 34px;
  height: 34px;
  stroke-width: 2.2;
}

.recording-state {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.recording-state.active {
  color: var(--color-bad);
  animation: pulse-text 1.2s infinite;
}

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

/* Sound Wave Canvas (iOS Waveform) */
.visualizer-container {
  width: 100%;
  height: 54px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

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

/* Execution Log Panel (Sleek Translucent Light Console) */
.log-console {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 16px;
  padding: 16px 20px;
  height: 140px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
  scroll-behavior: smooth;
}

.log-console::-webkit-scrollbar {
  width: 6px;
}
.log-console::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
}

.log-entry {
  margin-bottom: 5px;
  word-break: break-all;
}

.log-system { color: var(--text-muted); }
.log-client { color: var(--ios-blue-deep); }
.log-relay { color: #0f172a; font-weight: 500; }
.log-error { color: var(--color-bad); font-weight: 600; }
.log-success { color: #2e7d32; font-weight: 600; }

/* Metrics Gauge Dashboard */
.gauges-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 640px) {
  .gauges-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

.gauge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.35);
  padding: 16px 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.01);
}

.gauge-svg-wrap {
  position: relative;
  width: 86px;
  height: 86px;
  margin-bottom: 12px;
}

.gauge-ring {
  width: 100%;
  height: 100%;
}

.gauge-bg-circle {
  fill: none;
  stroke: rgba(0, 0, 0, 0.04);
  stroke-width: 8.5px;
}

.gauge-fill-circle {
  fill: none;
  stroke-width: 8.5px;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 264; /* 2 * PI * 42 */
  transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.accent-total { stroke: var(--color-total); filter: drop-shadow(0 2px 6px rgba(0, 122, 255, 0.25)); }
.accent-accuracy { stroke: var(--color-accuracy); filter: drop-shadow(0 2px 6px rgba(52, 198, 89, 0.25)); }
.accent-fluency { stroke: var(--color-fluency); filter: drop-shadow(0 2px 6px rgba(90, 200, 250, 0.25)); }
.accent-integrity { stroke: var(--color-integrity); filter: drop-shadow(0 2px 6px rgba(175, 82, 222, 0.25)); }

.gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.gauge-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Phoneme & Word Detail Breakdown container */
.breakdown-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.breakdown-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.words-container {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  min-height: 110px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.01);
}

.words-placeholder {
  color: var(--text-dark);
  font-size: 13px;
  text-align: center;
  font-weight: 500;
}

/* Custom Interactive Word Chips (iOS Squircled Caps) */
.word-chip {
  position: relative;
  background: var(--white-pure);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 70px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.word-chip:hover {
  background: var(--white-pure);
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(0, 122, 255, 0.2);
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.08);
}

.word-text {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-main);
}

.word-score {
  font-size: 11.5px;
  font-weight: 700;
}

/* Word chip status styling using Apple Accent Colors */
.score-excellent {
  border-top: 3px solid var(--color-accuracy);
}
.score-excellent .word-score { color: var(--color-accuracy); }

.score-good {
  border-top: 3px solid var(--ios-blue);
}
.score-good .word-score { color: var(--ios-blue); }

.score-average {
  border-top: 3px solid var(--color-integrity);
}
.score-average .word-score { color: var(--color-integrity); }

.score-poor {
  border-top: 3px solid var(--color-bad);
}
.score-poor .word-score { color: var(--color-bad); }

.score-missing {
  border-top: 3px solid var(--text-dark);
  text-decoration: line-through;
  opacity: 0.55;
}
.score-missing .word-score { color: var(--text-muted); }

/* Popup phoneme breakdown detail tooltips (Frosted Glass iOS Style) */
.phoneme-popover {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 150px;
  text-align: center;
}

.phoneme-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.88);
}

.word-chip:hover .phoneme-popover {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.popover-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding-bottom: 5px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.popover-phones {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.phone-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-char {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--ios-blue);
}

.phone-val {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

/* XML Inspector Section (iOS Card Style) */
.xml-inspector-card {
  padding: 0;
  overflow: hidden;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  cursor: pointer;
  user-select: none;
}

.btn-toggle-inspector {
  background: rgba(0, 122, 255, 0.05);
  border: 1px solid rgba(0, 122, 255, 0.1);
  border-radius: 20px;
  color: var(--ios-blue);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-inspector:hover {
  background: rgba(0, 122, 255, 0.1);
}

.inspector-content {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  max-height: 250px;
  overflow-y: auto;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.inspector-content.collapsed {
  max-height: 0;
  border-top-color: transparent;
}

.inspector-content pre {
  margin: 0;
  padding: 18px 28px;
  background: rgba(0, 0, 0, 0.02);
}

.inspector-content code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ios-blue-deep);
  white-space: pre-wrap;
  word-wrap: break-word;
}
