/* ==========================================================================
   THEME VARIABLES
   ========================================================================== */
:root {
  /* Brand Colors */
  --primary: #3b82f6;          /* Blue-500 */
  --primary-hover: #2563eb;    /* Blue-600 */
  --text-main: #334155;        /* Slate-700 */
  --text-dark: #1e293b;        /* Slate-800 */
  --text-light: #64748b;       /* Slate-500 */
  
  /* Backgrounds */
  --bg-body: #f8fafc;          /* Slate-50 */
  --bg-surface: #ffffff;       /* White */
  --bg-element-hover: #f1f5f9; /* Slate-100 */
  
  /* Borders & UI */
  --border-color: #e2e8f0;     /* Slate-200 */
  --header-height: 60px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
}

/* ==========================================================================
   BASE & LAYOUT
   ========================================================================== */
body {
  /* REVERTED: Strictly using the original font stack */
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0;
  height: 100vh;
  background-color: var(--bg-body);
  color: var(--text-main);
  max-width: 100vw;
  overflow-x: hidden;
  
  /* Opacity transition for the index.html loader */
  opacity: 0; 
  transition: opacity 0.4s ease-in-out;
}

/* The class that reveals the page */
body.app-loaded {
  opacity: 1;
}

button, input, textarea, select {
  font-family: inherit;
}

.page-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.content-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  height: auto;
  min-height: calc(100vh - var(--header-height));
  overflow: hidden;
  max-width: 100vw;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.back-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--primary);
  border-bottom: 1px solid var(--primary-hover);
}

#logo { display: none; height: 32px; margin: 0 8px; }
#logo a, #backlink { display: flex; align-items: center; height: 100%; }
#logo img { display: block; height: 32px; width: auto; object-fit: contain; }

.back-link {
  display: inline-block;
  padding: 8px 16px;
  background-color: transparent;
  color: white;
  text-decoration: none;
  border-radius: 0;
  font-weight: 500;
  transition: opacity 0.2s;
}
.back-link:hover { opacity: 0.8; }

/* ==========================================================================
   SIDEBAR & CONTROLS
   ========================================================================== */
.column { height: auto; min-height: 100%; }

#left-column {
  width: 30%;
  flex: 0 0 30%;
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
  box-shadow: 4px 0 6px -1px rgba(0, 0, 0, 0.05);
}

.controls-container {
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  padding: 24px;
  z-index: 10;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
}

/* Buttons & Inputs */
#playPauseButton, #searchButton {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

#playPauseButton:hover, #searchButton:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

#playPauseButton:active { transform: translateY(0); }

.play-button-container { display: flex; justify-content: center; margin-bottom: 20px; }

.search-container { margin: 20px 0; display: flex; gap: 8px; padding: 0 10px; }

#searchInput {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--bg-body);
  transition: border-color 0.2s;
}

#searchInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Progress & Time */
#progress-bar {
  width: calc(100% - 20px);
  height: 4px;
  background-color: var(--border-color);
  margin: 0 10px 15px 10px;
  border-radius: 2px;
  overflow: hidden;
}

#progress {
  width: 0%;
  height: 100%;
  background-color: var(--primary);
  transition: width 0.1s linear;
}

#time-display {
  width: 100%;
  text-align: center;
  margin-bottom: 8px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Search Results */
#searchResults {
  margin: 15px;
  max-height: 300px;
  overflow-y: auto;
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.search-result {
  padding: 12px;
  margin: 8px;
  background-color: var(--bg-body);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-result:hover { background-color: var(--bg-element-hover); transform: translateY(-1px); }
.search-timestamp { color: var(--primary); font-weight: 600; margin-right: 12px; font-size: 0.875rem; }
.search-context { color: var(--text-light); font-size: 0.875rem; }

/* ==========================================================================
   MAIN CONTENT (RIGHT COLUMN)
   ========================================================================== */
#right-column {
  width: 70%;
  flex: 0 0 70%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  box-sizing: border-box;
}

.page-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.page-title-h1 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

