/* CSS Custom Properties / Design Tokens */
:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* HSL Colors */
  --bg-primary: hsl(222, 47%, 6%);
  --bg-secondary: hsl(222, 33%, 10%);
  --bg-tertiary: hsl(222, 25%, 14%);
  --bg-glass: hsla(222, 33%, 10%, 0.7);
  --bg-glass-hover: hsla(222, 33%, 15%, 0.8);
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: hsla(210, 100%, 60%, 0.5);
  
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(210, 20%, 80%);
  --text-muted: hsl(210, 15%, 55%);
  
  --accent-blue: hsl(210, 100%, 60%);
  --accent-blue-rgb: 0, 149, 255;
  --accent-purple: hsl(260, 95%, 68%);
  --accent-emerald: hsl(150, 80%, 50%);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(0, 149, 255, 0.15);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 340px;
  --header-height: 70px;
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Layout Containers */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% -20%, hsl(222, 50%, 15%), var(--bg-primary) 70%);
}

/* Header */
.app-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.5px;
}

.logo-accent {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-title {
  color: var(--text-primary);
}

.header-tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  font-family: var(--font-heading);
}

.mobile-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.mobile-toggle-btn:hover {
  background-color: var(--bg-tertiary);
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-normal);
  z-index: 10;
}

.sidebar-search-container {
  padding: 16px;
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-container input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.sidebar-search-container input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 149, 255, 0.15);
}

.sidebar-search-container .search-icon {
  position: absolute;
  left: 28px;
  color: var(--text-muted);
  pointer-events: none;
}

.movies-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px 12px;
}

.loading-spinner, .no-results {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Movie Card Item */
.movie-item {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background-color: transparent;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.movie-item:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
}

.movie-item.active {
  background: linear-gradient(135deg, rgba(0, 149, 255, 0.08), rgba(120, 50, 255, 0.08));
  border-color: rgba(0, 149, 255, 0.3);
  box-shadow: var(--shadow-sm);
}

.movie-item-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  transition: var(--transition-fast);
}

.movie-item.active .movie-item-title {
  color: var(--accent-blue);
}

.movie-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Content Area */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
  min-height: 0; /* Prevents flexbox overflow */
}

/* Ensure closed dialogs do not block click/scroll */
dialog:not([open]) {
  display: none !important;
}

/* Banner Placeholder */
.banner-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.banner-placeholder h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.banner-placeholder p {
  color: var(--text-muted);
  max-width: 480px;
  font-size: 1rem;
  line-height: 1.5;
}

/* Active Movie Banner */
.movie-banner {
  padding: 24px;
  background: linear-gradient(to bottom, var(--bg-secondary), var(--bg-primary));
  border-bottom: 1px solid var(--border-light);
}

.movie-banner h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.movie-banner-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
}

/* Subtitle Control Panel */
.subtitles-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* Prevents flexbox overflow */
}

.subtitle-controls {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
}

.sub-search-container {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 400px;
}

.sub-search-container input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.sub-search-container input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 149, 255, 0.15);
}

.sub-search-container .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.subtitle-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Subtitles Grid Scroll List */
.subtitles-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0; /* Prevents flexbox overflow */
}

/* Subtitle Row Card */
.sub-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 40px;
  gap: 20px;
  padding: 16px 20px;
  background-color: var(--bg-glass);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  align-items: center;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Prevents flexbox squishing cards in scrollable view */
}

.sub-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, var(--accent-blue), var(--accent-purple));
  opacity: 0;
  transition: var(--transition-fast);
}

.sub-row:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 149, 255, 0.3);
  box-shadow: var(--shadow-glow);
  background-color: var(--bg-glass-hover);
}

.sub-row:hover::before {
  opacity: 1;
}

.sub-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.sub-text {
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
}

.sub-text.en {
  color: var(--text-primary);
  font-weight: 500;
}

.sub-text.nl {
  color: var(--text-secondary);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 20px;
}

.sub-action {
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.3;
  transition: var(--transition-fast);
}

.sub-row:hover .sub-action {
  opacity: 1;
  color: var(--accent-blue);
}

/* Lazy load trigger element */
.lazy-load-trigger {
  height: 20px;
}

/* Dialog Backdrop styling */
dialog::backdrop {
  background-color: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(8px);
}

/* Dialog Container */
dialog {
  margin: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  max-width: 650px;
  width: 90%;
  box-shadow: var(--shadow-md);
  outline: none;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-content {
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Side by Side Comparison in Modal */
.aligned-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.lang-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.dialogue-box {
  padding: 16px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 80px;
}

.lang-col.en .dialogue-box {
  border-left: 3px solid var(--accent-blue);
}

.lang-col.nl .dialogue-box {
  border-left: 3px solid var(--accent-purple);
}

/* Helm Prompt Card */
.helm-prompt-box {
  background: linear-gradient(135deg, rgba(120, 50, 255, 0.15) 0%, rgba(0, 149, 255, 0.05) 100%);
  border: 1px solid rgba(120, 50, 255, 0.25);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.helm-prompt-header {
  display: flex;
  flex-direction: column;
}

.helm-prompt-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.helm-prompt-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.prompt-text-container {
  display: flex;
  background-color: rgba(5, 8, 15, 0.6);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  align-items: stretch;
}

.prompt-text {
  flex: 1;
  padding: 14px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-y: auto;
  max-height: 120px;
}

.copy-btn {
  background-color: var(--bg-tertiary);
  border: none;
  border-left: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 120px;
  transition: var(--transition-fast);
}

.copy-btn:hover {
  background-color: var(--accent-blue);
  color: #fff;
}

.copy-btn.copied {
  background-color: var(--accent-emerald);
  color: #fff;
}

/* Tablet & Mobile Layouts */
@media (max-width: 900px) {
  .sub-row {
    grid-template-columns: 80px 1fr 1fr; /* Hide action button */
  }
  .sub-action {
    display: none;
  }
}

@media (max-width: 768px) {
  .mobile-toggle-btn {
    display: block;
  }

  .main-layout {
    position: relative;
  }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
  }

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

  .aligned-comparison {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sub-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 16px;
  }

  .sub-text.nl {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 0;
    padding-top: 8px;
  }
}

/* Alignment Adjustments Sync Panel */
.alignment-adjustments {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.adjust-label {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.adjust-btn {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-body);
  transition: var(--transition-fast);
}

.adjust-btn:hover {
  background-color: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.adjust-btn.reset-btn {
  background-color: transparent;
  color: var(--text-muted);
  border-color: transparent;
  margin-left: 4px;
  text-decoration: underline;
}

.adjust-btn.reset-btn:hover {
  color: hsl(0, 80%, 60%);
  background-color: rgba(255, 0, 0, 0.1);
  border-color: rgba(255, 0, 0, 0.2);
  text-decoration: none;
}

.adjust-value {
  font-family: monospace;
  font-weight: bold;
  color: var(--accent-purple);
  padding: 0 4px;
  min-width: 80px;
  text-align: center;
}

@media (max-width: 900px) {
  .subtitle-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .alignment-adjustments {
    justify-content: center;
  }
}
