/* sticky-dvr frontend styles — responsive, no external deps */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f1f5;
  --border: #dde1ea;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --primary: #4f6ef7;
  --primary-dark: #3b57e0;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */

#app { min-height: 100vh; display: flex; flex-direction: column; }

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 52px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -.3px;
}
.nav-brand span { color: var(--primary); }

.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-links a {
  padding: .35rem .75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
}

.nav-user strong { color: var(--text); }

.main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ---- page header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.25rem; font-weight: 700; }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { font-size: .9rem; font-weight: 600; margin-bottom: 1rem; }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .9rem;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: .9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); opacity: 1; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); opacity: 1; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); opacity: 1; }
.btn-sm { padding: .25rem .6rem; font-size: 12px; }

/* ---- forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: 12px; color: var(--danger); margin-top: .3rem; }

select.form-control { cursor: pointer; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: .6rem .75rem; font-weight: 600; color: var(--text-muted);
     background: var(--surface2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }

/* ---- badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.badge-recording  { background: #dcfce7; color: #15803d; }
.badge-running    { background: #dcfce7; color: #15803d; }
.badge-idle       { background: #f3f4f6; color: #6b7280; }
.badge-sleeping   { background: #fef3c7; color: #b45309; }
.badge-starting   { background: #fef3c7; color: #b45309; }
.badge-error      { background: #fee2e2; color: #dc2626; }
.badge-errored    { background: #fee2e2; color: #dc2626; }
.badge-active     { background: #dbeafe; color: #1d4ed8; }
.badge-paused     { background: #fef9c3; color: #a16207; }
.badge-archived   { background: #f3f4f6; color: #9ca3af; }
.badge-admin      { background: #ede9fe; color: #7c3aed; }
.badge-user       { background: #f0fdf4; color: #166534; }
.badge-started    { background: #dcfce7; color: #15803d; }
.badge-exited     { background: #fee2e2; color: #dc2626; }
.badge-stopped    { background: #f3f4f6; color: #6b7280; }
.badge-warning    { background: #fef3c7; color: #b45309; }

/* ---- skeleton loading ---- */
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e8eaed 25%, #f4f5f7 50%, #e8eaed 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius);
}
.skeleton-card {
  height: 120px;
  margin-bottom: .75rem;
}
.skeleton-row {
  height: 44px;
  margin-bottom: .5rem;
}

/* ---- alerts ---- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.alert-warning { background: #fef9c3; border-color: #fde047; color: #a16207; }

/* ---- login page ---- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.login-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

/* ---- stats row ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-num  { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: .25rem; text-transform: uppercase; letter-spacing: .5px; }

/* ---- sub card grid ---- */
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.sub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
  overflow: hidden;
}
.sub-card:hover { box-shadow: var(--shadow-lg); }
.sub-card > div:last-child { padding: 1.1rem; }
.sub-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .6rem; }

.sub-thumb { width: 100%; aspect-ratio: 16/9; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface2); }
.sub-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sub-source { font-weight: 600; font-size: .95rem; word-break: break-word; }
.sub-driver { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: .1rem; }
.sub-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .8rem; }
.sub-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---- source detail ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 700px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.log-box {
  background: #111827;
  color: #d1fae5;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: .75rem;
  border-radius: var(--radius);
  height: 250px;
  overflow-y: auto;
  white-space: pre;
  resize: vertical;
}

/* ---- event list ---- */
.event-list { list-style: none; }
.event-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-item:last-child { border-bottom: none; }
.event-ts { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .6rem; }
.modal-body  { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* ---- empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.empty-state-text  { font-size: .875rem; }

/* ---- spinner ---- */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: .75rem;
  color: var(--text-muted);
}

/* ---- timestamp ---- */
.last-updated {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- add subscription form ---- */
.add-sub-form {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.add-sub-form .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }

/* ---- file browser ---- */
.file-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: .75rem;
  word-break: break-all;
}
.file-breadcrumb a { color: var(--primary); }
.file-thumb-preview {
  width: 48px;
  height: 27px;
  object-fit: cover;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: .5rem;
  background: var(--surface2);
}

/* ---- responsive ---- */
@media (max-width: 600px) {
  .nav { padding: 0 1rem; gap: 1rem; }
  .main { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .sub-grid { grid-template-columns: 1fr; }
  .nav-links a { padding: .3rem .5rem; }
}
