/* ==========================================================================
   Panel Pentadbir — Portal Sektor Pembelajaran PPD Daro (2026)
   ========================================================================== */

:root {
  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --navy-950: #071529;
  --navy-900: #0b1f3a;
  --navy-800: #13315c;
  --gold: #c89b3c;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --brand: #13315c;
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --emerald: #047857;
  --emerald-bg: #ecfdf5;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  --sidebar-w: 264px;
}

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

html, body {
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.02em;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; flex-shrink: 0; }
.icon-lg { width: 22px; height: 22px; flex-shrink: 0; }

/* Shell */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--navy-950);
  color: rgba(255, 255, 255, 0.86);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.35rem 0.4rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 1rem;
}

.sidebar-logo-pill {
  background: rgba(255, 255, 255, 0.96);
  padding: 6px 12px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sidebar-logo-pill img { height: 42px; width: auto; display: block; object-fit: contain; }
.sidebar-brand-title { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; color: #fff; display: block; }
.sidebar-brand-sub { font-size: 0.74rem; color: #c4b5fd; display: block; }

.sidebar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(148, 163, 184, 0.75);
  padding: 0.5rem 0.75rem 0.35rem;
  font-weight: 700;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border-radius: 11px;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(226, 232, 240, 0.82);
  transition: background 160ms ease, color 160ms ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(200, 155, 60, 0.24), rgba(37, 99, 235, 0.25));
  color: #fff;
  font-weight: 600;
  border: 1px solid rgba(200, 155, 60, 0.35);
}

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

.admin-user-box {
  padding: 0.65rem 0.75rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
}
.admin-user-box strong { display: block; color: #fff; font-size: 0.86rem; }
.admin-user-box span { color: rgba(203, 213, 225, 0.78); }

/* Main Column */
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title { font-size: 1.15rem; font-weight: 800; color: var(--navy-900); }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.admin-content {
  padding: 1.6rem 1.75rem 2.5rem;
  max-width: 1320px;
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

/* Cards & Grids */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 1.02rem; font-weight: 700; color: var(--navy-900); }
.card-body { padding: 1.35rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; color: var(--navy-900); line-height: 1.15; }
.kpi-sub { font-size: 0.78rem; color: var(--text-secondary); }

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

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.56rem 1.05rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 160ms ease;
  white-space: nowrap;
}

.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--blue); }

.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: #f8fafc; border-color: var(--navy-900); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }

