/* ============================================================
   Webpages.dk — Global Stylesheet
   ============================================================ */

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

:root {
  /* Brand */
  --primary:       #4f6ef7;
  --primary-dark:  #3b54e0;
  --primary-light: #e8ecff;

  /* Grays */
  --bg:            #0f1117;
  --bg-card:       #161b22;
  --bg-input:      #0d1117;
  --border:        #30363d;
  --border-light:  #21262d;

  /* Text */
  --text:          #e1e4e8;
  --text-muted:    #8b949e;
  --text-dim:      #6e7681;
  --heading:       #f0f6fc;

  /* Status */
  --green:         #3fb950;
  --green-bg:      #0d2818;
  --green-border:  #238636;
  --yellow:        #e3b341;
  --yellow-bg:     #1a1300;
  --yellow-border: #9e6a03;
  --red:           #f85149;
  --red-bg:        #2d0f0f;
  --red-border:    #da3633;
  --blue:          #58a6ff;
  --blue-bg:       #051d4d;
  --blue-border:   #1f6feb;

  /* Sidebar */
  --sidebar-w:     240px;

  /* Misc */
  --radius:        8px;
  --radius-sm:     4px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.4);
  --shadow-md:     0 4px 12px rgba(0,0,0,.5);
  --transition:    .18s ease;
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

/* ─── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  color: var(--heading);
  line-height: 1.3;
  font-weight: 600;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 4px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 28px;
}

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

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

.page-body {
  padding: 32px 36px;
  flex: 1;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  font-weight: 700;
  color: var(--heading);
  font-size: 1rem;
}
.sidebar-brand .brand-role {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}
.sidebar-section {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 12px 4px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .875rem;
  transition: all var(--transition);
  text-decoration: none;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--border-light);
}
.sidebar-nav a.active {
  color: var(--blue);
  background: var(--blue-bg);
}
.sidebar-nav a .icon {
  width: 18px;
  text-align: center;
  opacity: .7;
  flex-shrink: 0;
}
.sidebar-nav a.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.sidebar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-user .user-info .name {
  font-size: .85rem;
  color: var(--text);
  font-weight: 500;
}
.sidebar-user .user-info .email {
  font-size: .75rem;
  color: var(--text-muted);
}

/* ─── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  position: sticky; top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right a { color: var(--text-muted); font-size: .875rem; }
.topbar-right a:hover { color: var(--text); text-decoration: none; }

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
}

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1;
}
.stat-change {
  font-size: .8rem;
  margin-top: 6px;
  color: var(--text-muted);
}
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--border-light); }

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  transition: border-color var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-success   { background: var(--green-border); color: #fff; }
.btn-success:hover { background: #2ea043; text-decoration: none; }
.btn-danger    { background: var(--red-border); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-secondary { background: var(--border-light); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-outline   { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--border-light); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success   { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-warning   { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-danger    { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-info      { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.badge-secondary { background: var(--border-light); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .875rem;
}
.alert-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.alert-warning { background: var(--yellow-bg); border: 1px solid var(--yellow-border); color: var(--yellow); }
.alert-danger  { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.alert-info    { background: var(--blue-bg); border: 1px solid var(--blue-border); color: var(--blue); }

/* ─── Auth Pages ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: #fff;
}
.auth-logo .logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--heading);
}
.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 4px;
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 24px;
}
.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: .875rem;
  color: var(--text-muted);
}

/* Role selector */
.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.role-option input[type="radio"] { display: none; }
.role-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  font-size: .8rem;
  color: var(--text-muted);
}
.role-option label .icon { font-size: 1.4rem; }
.role-option label .role-name { font-weight: 600; font-size: .875rem; color: var(--text); }
.role-option input:checked + label {
  border-color: var(--primary);
  background: rgba(79,110,247,.1);
  color: var(--text);
}
.role-option label:hover { border-color: var(--text-dim); }

/* ─── Divider ─────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.empty-state h3 { color: var(--text-muted); font-size: 1rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-dim); font-size: .875rem; margin-bottom: 20px; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  justify-content: center;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination a:hover { background: var(--border-light); color: var(--text); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Utilities ──────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mb-2   { margin-bottom: 8px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-blue  { color: var(--blue); }
.font-mono  { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-bold  { font-weight: 700; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* ============================================================
   THEME: Light
   ============================================================ */
html[data-theme="light"] {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;

  --bg:            #f6f8fa;
  --bg-card:       #ffffff;
  --bg-input:      #ffffff;
  --border:        #d0d7de;
  --border-light:  #eaeef2;

  --text:          #1f2328;
  --text-muted:    #656d76;
  --text-dim:      #9198a1;
  --heading:       #0d1117;

  --green:         #1a7f37;
  --green-bg:      #dafbe1;
  --green-border:  #4ac26b;
  --yellow:        #9a6700;
  --yellow-bg:     #fff8c5;
  --yellow-border: #d4a72c;
  --red:           #cf222e;
  --red-bg:        #ffebe9;
  --red-border:    #ff8182;
  --blue:          #0969da;
  --blue-bg:       #ddf4ff;
  --blue-border:   #54aeff;

  --shadow:        0 1px 3px rgba(31,35,40,.12);
  --shadow-md:     0 4px 12px rgba(31,35,40,.15);
}

