/* ============================================================
   TTube – Admin Panel Stylesheet
   ============================================================ */

:root {
  --admin-bg:        #0d0d0d;
  --admin-surface:   #161616;
  --admin-sidebar-w: 220px;
  --admin-card:      #1e1e1e;
  --admin-border:    #2a2a2a;
  --admin-border-l:  #333;
  --text-primary:    #f0f0f0;
  --text-secondary:  #aaa;
  --text-muted:      #555;
  --accent:          #ff4444;
  --accent-hover:    #e03333;
  --accent-light:    rgba(255,68,68,.12);
  --success:         #22c55e;
  --success-light:   rgba(34,197,94,.1);
  --danger:          #ef4444;
  --danger-light:    rgba(239,68,68,.1);
  --warning:         #f59e0b;
  --radius-sm:       6px;
  --radius-md:       10px;
  --shadow:          0 4px 20px rgba(0,0,0,.4);
  --font:            'Inter', system-ui, -apple-system, sans-serif;
  --transition:      .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--admin-bg); color: var(--text-primary); line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.admin-body { background: var(--admin-bg); }
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--admin-sidebar-w);
  flex-shrink: 0;
  background: var(--admin-surface);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--admin-border);
}
.admin-logo a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}
.admin-logo .logo-icon { color: var(--accent); font-size: 17px; }
.admin-logo small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.admin-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-section-label {
  padding: 12px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
  border-left: 3px solid transparent;
}
.admin-nav-link:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,.04);
}
.admin-nav-link.active {
  color: var(--text-primary);
  background: var(--accent-light);
  border-left-color: var(--accent);
}
.nav-logout { margin-top: 4px; }
.nav-logout:hover { color: var(--danger); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.admin-user {
  padding: 14px 18px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}
.user-avatar { font-size: 18px; }
.user-name { font-weight: 500; }

/* ── Content area ─────────────────────────────────────────── */
.admin-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  gap: 16px;
  flex-wrap: wrap;
}
.admin-page-title {
  font-size: 20px;
  font-weight: 700;
}
.admin-topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Inner padding */
.admin-content > *:not(.admin-topbar) {
  padding: 24px 28px;
}

/* ── Dashboard ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  text-align: center;
}
.stat-icon { font-size: 28px; margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }

.dashboard-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dashboard-panel {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
}
.panel-header h2 { font-size: 15px; font-weight: 700; }

.top-list { padding: 8px 0; }
.top-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--admin-border);
}
.top-item:last-child { border-bottom: none; }
.top-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  width: 20px;
  flex-shrink: 0;
}
.top-info { flex: 1; min-width: 0; }
.top-title {
  font-size: 13px;
  font-weight: 500;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-title:hover { color: var(--accent); }
.top-views { font-size: 12px; color: var(--text-muted); }

/* ── Panel ────────────────────────────────────────────────── */
.panel {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.panel-narrow { max-width: 580px; padding: 28px 28px; }
.panel-narrow.panel { overflow: visible; }

/* ── Data Table ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid var(--admin-border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.data-table td:first-child { color: var(--text-primary); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.data-table a:hover { color: var(--accent); }
.table-actions { white-space: nowrap; }

code {
  font-size: 12px;
  background: rgba(255,255,255,.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ── Admin Pagination ─────────────────────────────────────── */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--admin-border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary  { background: var(--accent);   color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: rgba(255,255,255,.07); color: var(--text-secondary); border: 1px solid var(--admin-border-l); }
.btn-secondary:hover { background: rgba(255,255,255,.12); color: var(--text-primary); }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }

.btn-sm  { padding: 6px 13px; font-size: 13px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-success {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.alert-error {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}
.form-col-main, .form-col-side { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.req { color: var(--accent); }
.form-hint { font-size: 12px; color: var(--text-muted); }

.form-control {
  width: 100%;
  padding: 9px 13px;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border-l);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-control-file {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Thumbnail preview */
.thumb-preview-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border-l);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}
.thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-preview {
  border-radius: 50%;
  width: 80px;
  height: 80px;
  margin: 12px auto;
}
.thumb-preview-wrap:has(.avatar-preview) {
  aspect-ratio: 1/1;
  width: 104px;
  border-radius: 50%;
}

/* Checkboxes */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border-l);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background var(--transition);
}
.checkbox-item:hover { background: rgba(255,255,255,.04); color: var(--text-primary); }
.checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--admin-border);
  flex-wrap: wrap;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--admin-bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-logo .logo-icon { color: var(--accent); }
.login-title {
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 26px;
}
.login-back {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-back a:hover { color: var(--text-primary); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 960px) {
  .admin-sidebar { width: 180px; }
  .dashboard-cols { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding-bottom: 0;
  }
  .admin-sidebar .admin-nav { display: flex; flex-wrap: wrap; padding: 0; }
  .admin-nav-link { padding: 10px 12px; font-size: 12px; border-left: none; border-bottom: 3px solid transparent; }
  .admin-nav-link.active { border-bottom-color: var(--accent); border-left-color: transparent; }
  .admin-user { display: none; }
  .admin-content > *:not(.admin-topbar) { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
