/* Admin Panel Design System — Kelas X-1 SMAN 11 Medan (TA 2026/2027) */

:root {
  --bg: #FAF9F5;
  --bg-alt: #F2F0E8;
  --surface: #FFFFFF;
  --surface-muted: #F6F5F0;
  --navy: #0B1F3A;
  --navy-hover: #14325B;
  --cobalt: #1D4ED8;
  --cobalt-soft: rgba(29, 78, 216, 0.1);
  --gold: #B45309;
  --gold-soft: rgba(180, 83, 9, 0.11);
  --emerald: #047857;
  --emerald-soft: rgba(4, 120, 87, 0.12);
  --danger: #B91C1C;
  --danger-soft: rgba(185, 28, 28, 0.1);

  --text: #111D2E;
  --text-muted: #425166;
  --text-subtle: #526277;
  --border: rgba(11, 31, 58, 0.11);
  --border-strong: rgba(11, 31, 58, 0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 2px 8px rgba(11, 31, 58, 0.05);
  --shadow-md: 0 12px 28px rgba(11, 31, 58, 0.1);
  --shadow-lg: 0 24px 52px rgba(11, 31, 58, 0.18);

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;

  --sidebar-width: 264px;
  --topbar-height: 68px;
  --transition: 180ms ease;
}

[data-theme="dark"] {
  --bg: #081220;
  --bg-alt: #0D1A2E;
  --surface: #11223A;
  --surface-muted: #162B47;
  --navy: #F59E0B;
  --navy-hover: #FBBF24;
  --cobalt: #60A5FA;
  --cobalt-soft: rgba(96, 165, 250, 0.16);
  --gold: #FBBF24;
  --gold-soft: rgba(251, 191, 36, 0.16);
  --emerald: #34D399;
  --emerald-soft: rgba(52, 211, 153, 0.16);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.16);

  --text: #F1F5F9;
  --text-muted: #B6C4D6;
  --text-subtle: #95A9C4;
  --border: rgba(241, 245, 249, 0.12);
  --border-strong: rgba(241, 245, 249, 0.22);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

button:not(:disabled),
a[href],
select,
label[for] {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

[data-theme="dark"] :focus-visible {
  outline-color: var(--gold);
}

.serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

.hidden {
  display: none !important;
}

/* Shared Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-primary {
  background: #0B1F3A;
  color: #FFFFFF;
}

.btn-primary:hover {
  background: #14325B;
}

[data-theme="dark"] .btn-primary {
  background: #F59E0B;
  color: #081220;
}

[data-theme="dark"] .btn-primary:hover {
  background: #FBBF24;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-muted);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-full {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
}

.badge-navy { background: var(--cobalt-soft); color: var(--cobalt); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-green { background: var(--emerald-soft); color: var(--emerald); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--surface-muted);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* =========================================
   LOGIN PAGE LAYOUT
   ========================================= */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
}

.auth-aside {
  background: #0B1F3A;
  color: #FFFFFF;
  padding: 48px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #F59E0B;
  color: #081220;
  font-weight: 800;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 0.98rem;
  font-weight: 700;
}

.brand-text small {
  font-size: 0.78rem;
  opacity: 0.78;
}

.auth-aside-body h1 {
  margin: 0 0 16px;
  font-size: clamp(2.1rem, 3.6vw, 3rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.auth-aside-body h1 .serif-italic {
  color: #FCD34D;
  font-size: 1.12em;
}

.auth-aside-body p {
  margin: 0 0 28px;
  color: #CBD5E1;
  max-width: 440px;
}

.db-spec-card {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
}

.db-spec-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.db-spec-row span {
  color: #94A3B8;
}

.db-spec-row strong {
  color: #F8FAFC;
  font-variant-numeric: tabular-nums;
}

.auth-aside-footer {
  font-size: 0.84rem;
  color: #94A3B8;
}

.auth-main {
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

.auth-topbar {
  position: absolute;
  top: 24px;
  left: 32px;
  right: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px;
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  font-weight: 800;
}

.auth-card-sub {
  margin: 0 0 24px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.alert-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.alert-info {
  background: var(--cobalt-soft);
  border-color: var(--cobalt);
  color: var(--cobalt);
}

.alert-success {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 72px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 6px;
}

.password-toggle:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.preview-divider {
  margin: 22px 0 16px;
  padding-top: 18px;
  border-top: 1px dashed var(--border-strong);
}

.preview-divider p {
  margin: 0 0 12px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* =========================================
   ADMIN DASHBOARD SHELL
   ========================================= */
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  background: #0B1F3A;
  color: #E2E8F0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
}

.sidebar-close {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-weight: 700;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94A3B8;
  padding: 10px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-item {
  width: 100%;
  text-align: left;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: #CBD5E1;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background-color var(--transition), color var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-item.active {
  background: #F59E0B;
  color: #081220;
  font-weight: 700;
}

.nav-count {
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-count {
  background: rgba(8, 18, 32, 0.18);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-profile-mini {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
}

.admin-profile-mini strong {
  display: block;
  font-size: 0.88rem;
  color: #FFFFFF;
}

.admin-profile-mini span {
  display: block;
  font-size: 0.76rem;
  color: #94A3B8;
}

.sidebar-logout {
  width: 100%;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #FCA5A5;
  font-size: 0.86rem;
  font-weight: 700;
}

.sidebar-logout:hover {
  background: rgba(248, 113, 113, 0.14);
}

.main-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar-height);
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
}

.topbar-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace {
  padding: 28px;
  max-width: 1220px;
  width: 100%;
}

.panel-view {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.stat-box span {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-subtle);
}

.stat-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-box small {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.card-header p {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.schedule-admin-split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: start;
}

.schedule-admin-split .data-table th,
.schedule-admin-split .data-table td {
  padding: 10px 10px;
  font-size: 0.85rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 280px;
}

.toolbar input[type="search"],
.toolbar select {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

.toolbar input[type="search"] {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 340px;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-subtle);
  background: var(--surface-muted);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-preview-img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  background: var(--surface-muted);
}

.table-student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-avatar-thumb {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Day Selector Pills */
.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.day-tab {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.day-tab.active {
  background: #0B1F3A;
  color: #FFFFFF;
  border-color: #0B1F3A;
}

[data-theme="dark"] .day-tab.active {
  background: #F59E0B;
  color: #081220;
  border-color: #F59E0B;
}

/* Admin Gallery Grid */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.gallery-admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.gallery-admin-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #0B1F3A;
}

.gallery-admin-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.gallery-admin-body h4 {
  margin: 0;
  font-size: 0.96rem;
}

.gallery-admin-body p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.gallery-admin-footer {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  gap: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 32, 0.72);
}

.modal-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* Toast Notification */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 300;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: #0B1F3A;
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.toast.toast-error {
  background: #991B1B;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 32, 0.6);
  z-index: 90;
}

/* Responsive */
@media (max-width: 1024px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    padding: 32px 24px;
  }

  .auth-main {
    padding: 76px 20px 36px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .sidebar-close,
  .mobile-menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 12px 16px;
  }

  .workspace {
    padding: 18px 16px;
  }

  .grid-2,
  .grid-3,
  .schedule-admin-split,
  .gallery-admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
