/* ============================================================
   Altered Visions — Admin Panel Stylesheet
   Dark cinematic theme with red/gold accents
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:       #0a0a0f;
  --bg-card:       #13131a;
  --bg-elevated:   #1c1c28;
  --bg-input:      #16161f;
  --red:           #e31c25;
  --red-dark:      #b01018;
  --gold:          #f5a623;
  --gold-dim:      #c47f10;
  --text:          #f0f0f0;
  --text-muted:    #a0a0b0;
  --text-dim:      #606070;
  --border:        #2a2a3a;
  --border-glow:   rgba(245,166,35,0.3);
  --success:       #27ae60;
  --warning:       #f39c12;
  --error:         #e74c3c;
  --info:          #3498db;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        6px;
  --shadow:        0 4px 20px rgba(0,0,0,0.5);
}

html { font-size: 16px; }
body {
  font-family: 'Open Sans', Arial, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: #fff; }

/* ── Layout ─────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-av {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  letter-spacing: 1px;
}
.brand-text {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}
.nav-section { margin-bottom: 8px; }
.nav-label {
  display: block;
  padding: 8px 20px 4px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-family: 'Open Sans', sans-serif;
  font-size: .9rem;
  transition: all .2s;
  border-left: 3px solid transparent;
}
.nav-item i { width: 18px; text-align: center; font-size: .95rem; }
.nav-item:hover {
  color: var(--text);
  background: var(--bg-elevated);
  border-left-color: var(--gold-dim);
}
.nav-item.active {
  color: var(--gold);
  background: rgba(245,166,35,0.08);
  border-left-color: var(--gold);
}
.nav-logout { color: var(--error); }
.nav-logout:hover { color: #ff6b6b; border-left-color: var(--error); }

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

/* ── Main content ───────────────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem; padding: 6px;
  transition: color .2s;
}
.sidebar-toggle:hover { color: var(--gold); }

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: .9rem;
}
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--gold);
}
.topbar-avatar-icon { font-size: 1.8rem; color: var(--text-dim); }
.topbar-username { color: var(--text); font-weight: 600; }

.role-badge {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 2px 8px; border-radius: 20px;
}
.role-admin  { background: rgba(227,28,37,.2); color: var(--red); border: 1px solid var(--red); }
.role-editor { background: rgba(245,166,35,.2); color: var(--gold); border: 1px solid var(--gold); }
.role-author { background: rgba(52,152,219,.2); color: var(--info); border: 1px solid var(--info); }

.admin-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.8rem; font-weight: 600;
  color: var(--text);
}
.page-header h1 span { color: var(--gold); }

/* ── Stat cards (dashboard) ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-glow); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-icon.red  { background: rgba(227,28,37,.15); color: var(--red); }
.stat-icon.gold { background: rgba(245,166,35,.15); color: var(--gold); }
.stat-icon.blue { background: rgba(52,152,219,.15); color: var(--info); }
.stat-icon.green{ background: rgba(39,174,96,.15); color: var(--success); }
.stat-value {
  font-family: 'Oswald', sans-serif;
  font-size: 1.8rem; font-weight: 700;
  line-height: 1; color: var(--text);
}
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem; font-weight: 600; color: var(--text);
}
.card-body { padding: 20px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-family: 'Open Sans', sans-serif; font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .2s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary  { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-gold     { background: var(--gold); color: #111; }
.btn-gold:hover { background: var(--gold-dim); color: #111; }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger   { background: var(--error); color: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-icon { padding: 7px 10px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: .825rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
}
label .req { color: var(--red); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Open Sans', sans-serif;
  font-size: .9rem;
  padding: 10px 14px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--bg-elevated); }

.input-hint {
  font-size: .775rem; color: var(--text-dim); margin-top: 2px;
}

/* Image preview */
.image-preview-wrap { position: relative; display: inline-block; }
.image-preview {
  max-width: 160px; max-height: 200px; display: block;
  border-radius: var(--radius); border: 2px solid var(--border);
  object-fit: cover; margin-top: 8px;
}
.image-preview-wrap.hidden { display: none; }

