/**
 * Kazakan Tools 2.0 — Subtitle Editor Studio & Synced Media Player
 */
/* ==========================================================================
   Subtitle Editor — Premium Glassmorphic Studio & Responsive Table
   ========================================================================== */

.sub-editor-card {
  padding: clamp(16px, 2.5vw, 24px);
  background: var(--bg-surface, rgba(17, 24, 39, 0.7));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .sub-editor-card {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.05);
}

/* Header & Main Actions Bar */
.sub-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-block-end: 20px;
  padding-block-end: 18px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.sub-file-info-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sub-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  font-size: 0.86rem;
  color: var(--text-main, #e2e8f0);
}

[data-theme="light"] .sub-file-pill {
  background: rgba(241, 245, 249, 0.95);
  border-color: #cbd5e1;
  color: #1e293b;
}

.sub-pill-icon {
  width: 16px;
  height: 16px;
  color: var(--brand-primary, #3b82f6);
  flex-shrink: 0;
}

.sub-filename-text {
  font-weight: 700;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sub-badge-format {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

[data-theme="light"] .sub-badge-format {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.25);
}

.sub-badge-count {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .sub-badge-count {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.25);
}

.sub-main-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sub-export-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Base Subtitle Buttons */
.sub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 650;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
}

.sub-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.sub-btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.sub-btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.sub-btn-primary:active {
  transform: scale(0.98);
}

.sub-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main, #e2e8f0);
  border-color: var(--border-subtle, rgba(255, 255, 255, 0.14));
}

[data-theme="light"] .sub-btn-secondary {
  background: #ffffff;
  color: #1e293b;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sub-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--brand-primary, #3b82f6);
  color: #ffffff;
  transform: translateY(-1px);
}

[data-theme="light"] .sub-btn-secondary:hover {
  background: #f8fafc;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.sub-btn-action {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
  padding: 5px 12px;
  min-height: 34px;
}

[data-theme="light"] .sub-btn-action {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.25);
}

.sub-btn-action:hover {
  background: var(--brand-primary, #3b82f6);
  color: #ffffff;
  border-color: var(--brand-primary, #3b82f6);
  transform: translateY(-1px);
}

/* Tools Bar (Time Shift & Replace) */
.sub-tools-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  margin-block-end: 20px;
}

.sub-tool-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
}

[data-theme="light"] .sub-tool-group {
  background: rgba(248, 250, 252, 0.8);
  border-color: #e2e8f0;
}

.sub-tool-group-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
}

.sub-tool-group-label svg {
  width: 14px;
  height: 14px;
  color: var(--brand-primary, #3b82f6);
}

.sub-shift-controls,
.sub-replace-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-quick-shifts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

[data-theme="light"] .sub-quick-shifts {
  background: #ffffff;
  border-color: #e2e8f0;
}

.sub-quick-shift-btn {
  background: transparent;
  border: none;
  color: var(--text-main, #e2e8f0);
  font-size: 0.78rem;
  font-weight: 650;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="light"] .sub-quick-shift-btn {
  color: #334155;
}

.sub-quick-shift-btn:hover {
  background: var(--brand-primary, #3b82f6);
  color: #ffffff;
}

.sub-shift-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sub-number-input {
  width: 72px;
  text-align: center;
  font-weight: 700;
}

.sub-unit-label {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

/* Video Section */
.sub-video-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-block-end: 20px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 14px;
}

[data-theme="light"] .sub-video-section {
  background: rgba(248, 250, 252, 0.6);
  border-color: #cbd5e1;
}

.sub-video-picker-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sub-video-picker-btn {
  cursor: pointer;
  margin: 0;
}

.sub-video-container {
  position: relative;
  max-width: 680px;
  width: 100%;
  margin-inline: auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.sub-video-container video {
  display: block;
  width: 100%;
  max-height: 380px;
  background: #000;
}

.sub-video-overlay {
  position: absolute;
  bottom: 44px;
  left: 6%;
  right: 6%;
  text-align: center;
  pointer-events: none;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 700;
  line-height: 1.4;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.65);
  padding: 6px 14px;
  border-radius: 8px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-width: 90%;
  margin-inline: auto;
  transition: opacity 0.15s ease;
}

/* Subtitle Table Container & Table */
.sub-table-container {
  max-height: 540px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  background: rgba(0, 0, 0, 0.2);
  scrollbar-gutter: stable;
}

[data-theme="light"] .sub-table-container {
  background: #ffffff;
  border-color: #e2e8f0;
}

.sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.sub-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
}

[data-theme="light"] .sub-table th {
  background: rgba(241, 245, 249, 0.95);
  color: #475569;
  border-color: #cbd5e1;
}

.sub-cue-row {
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

[data-theme="light"] .sub-cue-row {
  border-bottom-color: #f1f5f9;
}

.sub-cue-row:hover {
  background: rgba(255, 255, 255, 0.035);
}

[data-theme="light"] .sub-cue-row:hover {
  background: #f8fafc;
}

/* === CRITICAL: Active Playing Cue Highlighting & Indicator === */
.sub-cue-row.is-active-cue {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.24) 0%, rgba(59, 130, 246, 0.08) 100%) !important;
  border-inline-start: 4px solid var(--brand-primary, #3b82f6) !important;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35) !important;
}

[data-theme="light"] .sub-cue-row.is-active-cue {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0.06) 100%) !important;
  border-inline-start: 4px solid #2563eb !important;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.3) !important;
}

