/* ═══════════════════════════════════════════════════════════
   КЛИПОВАРНЯ — Dashboard Styles
═══════════════════════════════════════════════════════════ */

/* ── App Layout ────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  max-width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 50;
  transition: transform var(--transition-base);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: rgba(124,58,237,0.15);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.2);
}

.sidebar-nav-item .nav-icon { font-size: 18px; }

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

.credits-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.credits-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.credits-value { font-size: 16px; font-weight: 700; margin-bottom: var(--space-sm); }
.credits-plan {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(124,58,237,0.2);
  color: #a78bfa;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  margin-top: var(--space-sm);
}

/* ── Main content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 0;
  padding: var(--space-xl);
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.page-title { font-size: 28px; font-weight: 800; }
.page-sub { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ── Upload zone ───────────────────────────────────────────── */
.upload-section {
  margin-bottom: var(--space-2xl);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  background: var(--bg-surface);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-purple);
  background: rgba(124,58,237,0.05);
}

.upload-zone.drag-over {
  transform: scale(1.01);
}

.upload-icon-wrap {
  width: 80px;
  height: 80px;
  background: var(--grad-glow);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto var(--space-lg);
  transition: transform var(--transition-base);
}

.upload-zone:hover .upload-icon-wrap {
  transform: scale(1.1) translateY(-4px);
}

.upload-title { font-size: 22px; font-weight: 700; margin-bottom: var(--space-sm); }
.upload-sub { color: var(--text-secondary); font-size: 15px; margin-bottom: var(--space-lg); }

.upload-or {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
  color: var(--text-muted);
  font-size: 13px;
}
.upload-or::before, .upload-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.upload-url-row {
  display: flex;
  gap: var(--space-sm);
  max-width: 500px;
  margin: 0 auto;
}

.upload-formats {
  margin-top: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.format-badge {
  padding: 4px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Settings panel ────────────────────────────────────────── */
.settings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-top: var(--space-lg);
  display: none;
}

.settings-panel.visible { display: block; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.settings-title { font-size: 18px; font-weight: 700; margin-bottom: var(--space-lg); }

.toggle-group {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 2px;
}

.toggle-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.toggle-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--grad-primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(124,58,237,0.4);
}

.range-value {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

.output-format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.output-format-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.output-format-btn:hover,
.output-format-btn.active {
  border-color: var(--accent-purple);
  background: rgba(124, 58, 237, 0.08);
}

.output-format-ratio {
  font-size: 18px;
  font-weight: 800;
}

.output-format-name {
  font-size: 14px;
  font-weight: 600;
}

.output-format-platforms {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.template-btn {
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.template-btn .tpl-swatch {
  height: 64px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px 6px;
  background: #111;
}

.template-btn .tpl-swatch span {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0,0,0,.85);
}

.template-btn .tpl-swatch span .hl {
  color: inherit;
}

.template-btn .tpl-meta {
  padding: 8px 6px 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

.template-btn.active,
.template-btn:hover {
  border-color: var(--accent-purple);
  color: #a78bfa;
  background: rgba(124,58,237,0.1);
}

.template-btn.active {
  box-shadow: 0 0 0 1px rgba(124,58,237,0.45);
}

.caption-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  align-items: start;
}

.caption-preview-phone {
  position: sticky;
  top: 12px;
}

.caption-preview-screen {
  position: relative;
  width: 160px;
  height: 284px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  background: #0a0a0a;
}

.caption-preview-video-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.55) 70%, rgba(0,0,0,0.75) 100%),
    radial-gradient(circle at 30% 30%, #334155, #0f172a 60%);
}

.caption-preview-text {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 36px;
  text-align: center;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 2px 6px rgba(0,0,0,.85);
  z-index: 2;
  word-break: break-word;
}

.caption-preview-text .hl {
  color: #ffd700;
}

.caption-preview-text.is-box {
  background: rgba(255,255,255,0.92);
  color: #111;
  border-radius: 6px;
  padding: 6px 8px;
  text-shadow: none;
}

.caption-preview-text.is-upper {
  text-transform: uppercase;
}

.template-btn .tpl-swatch span {
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  word-break: break-word;
}

.template-btn .tpl-swatch span.is-upper {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.template-btn .tpl-meta {
  font-size: 11px;
  padding: 6px 4px 8px;
  color: var(--text-secondary);
}

.template-btn .tpl-font {
  display: block;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.85;
}

.caption-preview-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .caption-layout {
    grid-template-columns: 1fr;
  }
  .caption-preview-phone {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); max-height: none; }
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  transition: var(--transition-base);
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition-base);
}

input:checked + .switch-slider {
  background: var(--accent-purple);
}

input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* ── Progress overlay ──────────────────────────────────────── */
.processing-card {
  background: var(--bg-surface);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  display: none;
}

.processing-card.visible { display: block; }

.processing-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.processing-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.processing-title { font-size: 18px; font-weight: 700; }
.processing-stage { color: var(--text-secondary); font-size: 14px; }
.processing-eta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.processing-steps {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.proc-step {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: var(--space-sm);
  position: relative;
}

.proc-step::before {
  content: '';
  display: block;
  width: 100%;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

.proc-step.done::before { background: var(--success); }
.proc-step.active::before { background: var(--grad-primary); animation: pulse-bar 1.5s ease-in-out infinite; }

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.proc-step.done { color: var(--success); }
.proc-step.active { color: var(--accent-purple); font-weight: 600; }

/* ── Projects list ─────────────────────────────────────────── */
.manual-ranges-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manual-range-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

.manual-range-row .form-label {
  font-size: 12px;
  margin-bottom: 4px;
}

.manual-range-idx {
  font-weight: 700;
  color: #a78bfa;
  padding-bottom: 10px;
  min-width: 28px;
}

.manual-range-remove {
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}

@media (max-width: 700px) {
  .manual-range-row {
    grid-template-columns: auto 1fr auto;
  }
  .manual-range-row .form-group:nth-child(3) {
    grid-column: 2;
  }
}
.section-heading { font-size: 20px; font-weight: 700; margin-bottom: var(--space-lg); }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
  align-items: start;
}

.project-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 14px 14px;
  flex-wrap: wrap;
  align-items: center;
}

.project-delete-btn {
  margin-left: auto;
  border: 1px solid rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  font-weight: 600;
}

.project-delete-btn:hover,
.project-delete-btn:focus {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.22);
  color: #fecaca;
}


.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.project-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.project-thumb {
  aspect-ratio: 16/9;
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.project-thumb-gradient {
  position: absolute;
  inset: 0;
  background: var(--grad-vibrant);
  opacity: 0.3;
}

.project-info { padding: var(--space-md); }
.project-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.status-done       { background: rgba(16,185,129,0.15); color: #34d399; }
.status-processing { background: rgba(124,58,237,0.15); color: #a78bfa; }
.status-error      { background: rgba(239,68,68,0.15);  color: #f87171; }
.status-uploaded   { background: rgba(245,158,11,0.15); color: #fbbf24; }

.project-progress {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.project-progress .progress-bar { flex: 1; }
.project-progress-pct { font-size: 12px; color: var(--text-secondary); font-weight: 600; min-width: 36px; text-align: right; }

.empty-state {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-secondary);
}

.empty-icon { font-size: 64px; margin-bottom: var(--space-lg); opacity: 0.5; }
.empty-title { font-size: 20px; font-weight: 700; margin-bottom: var(--space-sm); color: var(--text-primary); }

/* ── Top bar (mobile) ──────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--grad-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; }
  .topbar { display: flex; }
  .projects-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .output-format-grid { grid-template-columns: 1fr; }
}