html[data-theme="light"] body              { background: var(--bg); color: var(--text); }
html[data-theme="light"] .sidebar-nav a    { color: var(--text-muted); }
html[data-theme="light"] .sidebar-nav a:hover  { background: #f1f5f9; color: var(--text); }
html[data-theme="light"] .sidebar-nav a.active { background: #eff6ff; color: #1d4ed8; }
html[data-theme="light"] tbody tr:hover td { background: #f1f5f9; }
html[data-theme="light"] .btn-outline      { color: var(--text); }
html[data-theme="light"] .badge-secondary  { background: #eaeef2; color: #57606a; border-color: #d0d7de; }
html[data-theme="light"] select.form-control { background: #fff; }
html[data-theme="light"] pre               { background: #f6f8fa !important; color: #1f2328 !important; border: 1px solid var(--border); }

/* ============================================================
   THEME: Colorful  (deep violet + neon accents)
   ============================================================ */
html[data-theme="colorful"] {
  --primary:       #a855f7;
  --primary-dark:  #9333ea;
  --primary-light: rgba(168,85,247,.18);

  --bg:            #12002a;
  --bg-card:       #1e0538;
  --bg-input:      #0e001e;
  --border:        #4c1d95;
  --border-light:  #2e0f60;

  --text:          #e9d5ff;
  --text-muted:    #a78bca;
  --text-dim:      #7c5fa0;
  --heading:       #f5f3ff;

  --green:         #34d399;
  --green-bg:      #022c22;
  --green-border:  #10b981;
  --yellow:        #fbbf24;
  --yellow-bg:     #1c1000;
  --yellow-border: #d97706;
  --red:           #f87171;
  --red-bg:        #2d0000;
  --red-border:    #ef4444;
  --blue:          #60a5fa;
  --blue-bg:       #0a1628;
  --blue-border:   #3b82f6;

  --shadow:        0 1px 3px rgba(0,0,0,.7);
  --shadow-md:     0 4px 16px rgba(168,85,247,.25);
}

/* Colorful: gradient sidebar */
html[data-theme="colorful"] .sidebar {
  background: linear-gradient(180deg, #280655 0%, #150030 100%);
  border-right-color: #4c1d95;
}
html[data-theme="colorful"] .sidebar-brand   { border-bottom-color: #4c1d95; }
html[data-theme="colorful"] .sidebar-brand .logo {
  background: linear-gradient(135deg, #a855f7, #ec4899);
}
html[data-theme="colorful"] .sidebar-footer  { border-top-color: #4c1d95; }
html[data-theme="colorful"] .sidebar-section { color: #7c5fa0; }
html[data-theme="colorful"] .sidebar-nav a        { color: #c4b5fd; }
html[data-theme="colorful"] .sidebar-nav a:hover   { background: rgba(168,85,247,.15); color: #f0e6ff; }
html[data-theme="colorful"] .sidebar-nav a.active  { background: rgba(168,85,247,.25); color: #e879f9; }
html[data-theme="colorful"] .sidebar-nav a.active .icon { opacity: 1; }

/* Colorful: gradient topbar */
html[data-theme="colorful"] .topbar {
  background: linear-gradient(90deg, #1e0538 0%, #12002a 100%);
  border-bottom-color: #4c1d95;
}

/* Colorful: cards, stat-cards */
html[data-theme="colorful"] .card,
html[data-theme="colorful"] .stat-card    { border-color: #4c1d95; }
html[data-theme="colorful"] .stat-card    { box-shadow: 0 0 12px rgba(168,85,247,.08); }

/* Colorful: table rows */
html[data-theme="colorful"] tbody tr:hover td { background: rgba(168,85,247,.08); }
html[data-theme="colorful"] thead th      { border-bottom-color: #4c1d95; }
html[data-theme="colorful"] tbody td      { border-bottom-color: #2e0f60; }

/* Colorful: form */
html[data-theme="colorful"] .form-control:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168,85,247,.2);
}

/* Colorful: buttons */
html[data-theme="colorful"] .btn-primary  { background: #a855f7; border-color: #a855f7; }
html[data-theme="colorful"] .btn-primary:hover { background: #9333ea; }
html[data-theme="colorful"] .btn-outline  { color: #c4b5fd; border-color: #4c1d95; }
html[data-theme="colorful"] .btn-outline:hover { background: rgba(168,85,247,.12); }
html[data-theme="colorful"] .btn-secondary { background: #2e0f60; border-color: #4c1d95; color: var(--text); }

/* Colorful: code / pre blocks */
html[data-theme="colorful"] pre           { background: #0e001e !important; }

/* Colorful: auth card */
html[data-theme="colorful"] .auth-card    { border-color: #4c1d95; }
html[data-theme="colorful"] .role-option input:checked + label {
  border-color: #a855f7;
  background: rgba(168,85,247,.12);
}

/* Colorful: pagination active */
html[data-theme="colorful"] .pagination .current { background: #a855f7; border-color: #a855f7; }

/* ─── Schedule pill toggles ─────────────────────────────────── */
.sched-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
  min-width: 36px;
}
.sched-pill:hover {
  border-color: var(--primary);
  color: var(--text);
}
.sched-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ─── Theme Switcher ─────────────────────────────────────────── */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
}
.theme-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: .02em;
  text-decoration: none;
  display: inline-block;
}
.theme-btn:hover  { color: var(--text); background: var(--border-light); }
.theme-btn.active { background: var(--primary); color: #fff; }