.sub-cue-row.is-active-cue .sub-cue-index {
  color: var(--brand-primary, #3b82f6) !important;
  font-weight: 800;
}

.sub-cue-row.is-active-cue .sub-time-input,
.sub-cue-row.is-active-cue .sub-text-textarea {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(255, 255, 255, 0.07);
}

[data-theme="light"] .sub-cue-row.is-active-cue .sub-time-input,
[data-theme="light"] .sub-cue-row.is-active-cue .sub-text-textarea {
  background: #ffffff;
  border-color: #3b82f6;
}

.sub-cue-row-error {
  background: rgba(239, 68, 68, 0.12) !important;
  border-inline-start: 4px solid #ef4444 !important;
}

.sub-cue-row td {
  padding: 8px 10px;
  vertical-align: middle;
}

.sub-cue-index {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
}

.sub-time-input {
  width: 100%;
  text-align: center;
  font-family: monospace, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  padding: 5px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  color: var(--text-main, #e2e8f0);
  box-sizing: border-box;
}

[data-theme="light"] .sub-time-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

.sub-time-input:focus {
  border-color: var(--brand-primary, #3b82f6);
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.sub-text-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.86rem;
  line-height: 1.45;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  color: var(--text-main, #e2e8f0);
  resize: vertical;
  min-height: 48px;
}

[data-theme="light"] .sub-text-textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

.sub-text-textarea:focus {
  border-color: var(--brand-primary, #3b82f6);
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

/* Action Buttons inside Table Rows */
.sub-cue-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.sub-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

[data-theme="light"] .sub-action-btn {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

.sub-action-btn svg {
  width: 14px;
  height: 14px;
}

.sub-action-btn:hover {
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.35);
  transform: translateY(-1px);
}

[data-theme="light"] .sub-action-btn:hover {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.3);
}

.sub-action-btn-danger:hover {
  background: rgba(239, 68, 68, 0.16) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.35) !important;
}

.cue-play-btn:hover {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.35) !important;
}

@media (max-width: 768px) {
  .sub-header-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .sub-file-info-group,
  .sub-main-actions {
    justify-content: space-between;
  }
  .sub-tools-bar {
    grid-template-columns: 1fr;
  }
}

#sub-editor-wrap {
  margin-block-start: var(--space-4);
}

@media (max-width: 640px) {
  .sub-video-section {
    padding: 10px 12px;
    border-radius: 12px;
  }

  .sub-video-container video {
    max-height: 240px;
  }

  .sub-table-container {
    max-height: 420px;
  }

  .sub-table th,
  .sub-table td {
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  .sub-btn-action,
  .sub-btn-primary {
    min-height: 44px;
    padding: 6px 14px;
  }
}

@media (max-width: 420px) {
  .sub-video-container video {
    max-height: 180px;
  }

  .sub-table th,
  .sub-table td {
    padding: 6px 4px;
    font-size: 0.72rem;
  }
}

/* Low-Spec & No-GPU Solid Fallback */
html.no-glass .sub-table-container {
  background: #0d1527 !important;
  border-color: #1e293b !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
}

html.no-glass[data-theme="light"] .sub-table-container {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05) !important;
}

html.no-glass .sub-table th {
  background: #0f172a !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.no-glass[data-theme="light"] .sub-table th {
  background: #f8fafc !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

@supports not (backdrop-filter: blur(10px)) {
  .sub-table-container {
    background: #0d1527 !important;
    border-color: #1e293b !important;
  }
  [data-theme="light"] .sub-table-container {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
  }
  .sub-table th {
    background: #0f172a !important;
  }
  [data-theme="light"] .sub-table th {
    background: #f8fafc !important;
  }
}