.btn-danger-soft { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn-danger-soft:hover { background: #fee2e2; }

.btn-sm { padding: 0.38rem 0.75rem; font-size: 0.8rem; border-radius: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-navy    { background: #e2e8f0; color: var(--navy-900); }
.badge-blue    { background: var(--blue-bg); color: var(--blue); }
.badge-emerald { background: var(--emerald-bg); color: var(--emerald); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-slate   { background: #f1f5f9; color: var(--text-secondary); }

/* Alerts */
.alert {
  padding: 0.9rem 1.15rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.alert-success { background: var(--emerald-bg); color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--amber-bg); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--blue-bg); color: #1e40af; border-color: #bfdbfe; }

/* Forms */
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.field-hint {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.72rem 0.95rem;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.92rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: #fff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: #1d4ed8; }

/* Pemilih 2 Kaedah Sumber (URL Pautan / Drive vs Muat Naik Fail) — Gaya Bersih 2026 */
.method-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.method-card {
  position: relative;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.method-card:hover {
  border-color: #93c5fd;
  background: #fafcff;
}

.method-card input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  flex-shrink: 0;
  cursor: pointer;
}

.method-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.method-card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
}

.method-card-desc {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
}

.method-card:has(input:checked),
.method-card.is-active {
  border-color: #2563eb;
  background: #f0f6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  padding: 2.2rem 1.5rem;
  text-align: center;
  background: #fbfdff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.dropzone-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #e0edff;
  color: #1d4ed8;
  display: inline-grid;
  place-items: center;
  margin-bottom: 0.35rem;
}

.dropzone-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.dropzone input[type="file"] { display: none; }
.dropzone-name { margin-top: 0.35rem; font-size: 0.85rem; font-weight: 600; color: #1d4ed8; }

.form-footer-bar {
  margin-top: 0.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-storage-note {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}

.form-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-royal {
  background: #1d4ed8;
  color: #ffffff;
  border-radius: 12px;
  padding: 0.68rem 1.35rem;
  font-weight: 600;
}
.btn-royal:hover {
  background: #1e40af;
}

.optional-details {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fafcff;
  padding: 0.8rem 1rem;
}
.optional-details summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: #334155;
  user-select: none;
}
.optional-details[open] summary {
  margin-bottom: 0.9rem;
}

/* Header Kad Borang Dokumen & Banner Auto-Sync */
.doc-page-header {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.15rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.doc-page-header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.back-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 150ms ease, border-color 150ms ease;
}
.back-circle-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.btn-soft-slate {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.6rem 1rem;
}
.btn-soft-slate:hover {
  background: #e2e8f0;
}

.btn-drive-amber {
  background: #f59e0b;
  color: #1e1b08;
  border: 1px solid #d97706;
  border-radius: 12px;
  padding: 0.6rem 1.05rem;
  font-weight: 700;
}
.btn-drive-amber:hover {
  background: #d97706;
  color: #ffffff;
}

.sync-banner {
  border-radius: 14px;
  padding: 0.95rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
}

.sync-banner-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.sync-banner-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.sync-banner-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 240px;
}

.sync-pill {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.sync-pill-ok { background: #d1fae5; color: #047857; }
.sync-pill-warn { background: #fef3c7; color: #b45309; }

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

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

table.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data-table tr:last-child td { border-bottom: 0; }
table.data-table tr:hover td { background: #fafcff; }

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Unit Manager Accordion / Blocks */
.unit-manage-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 1rem;
}

.unit-manage-head {
  padding: 1rem 1.2rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.unit-manage-body {
  padding: 1.1rem 1.2rem;
}

.unit-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.55rem;
  background: #fcfdff;
  flex-wrap: wrap;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 15%, rgba(200, 155, 60, 0.2), transparent 40%),
    linear-gradient(135deg, #071529 0%, #0f294d 60%, #163a6e 100%);
}

.login-card {
  width: min(100%, 440px);
  background: #fff;
  border-radius: 22px;
  padding: 2.1rem;
  box-shadow: 0 24px 60px rgba(3, 10, 24, 0.42);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-brand img { height: 64px; width: auto; display: block; object-fit: contain; }

/* Dialog pengesahan padam */
dialog.confirm-dialog {
  width: min(100% - 2rem, 460px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.28);
}
dialog.confirm-dialog::backdrop {
  background: rgba(7, 21, 41, 0.52);
  backdrop-filter: blur(3px);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 21, 41, 0.52);
  backdrop-filter: blur(2px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-sidebar-btn {
  display: none;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  place-items: center;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .split-layout, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-main { min-width: 0; max-width: 100%; }
  .admin-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    height: 100dvh;
    width: min(82vw, var(--sidebar-w));
    z-index: 60;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    transition: left 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .admin-sidebar.is-open { left: 0; }
  .mobile-sidebar-btn { display: inline-grid; }
  .admin-topbar { padding: 0.75rem 1rem; gap: 0.5rem; }
  .admin-content { padding: 1.15rem 1rem calc(2rem + env(safe-area-inset-bottom)); min-width: 0; }
  .form-row-2, .method-picker { grid-template-columns: minmax(0, 1fr); }
  .sync-banner-left { min-width: 0; }
  .input, .select, .textarea { font-size: 1rem; min-height: 44px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .doc-page-header, .sync-banner, .card-body { padding: 1.05rem; }
  .form-footer-bar { flex-direction: column; align-items: stretch; }
  .form-footer-actions { justify-content: flex-end; flex-wrap: wrap; }
  .login-page { min-height: 100dvh; padding: 1rem; }
  .login-card { padding: 1.65rem 1.35rem; }
}