/* File input styling */
input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}
input[type="file"]::-webkit-file-upload-button {
  background: var(--bg-elevated); color: var(--gold);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 12px; cursor: pointer; font-size: .85rem;
  margin-right: 10px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  padding: 10px 14px; text-align: left;
  font-family: 'Oswald', sans-serif; font-size: .8rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: 12px 14px; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── Status badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px;
}
.badge-published, .badge-active {
  background: rgba(39,174,96,.15); color: var(--success);
  border: 1px solid rgba(39,174,96,.4);
}
.badge-draft {
  background: rgba(245,166,35,.15); color: var(--gold);
  border: 1px solid rgba(245,166,35,.4);
}
.badge-archived, .badge-inactive, .badge-banned {
  background: rgba(255,255,255,.05); color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-lead       { background: rgba(227,28,37,.15); color: var(--red); border: 1px solid rgba(227,28,37,.4); }
.badge-supporting { background: rgba(52,152,219,.15); color: var(--info); border: 1px solid rgba(52,152,219,.4); }
.badge-antagonist { background: rgba(245,166,35,.15); color: var(--gold); border: 1px solid rgba(245,166,35,.4); }
.badge-cameo      { background: rgba(255,255,255,.05); color: var(--text-dim); border: 1px solid var(--border); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 20px; font-size: .9rem;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert::before { font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-top: 1px; }
.alert-success { background: rgba(39,174,96,.1); color: #5ddb8a; border: 1px solid rgba(39,174,96,.3); }
.alert-success::before { content: '\f058'; }
.alert-error   { background: rgba(231,76,60,.1); color: #ff6b6b; border: 1px solid rgba(231,76,60,.3); }
.alert-error::before { content: '\f071'; }
.alert-warning { background: rgba(243,156,18,.1); color: var(--gold); border: 1px solid rgba(243,156,18,.3); }
.alert-warning::before { content: '\f06a'; }
.alert-info    { background: rgba(52,152,219,.1); color: #6ab0e0; border: 1px solid rgba(52,152,219,.3); }
.alert-info::before { content: '\f05a'; }

/* ── Character selector in issues ───────────────────────────── */
.character-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 12px;
}
.char-pick-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
  transition: border-color .2s;
}
.char-pick-item:hover { border-color: var(--gold-dim); }
.char-pick-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--gold); }
.char-pick-item img {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border);
}
.char-pick-item label {
  font-size: .82rem; text-transform: none; letter-spacing: 0;
  color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.char-pick-item.selected { border-color: var(--gold); background: rgba(245,166,35,.07); }

.role-select-inline {
  display: none; margin-top: 6px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: .8rem; padding: 4px;
}
.char-pick-item.selected .role-select-inline { display: block; }

/* ── Thumbnail strip ─────────────────────────────────────────── */
.thumb-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.thumb-item {
  position: relative; width: 80px; height: 80px;
}
.thumb-item img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border);
}
.thumb-remove {
  position: absolute; top: -6px; right: -6px;
  background: var(--red); color: #fff;
  border: none; border-radius: 50%; width: 20px; height: 20px;
  cursor: pointer; font-size: .65rem; display: flex;
  align-items: center; justify-content: center;
}

/* ── Media library grid ──────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.media-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s, transform .2s;
}
.media-item:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.media-item-icon {
  height: 110px; display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text-dim);
}
.media-item .media-meta {
  padding: 6px 8px; font-size: .72rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-item .media-actions { padding: 0 8px 8px; display: flex; gap: 4px; }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(227,28,37,.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(245,166,35,.04) 0%, transparent 50%);
}
.login-box {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 40px; box-shadow: var(--shadow);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .av-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; background: var(--red);
  border-radius: 8px; font-family: 'Oswald', sans-serif;
  font-size: 1.6rem; font-weight: 700; color: #fff; margin-bottom: 10px;
}
.login-logo h1 {
  font-family: 'Oswald', sans-serif; font-size: 1.3rem;
  font-weight: 600; color: var(--text-muted); letter-spacing: 3px;
}
.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-error {
  background: rgba(231,76,60,.1); color: #ff6b6b;
  border: 1px solid rgba(231,76,60,.3);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: .875rem; margin-bottom: 16px;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { margin-top: 20px; }
.pagination ul { list-style: none; display: flex; gap: 4px; flex-wrap: wrap; }
.pagination li a, .pagination li.active a {
  display: inline-block; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-muted); font-size: .85rem; transition: all .2s;
}
.pagination li a:hover { border-color: var(--gold-dim); color: var(--gold); }
.pagination li.active a { background: var(--red); border-color: var(--red); color: #fff; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
