/* Dashboard-specific layout & components */

/* ---------- Auth view ---------- */
.auth-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-panel {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 32px 28px;
  display: flex; flex-direction: column; gap: 18px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand h1 { font-size: 22px; }
.auth-logo { display: inline-flex; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: var(--accent-contrast); align-items: center; justify-content: center; }
.auth-logo .icon { width: 22px; height: 22px; }
.auth-tagline { margin-top: -8px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-links { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; text-align: center; }

/* ---------- App shell ---------- */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .brand-mark { display: inline-flex; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-contrast); align-items: center; justify-content: center; }
.brand .brand-mark .icon { width: 16px; height: 16px; }

.topbar-search { position: relative; flex: 1; max-width: 480px; margin: 0 auto; }
.topbar-search .input { padding-left: 36px; min-height: 36px; background: var(--surface-2); border-color: transparent; }
.topbar-search .input:focus { background: var(--surface); border-color: var(--accent); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: inline-flex; }
.search-icon .icon { width: 16px; height: 16px; }

.app-body { display: flex; flex: 1; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px; flex: none; padding: 14px 10px;
  display: flex; flex-direction: column; gap: 18px;
  border-right: 1px solid var(--border); background: var(--surface);
  overflow-y: auto;
}
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-heading {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); padding: 0 10px 4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; font-weight: 500;
  cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left;
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.sidebar-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 59; }

#navToggle { display: none; }
@media (max-width: 900px) {
  #navToggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
    box-shadow: var(--shadow-lg); width: 260px; padding-top: 18px;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-search { max-width: none; }
  .brand span:not(.brand-mark) { display: none; }
}

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; padding: 20px; max-width: 1400px; margin: 0 auto; width: 100%; }
.content-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.content-header h2 { font-size: 19px; }
.select-sm { min-height: 32px; padding: 4px 30px 4px 10px; font-size: 13px; width: auto; }

/* ---------- Library grid ---------- */
.library-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.library-grid.list-mode { grid-template-columns: 1fr; gap: 8px; }

.video-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex; flex-direction: column;
}
.video-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.video-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.video-thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--text-3); overflow: hidden;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb .thumb-placeholder .icon { width: 34px; height: 34px; stroke-width: 1.5; }
.video-thumb .duration-badge {
  position: absolute; right: 8px; bottom: 8px;
  background: rgb(0 0 0 / 0.75); color: #fff; font-size: 12px; font-weight: 600;
  padding: 1px 7px; border-radius: 5px;
}
.video-thumb .play-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgb(0 0 0 / 0); transition: background var(--transition); opacity: 0;
}
.video-thumb:hover .play-overlay { background: rgb(0 0 0 / 0.3); opacity: 1; }
.play-overlay .play-circle {
  width: 46px; height: 46px; border-radius: 50%; background: rgb(255 255 255 / 0.92);
  color: #111; display: flex; align-items: center; justify-content: center;
}
.play-circle .icon { width: 20px; height: 20px; margin-left: 2px; fill: currentColor; }

.video-card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.video-card-title-row { display: flex; align-items: flex-start; gap: 6px; }
.video-card-title {
  font-weight: 600; font-size: 14px; line-height: 1.35; flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  cursor: pointer; border: 0; background: none; text-align: left; padding: 0; color: var(--text);
}
.video-card-title:hover { color: var(--accent); }
.video-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.video-card-meta .dot::before { content: "·"; margin-right: 8px; }
.video-card-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.fav-star { color: var(--warning); }
.fav-star .icon { fill: currentColor; }

.select-check {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: transparent;
}
.select-check.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.select-check .icon { width: 14px; height: 14px; }

/* List mode */
.list-mode .video-card { flex-direction: row; align-items: center; }
.list-mode .video-thumb { width: 150px; aspect-ratio: 16 / 9; flex: none; }
.list-mode .video-card-body { padding: 8px 14px; }
.list-mode .video-card-title { -webkit-line-clamp: 1; }
@media (max-width: 560px) {
  .list-mode .video-thumb { width: 110px; }
}

.load-more-wrap { display: flex; justify-content: center; padding: 22px 0 8px; }

