/* ============================================================
   ADMIN CONSOLE (ac-*) — Persistent Sidebar Layout System
   ============================================================ */

/* ── Standalone Admin Page Reset ─────────────────────────── */
body.admin-console-body {
  margin: 0 !important;
  padding: 0 !important;
  background: #f1f5f9 !important;
  min-height: 100vh;
  display: flex !important;
  flex-direction: column !important;
  overflow-x: hidden;
}
body.admin-console-body .site-main {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
}

/* ── Layout root ─────────────────────────────────────────── */
.ac-layout {
  display: flex;
  flex: 1;
  min-height: 100vh;
  width: 100%;
  gap: 0;
  margin: 0;
  position: relative;
  background: #f1f5f9;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.ac-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900) 0%, #063247 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 4px 0 24px rgba(0,0,0,.15);
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  transition: transform .24s ease;
  z-index: 100;
}

.ac-sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.3rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: .5rem;
  flex-shrink: 0;
}
.ac-brand-icon { font-size: 1.6rem; line-height: 1; }
.ac-sidebar-brand strong { display: block; font-size: .95rem; font-weight: 800; line-height: 1.2; color: #fff; }
.ac-sidebar-brand small { font-size: .7rem; color: rgba(255,255,255,.6); line-height: 1; }

/* ── Sidebar Nav ─────────────────────────────────────────── */
.ac-nav {
  flex: 1;
  padding: .4rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.ac-nav-label {
  display: block;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: .5rem .5rem .15rem;
  margin-bottom: .1rem;
}
.ac-nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  color: rgba(255,255,255,.78);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: transparent;
  position: relative;
}
.ac-nav-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.ac-nav-item.active {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-weight: 750;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.ac-nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.ac-badge {
  margin-left: auto;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  padding: .12rem .45rem;
  border-radius: 99px;
}

/* ── Sidebar Footer ──────────────────────────────────────── */
.ac-sidebar-footer {
  flex-shrink: 0;
  padding: .75rem .65rem;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.ac-footer-link {
  display: block;
  padding: .45rem .75rem;
  border-radius: 8px;
  font-size: .82rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: color .15s, background .15s;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.ac-footer-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.ac-footer-logout { color: rgba(255,160,160,.8); }
.ac-footer-logout:hover { color: #fca5a5; background: rgba(255,100,100,.1); }

/* ── Main Workspace ──────────────────────────────────────── */
.ac-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────────── */
.ac-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.6rem;
  background: #fff;
  border-bottom: 1px solid rgba(7,89,133,.12);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(6,50,71,.05);
  border-radius: 0;
  min-height: 64px;
}
.ac-sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--navy-900);
  padding: .3rem;
  border-radius: 8px;
  flex-shrink: 0;
  display: none; /* shown on mobile via media query */
  transition: background .15s;
}
.ac-sidebar-toggle:hover { background: var(--blue-100); }
.ac-topbar-title h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 850;
  color: var(--navy-900);
  line-height: 1.2;
}
.ac-topbar-title small {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: .1rem;
}
.ac-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
}