/* Transcript Segments */
.transcript-segment {
  margin: 24px 0;
  padding: 24px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  line-height: 1.7;
  word-wrap: break-word;
}

.transcript-segment.editing { opacity: 0.7; }

/* Words */
.word {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.word:hover { background-color: var(--border-color); }
.word.current { background-color: var(--primary); color: white !important; }
.word.disabled { cursor: not-allowed; opacity: 0.7; }

/* ==========================================================================
   METADATA (ENTITIES)
   ========================================================================== */
.metadata-scroll-container { flex: 1; overflow-y: auto; padding: 24px; height: auto; box-sizing: border-box; }
.metadata-container { display: flex; flex-direction: column; gap: 24px; }

.entity-section, .metadata-section { margin-bottom: 20px; }
.entity-section h4 { font-size: 1rem; color: var(--text-dark); font-weight: 600; margin-bottom: 12px; }
.entity-item { margin-bottom: 20px; }
.entity-name { display: block; font-weight: 400; color: var(--text-main); margin-bottom: 8px; }

.timestamps { display: flex; flex-wrap: wrap; gap: 6px; }

.timestamp {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.timestamp:hover { transform: translateY(-1px); }

/* Entity Specific Colors */
.speaker-timestamp { background-color: #e0f2fe; color: #0c4a6e; }
.speaker-timestamp:hover { background-color: #bae6fd; }

.languages-timestamp { background-color: #f0f9ff; color: var(--text-dark); }
.languages-timestamp:hover { filter: brightness(0.95); }

.people-timestamp { background-color: #dbeafe; color: #1e40af; }
.people-timestamp:hover { background-color: #bfdbfe; }

.places-timestamp { background-color: #dcfce7; color: #166534; }
.places-timestamp:hover { background-color: #bbf7d0; }

.topics-timestamp { background-color: #fef9c3; color: #854d0e; }
.topics-timestamp:hover { background-color: #fef08a; }

/* ==========================================================================
   CONFIDENCE SLIDER & DEBUG
   ========================================================================== */
.confidence-indicator { margin-left: 0; flex-shrink: 0; }

/* FIX #1: Align items center to prevent jumping text */
.confidence-control-row { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  min-height: 24px; /* Fixes layout shift */
}

.confidence-threshold-label {
  font-size: 11px;
  color: #a2a0b3;
  min-width: 50px;
  text-align: right;
  white-space: nowrap;
}

.confidence-slider-wrapper { width: 200px; position: relative; }
.confidence-slider-container { position: relative; width: 100%; height: 8px; }

.confidence-bar-bg {
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  background: linear-gradient(to right, #007bff, #28a745, #ffc107, #fd7e14, #dc3545);
}

.confidence-dots {
  position: absolute;
  width: calc(100% - 14px);
  height: 3px;
  top: -6px;
  left: 7px;
}

.confidence-dot {
  position: absolute;
  width: 3px;
  height: 3px;
  background-color: #cbd5e1;
  border-radius: 50%;
  transform: translateX(-50%);
}

.confidence-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

/* SEPARATED RULES to prevent browser ignoring the styles */
/* Chrome/Safari/Edge */
.confidence-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  background: #e6f1ff; /* Gray background */
  border: 2px solid #94a3b8; /* Darker gray border */
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

/* Firefox */
.confidence-slider::-moz-range-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  background: #e6f1ff; /* Gray background */
  border: 2px solid #94a3b8; /* Darker gray border */
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.confidence-slider::-webkit-slider-thumb:hover,
.confidence-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.confidence-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  margin-left: 60px;
  width: 200px;
}

.confidence-labels span { font-size: 11px; color: var(--text-light); }

#debug-info {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.9);
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.75rem;
  display: none;
  backdrop-filter: blur(8px);
}

@media (max-width: 1200px) {
  .page-title-container { flex-direction: column; align-items: flex-start; }
  .confidence-indicator { margin-top: 16px; align-self: flex-end; }
  .page-title-h1 { margin-bottom: 16px; }
}