/* ---------- Share dialog ---------- */
.share-mode-grid { display: flex; flex-direction: column; gap: 8px; }
.share-mode {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: transparent; text-align: left; width: 100%; color: var(--text);
}
.share-mode:hover { background: var(--surface-2); }
.share-mode[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.share-mode .icon { margin-top: 1px; color: var(--text-2); }
.share-mode[aria-pressed="true"] .icon { color: var(--accent-strong); }
.share-mode-label { font-weight: 600; font-size: 14px; }
.share-mode-desc { font-size: 12.5px; color: var(--text-2); }

.share-link-row { display: flex; gap: 8px; }
.share-link-row .input { font-family: var(--font-mono); font-size: 13px; }
.share-qr { display: flex; justify-content: center; padding: 8px; }
.share-qr img { width: 200px; height: 200px; border-radius: var(--radius-sm); background: #fff; padding: 8px; }

/* ---------- Analytics dialog ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat-tile { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-tile .stat-value { font-size: 20px; font-weight: 700; }
.stat-tile .stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- Redaction editor ---------- */
/* Redaction editor gets a much wider stage than a normal modal. */
.modal.modal-redact { max-width: min(1100px, 96vw); }
.redact-layout { display: flex; gap: 16px; align-items: flex-start; }
.redact-main { flex: 1 1 auto; min-width: 0; }
.redact-side { flex: 0 0 260px; display: flex; flex-direction: column; gap: 12px; }

.redact-stage {
  position: relative; user-select: none; touch-action: none;
  background: #000; border-radius: 8px; overflow: hidden;
}
.redact-stage video { display: block; width: 100%; height: auto; }
/* Transparent overlay that captures the drag (native controls would eat it). */
.redact-draw { position: absolute; inset: 0; cursor: crosshair; }
.redact-box {
  position: absolute; border: 2px solid var(--accent);
  background: rgb(99 102 241 / 0.18);
  pointer-events: none; border-radius: 2px;
}
.redact-box-pending { box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.28); }
.redact-box-committed { border-style: dashed; background: rgb(99 102 241 / 0.12); }
.redact-box-committed::after {
  content: attr(data-n); position: absolute; top: -1px; left: -1px;
  background: var(--accent); color: #fff; font-size: 11px; line-height: 1;
  padding: 2px 5px; border-radius: 2px 0 4px 0;
}

.redact-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.redact-play { flex: 0 0 auto; min-width: 40px; }
.redact-seek { flex: 1 1 auto; min-width: 0; }
.redact-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-2); white-space: nowrap; }

.redact-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.redact-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.redact-item-seek { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
.redact-item-time { flex: 1 1 auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); }
.redact-item-del { flex: 0 0 auto; background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px; }
.redact-item-del:hover { color: var(--danger); }

@media (max-width: 720px) {
  .redact-layout { flex-direction: column; }
  .redact-side { flex-basis: auto; width: 100%; }
}

/* ---------- Upload ---------- */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 28px 16px; cursor: pointer; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-2); font-size: 14px;
  transition: border-color var(--transition), background var(--transition);
}
.upload-drop:hover, .upload-drop.drag-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.upload-drop .icon { width: 26px; height: 26px; color: var(--text-3); stroke-width: 1.5; }
.upload-drop:hover .icon, .upload-drop.drag-over .icon { color: var(--accent); }
.upload-drop b { color: var(--text); font-weight: 600; }

.upload-list { display: flex; flex-direction: column; gap: 10px; }
.upload-list:empty { display: none; }
.upload-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 7px;
  background: var(--surface);
}
.upload-item-head { display: flex; align-items: center; gap: 8px; }
.upload-item-name { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; }
.upload-item-size { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.upload-progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; border-radius: inherit; background: var(--accent); transition: width 200ms linear; }
.upload-item.done .upload-progress-fill { background: var(--success); }
.upload-item.error .upload-progress-fill { background: var(--danger); }
.upload-item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.upload-item-status { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.upload-item.error .upload-item-status { color: var(--danger); }

.drop-overlay {
  position: fixed; inset: 0; z-index: 95; background: var(--backdrop);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; animation: fadeIn 120ms ease;
}
.drop-overlay-panel {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--surface); border: 2px dashed var(--accent); border-radius: var(--radius-lg);
  padding: 42px 60px; font-size: 16px; font-weight: 600; box-shadow: var(--shadow-lg);
}
.drop-overlay-panel .icon { width: 36px; height: 36px; color: var(--accent); stroke-width: 1.5; }

/* ---------- Skeleton cards ---------- */
.skeleton-card { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.skeleton-card .sk-thumb { aspect-ratio: 16/9; }
.skeleton-card .sk-lines { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.skeleton-card .sk-line { height: 12px; }