/* ── Flash Messages ──────────────────────────────────────── */
.ac-flashes {
  padding: .8rem 1.4rem 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.ac-flash {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem 1rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.4;
}
.ac-flash button {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: .6;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.ac-flash button:hover { opacity: 1; }
.ac-flash-success { background: var(--green-100); color: var(--green-700); border: 1px solid rgba(5,150,105,.25); }
.ac-flash-error { background: #fee2e2; color: #dc2626; border: 1px solid rgba(220,38,38,.22); }
.ac-flash-info { background: var(--blue-100); color: var(--blue-700); border: 1px solid rgba(3,105,161,.2); }

/* ── Page Content ────────────────────────────────────────── */
.ac-content {
  flex: 1;
  padding: 1.4rem;
  min-width: 0;
}

/* ── Data Table ──────────────────────────────────────────── */
.ac-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid rgba(7,89,133,.1);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.ac-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.ac-table thead th {
  background: var(--surface-soft);
  color: var(--navy-900);
  font-weight: 800;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 2px solid rgba(7,89,133,.1);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.ac-table tbody tr {
  border-bottom: 1px solid rgba(7,89,133,.06);
  transition: background .12s;
}
.ac-table tbody tr:hover { background: rgba(224,242,254,.35); }
.ac-table tbody tr:last-child { border-bottom: none; }
.ac-table td {
  padding: .75rem 1rem;
  color: var(--text);
  vertical-align: middle;
}
.ac-table td.ac-td-actions {
  white-space: nowrap;
  text-align: right;
}
.ac-table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.ac-table-empty p { font-size: 2rem; margin: 0 0 .5rem; }

/* ── Section / Card ──────────────────────────────────────── */
.ac-card {
  background: #fff;
  border: 1px solid rgba(7,89,133,.1);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ac-card-header {
  padding: 1rem 1.3rem;
  border-bottom: 1px solid rgba(7,89,133,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  background: var(--surface-soft);
}
.ac-card-header h2, .ac-card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy-900);
}
.ac-card-body { padding: 1.3rem; }

/* ── Search Bar ──────────────────────────────────────────── */
.ac-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #fff;
  border: 1.5px solid rgba(7,89,133,.2);
  border-radius: 10px;
  padding: .45rem .85rem;
  transition: border-color .15s, box-shadow .15s;
}
.ac-search:focus-within {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.ac-search svg { color: var(--muted); flex-shrink: 0; }
.ac-search input {
  border: none;
  background: none;
  outline: none;
  font-size: .88rem;
  color: var(--text);
  width: 100%;
  min-width: 0;
}

/* ── Toolbar (above tables) ──────────────────────────────── */
.ac-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.ac-toolbar-left { flex: 1; min-width: 0; }
.ac-toolbar-right { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────── */
.ac-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 9px;
  font-size: .875rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
  background: none;
}
.ac-btn-primary {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5,150,105,.25);
}
.ac-btn-primary:hover { opacity: .9; color: #fff; text-decoration: none; box-shadow: 0 6px 18px rgba(5,150,105,.35); }
.ac-btn-secondary {
  background: #fff;
  color: var(--blue-800);
  border-color: rgba(7,89,133,.25);
}
.ac-btn-secondary:hover { background: var(--blue-100); color: var(--navy-900); text-decoration: none; }
.ac-btn-danger {
  background: #fff;
  color: #dc2626;
  border-color: rgba(220,38,38,.3);
}
.ac-btn-danger:hover { background: #fee2e2; text-decoration: none; }
.ac-btn-sm { padding: .3rem .7rem; font-size: .8rem; border-radius: 7px; }
.ac-btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: .3rem .5rem;
}
.ac-btn-ghost:hover { background: var(--blue-100); color: var(--navy-900); text-decoration: none; }

/* ── Form fields ─────────────────────────────────────────── */
.ac-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.ac-form-field { display: flex; flex-direction: column; gap: .35rem; }
.ac-form-field label {
  font-size: .78rem;
  font-weight: 750;
  color: var(--navy-900);
  display: block;
}
.ac-form-field input,
.ac-form-field select,
.ac-form-field textarea {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid rgba(7,89,133,.2);
  border-radius: 9px;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  box-sizing: border-box;
}
.ac-form-field input:focus,
.ac-form-field select:focus,
.ac-form-field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.ac-form-field small { font-size: .73rem; color: var(--muted); }
.ac-form-actions {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid rgba(7,89,133,.08);
  margin-top: .5rem;
}

/* ── Stats Row ───────────────────────────────────────────── */
.ac-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .85rem;
  margin-bottom: 1.5rem;
}
.ac-stat-card {
  background: #fff;
  border: 1px solid rgba(7,89,133,.1);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.ac-stat-card .num {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--navy-900);
  line-height: 1.1;
}
.ac-stat-card .lbl {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Chip / Badge ────────────────────────────────────────── */
.ac-chip {
  display: inline-block;
  padding: .22rem .65rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .03em;
}

/* ── Color swatch preview ────────────────────────────────── */
.ac-color-preview {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .2rem .65rem;
  border-radius: 7px;
  font-weight: 800;
  font-size: .82rem;
  min-width: 48px;
  justify-content: center;
}

/* ── Danger zone ─────────────────────────────────────────── */
.ac-danger-zone {
  border: 1.5px solid rgba(220,38,38,.3);
  border-radius: 14px;
  padding: 1.2rem;
  background: rgba(254,226,226,.3);
}
.ac-danger-zone h3 { color: #b91c1c; margin: 0 0 .5rem; font-size: .95rem; }
.ac-danger-zone p { font-size: .86rem; color: #7f1d1d; margin: 0 0 1rem; line-height: 1.5; }

/* ── Empty-state ─────────────────────────────────────────── */
.ac-empty {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
}
.ac-empty .ac-empty-icon { font-size: 2.8rem; display: block; margin-bottom: .6rem; }
.ac-empty h3 { color: var(--navy-900); margin: 0 0 .4rem; font-size: 1rem; }
.ac-empty p { font-size: .88rem; margin: 0 0 1.2rem; }

/* ── Backdrop for Mobile Sidebar ──────────────────────────── */
.ac-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 15, 28, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 450;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.ac-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive Architecture (Tablet & Small Desktop) ────── */
@media (max-width: 960px) {
  .ac-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    max-height: 100vh;
    width: 275px;
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    z-index: 500;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }
  .ac-sidebar.open { transform: translateX(0); }
  .ac-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
  }
  .ac-layout { min-height: auto; }
  .ac-topbar {
    top: 0;
    border-radius: 0;
    padding: 0.85rem 1.2rem;
    flex-wrap: wrap;
  }
  .ac-content { padding: 1.15rem 1.1rem; }
  .ac-table-wrap, .table-wrap {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* ── Responsive Architecture (Mobile Screens) ────────────── */
@media (max-width: 768px) {
  /* Topbar Adjustments */
  .ac-topbar {
    padding: 0.75rem 0.95rem;
    gap: 0.75rem;
  }
  .ac-topbar-title h1 { font-size: 1.1rem; }
  .ac-topbar-title small { font-size: 0.76rem; }
  .ac-topbar-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 0.5rem;
    overflow-x: auto;
    padding-top: 0.2rem;
    padding-bottom: 0.15rem;
  }

  /* Cards & Section Headers */
  .ac-card { border-radius: 14px; }
  .ac-card-header {
    padding: 0.95rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }
  .ac-card-header > div, .ac-card-header form {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .ac-card-body { padding: 1rem; }

  /* Form Fields & Inputs */
  .ac-form-row, .form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
  .ac-form-field input,
  .ac-form-field select,
  .ac-form-field textarea {
    padding: 0.65rem 0.85rem;
    font-size: 0.92rem;
  }
  .ac-form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .ac-form-actions .ac-btn, .ac-form-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  /* Toolbar & Search Bar */
  .ac-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .ac-toolbar-left, .ac-toolbar-right {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }
  .ac-toolbar-right {
    justify-content: flex-start;
    gap: 0.5rem;
  }
  .ac-search {
    width: 100%;
    box-sizing: border-box;
  }

  /* Data Tables */
  .ac-table-wrap { margin-bottom: 1rem; }
  .ac-table th, .ac-table td {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.82rem !important;
  }
  .ac-table td.ac-td-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0.35rem !important;
  }
  .ac-table td.ac-td-actions .ac-btn,
  .ac-table td.ac-td-actions .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
  }

  /* Stats Grid */
  .ac-stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem;
  }
  .ac-stat-card { padding: 0.85rem; }
  .ac-stat-card .num { font-size: 1.5rem; }
  .ac-stat-card .lbl { font-size: 0.68rem; }

  /* Flash Notifications */
  .ac-flashes { padding: 0.6rem 0.95rem 0; }
  .ac-flash { font-size: 0.85rem; padding: 0.65rem 0.85rem; }

  /* Modals */
  .modal-box, .ac-modal-box {
    width: 94% !important;
    max-width: 94% !important;
    margin: 1.25rem auto !important;
    padding: 1.25rem !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    box-sizing: border-box;
  }
}

/* ── Responsive Architecture (Small Phones & Compact Screens) ── */
@media (max-width: 480px) {
  .ac-stats-row { grid-template-columns: 1fr !important; }
  .ac-topbar-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .ac-topbar-actions .ac-btn, .ac-topbar-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 40px;
  }
  .ac-btn {
    font-size: 0.84rem;
    padding: 0.5rem 0.9rem;
  }
  .ac-sidebar { width: 86vw; }
  .ac-nav-item {
    padding: 0.55rem 0.65rem;
    font-size: 0.85rem;
  }
  .ac-table th, .ac-table td {
    padding: 0.5rem 0.55rem !important;
    font-size: 0.78rem !important;
  }
}
