﻿/* =========================================
   ADMIN — dark-only + compactable sidebar
   (with fallbacks so cards render even if
   site-level CSS variables aren't present)
   ========================================= */

:root {
  --appbar-h: 80px;
  --sidebar-w: 240px;
  --sidebar-w-compact: 80px;
  --radius: 12px;
  --radius-lg: var(--radius-md, 12px);
  /* Dark palette (with safe fallbacks) */
  --bg: var(--darker-bg, #0b1020);
  --surface: var(--dark-bg, #0f162e);
  --elev: var(--card-bg, #131a33);
  --text: var(--text-primary, #eef2ff);
  --muted: var(--text-secondary, #9aa4c7);
  --brand: var(--primary-blue, #3B82F6);
  --ok: #22c55e;
  --danger: #ef4444;
  --divider: var(--card-border, #1f2a44);
  --shadow-md-admin: 0 10px 30px rgba(0,0,0,.35);
  --shadow-lg-admin: 0 20px 60px rgba(0,0,0,.45);
}

/* ===== Root shell ===== */
.ap-root {
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(60% 40% at 20% 20%, rgba(126,28,187,.15) 0%, transparent 60%), radial-gradient(50% 40% at 80% 30%, rgba(35,147,226,.12) 0%, transparent 60%), radial-gradient(60% 35% at 40% 80%, rgba(255,68,102,.10) 0%, transparent 70%), var(--bg);
  color: var(--text);
}

/* ===== AppBar ===== */
.ap-appbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(10,14,26,.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--divider);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  z-index: 1000 !important;
}

.ap-appbar__menu {
  display: none;
}

.ap-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.ap-brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(126,28,187,.3), 0 0 0 1px rgba(255,255,255,.06) inset;
}

.ap-brand__title {
  font-weight: 700;
  letter-spacing: -.01em;
}

.ap-brand__subtitle {
  font-size: .82rem;
  color: var(--muted);
  margin-top: -2px;
}

.ap-appbar__spacer {
  flex: 1;
}

.ap-appbar__actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--elev);
  color: inherit;
  border: 1px solid var(--divider);
  cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

  .icon-btn:hover {
    border-color: rgba(126,28,187,.34);
    background: rgba(255,255,255,.06);
    box-shadow: 0 12px 28px rgba(126,28,187,.28);
  }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary-purple, #7e1cbb), var(--primary-blue, #3B82F6));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-left: -6px;
  border: 2px solid var(--surface);
}

.ap-appbar__presence {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--divider);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--elev);
}

/* ===== User menu (alignment fixed) ===== */
.ap-user {
  position: relative;
}

.ap-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, rgba(126,28,187,.35), rgba(35,147,226,.35)) border-box;
  border: 1px solid var(--divider);
  border-radius: 14px;
  box-shadow: var(--shadow-lg-admin);
  padding: 8px;
  display: none;
  z-index: 1200;
}

  .ap-menu.open {
    display: block;
  }

.ap-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background .18s ease;
  text-align: left;
}

  .ap-menu__item:hover {
    background: rgba(126,28,187,.15);
  }

  .ap-menu__item.danger:hover {
    background: rgba(239,68,68,.18);
  }

  .ap-menu__item .material-symbols-rounded {
    flex: 0 0 24px;
    text-align: center;
    font-size: 22px;
    line-height: 1;
  }

.ap-menu__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ap-menu__title {
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

.ap-menu__caption {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.2;
  margin: 0;
}

.ap-menu hr {
  border: none;
  height: 1px;
  background: var(--divider);
  margin: 6px 8px;
}

/* ===== Sidebar ===== */
.ap-sidebar {
  position: fixed;
  top: var(--appbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--divider);
  z-index: 900;
  translate: 0 0;
  transition: translate .2s ease, width .2s ease;
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset;
}

.ap-sidebar__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.ap-sidebar__header {
  display: none;
}

.ap-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}

/* Links */
.ap-nav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  color: inherit;
  border: 1px solid transparent;
  transition: background .16s ease, border-color .16s ease, padding .16s ease, gap .16s ease;
  background: transparent;
  text-decoration: none;
}

  .ap-nav__link:hover {
    background: rgba(126,28,187,.14);
    border-color: rgba(126,28,187,.28);
  }

  .ap-nav__link.active {
    background: linear-gradient(180deg, rgba(126,28,187,.22), rgba(35,147,226,.18));
    border-color: var(--brand);
    box-shadow: 0 10px 30px rgba(35,147,226,.14);
  }

/* ===== Compact (icons-only) mode ===== */
.ap-root.nav-compact .ap-sidebar {
  width: var(--sidebar-w-compact);
}

.ap-root.nav-compact .ap-maincol {
  left: var(--sidebar-w-compact);
}

.ap-root.nav-compact .ap-nav__link {
  justify-content: center;
  gap: 0;
  padding: 12px 8px;
}

  .ap-root.nav-compact .ap-nav__link > .material-symbols-rounded {
    font-size: 24px;
  }

  .ap-root.nav-compact .ap-nav__link > span:last-child {
    display: none;
  }

/* Sidebar footer/status */
.ap-sidebar__footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: .9rem;
}

.ap-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

  .ap-dot.online {
    background: var(--ok);
  }

/* ===== Main (scroll column) ===== */
.ap-maincol {
  position: fixed;
  top: var(--appbar-h);
  right: 0;
  bottom: 0;
  left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  transition: left .2s ease;
}

.ap-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.ap-content {
  padding: 20px;
}

/* ===== Cards / utilities ===== */
.ap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.ap-card {
  grid-column: span 12;
  margin-top: 10px;
  background: var(--elev);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg-admin);
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease, border-color .25s ease;
}

  .ap-card:hover {
    background: rgba(255,255,255,.04);
    border-color: rgba(126,28,187,.34);
    box-shadow: 0 24px 70px rgba(126,28,187,.18);
  }

.ap-card__header {
  padding: 16px 18px 8px;
  border-bottom: 1px solid var(--divider);
}

.ap-card__body {
  padding: 18px;
}

.muted {
  color: var(--muted);
}

/* KPI grid for your first card */
.ap-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 12px 14px;
}

.kpi__label {
  color: var(--muted);
  font-size: .9rem;
}

.kpi__value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 4px;
}

/* Tables */
.ap-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}

  .ap-card table th, .ap-card table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--divider);
    color: var(--muted);
  }

  .ap-card table th {
    color: var(--text);
    font-weight: 700;
  }

  .ap-card table tr:hover td {
    background: rgba(255,255,255,.03);
    color: var(--text);
  }

/* Inputs */
.ap-form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  font-size: 1rem;
  background: rgba(255,255,255,.05);
  color: var(--text);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

  .ap-form-control::placeholder {
    color: rgba(176,184,212,.55);
  }

  .ap-form-control:focus {
    outline: none;
    border-color: var(--brand);
    background: rgba(255,255,255,.08);
    box-shadow: 0 0 0 3px rgba(59,130,246,.25);
  }

/* Chips */
.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--divider);
  background: var(--elev);
  color: var(--muted);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

  .ap-chip:hover {
    color: var(--text);
    border-color: rgba(126,28,187,.34);
  }

  .ap-chip.active {
    background: linear-gradient(180deg, rgba(126,28,187,.22), rgba(35,147,226,.18));
    color: var(--text);
    border-color: var(--brand);
  }

/* ===== Responsive ===== */
@media (max-width:1280px) {
  .ap-appbar__menu {
    display: grid;
  }

  .ap-sidebar {
    translate: -100% 0;
  }

    .ap-sidebar.open {
      translate: 0 0;
      box-shadow: 0 20px 60px rgba(0,0,0,.45);
    }

  .ap-maincol {
    left: 0;
  }
  /* drawer overlays on small screens */

  .ap-kpis {
    grid-template-columns: 1fr;
  }
  /* stack KPIs on smaller screens */
}

@media (max-width:900px) {
  .ap-content {
    padding: 16px;
  }

  .ap-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
