/* ============================================================
   SIGAP Admin — Shared Stylesheet v2
   Core: Bootstrap 5.3.3 + Plus Jakarta Sans
   ============================================================ */

/* ── 1. Design Tokens ─────────────────────────────────────── */
:root {
  --sp-primary:     #4f46e5;
  --sp-primary-d:   #3730a3;
  --sp-primary-l:   #818cf8;
  --sp-primary-xs:  rgba(79, 70, 229, 0.08);
  --sp-sidebar:     #0f0e1a;
  --sp-sidebar-2:   #1c1a35;
  --sp-bg:          #f1f3f7;
  --sp-surface:     #ffffff;
  --sp-border:      #e5e7eb;
  --sp-border-l:    #f3f4f6;
  --sp-text:        #111827;
  --sp-text-2:      #374151;
  --sp-muted:       #6b7280;
  --sp-muted-l:     #9ca3af;
  --sidebar-width:  256px;
  --header-height:  60px;
  --radius-card:    0.875rem;
  --radius-btn:     0.5rem;
  --radius-input:   0.6rem;

  /* Bootstrap overrides */
  --bs-primary:         #4f46e5;
  --bs-primary-rgb:     79, 70, 229;
  --bs-link-color:      #4f46e5;
  --bs-link-color-rgb:  79, 70, 229;
  --bs-border-radius:   var(--radius-btn);
}


/* ── 2. Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  background: var(--sp-bg);
  background-image: radial-gradient(circle, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--sp-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: var(--sp-primary); }


/* ── 3. Bootstrap Primary Override ───────────────────────── */
.btn-primary {
  background-color: var(--sp-primary) !important;
  border-color: var(--sp-primary) !important;
  border-radius: var(--radius-btn);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--sp-primary-d) !important;
  border-color: var(--sp-primary-d) !important;
}
.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25) !important;
}

.btn-outline-primary {
  color: var(--sp-primary) !important;
  border-color: var(--sp-primary) !important;
  border-radius: var(--radius-btn);
  font-weight: 600;
}
.btn-outline-primary:hover {
  background-color: var(--sp-primary) !important;
  color: #fff !important;
}

.text-primary { color: var(--sp-primary) !important; }
.bg-primary { background-color: var(--sp-primary) !important; }
.border-primary { border-color: var(--sp-primary) !important; }

.btn { border-radius: var(--radius-btn); font-weight: 500; }
.btn-sm { border-radius: calc(var(--radius-btn) - 0.1rem); }

.form-control, .form-select {
  border-radius: var(--radius-input);
  border-color: var(--sp-border);
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--sp-text-2);
  margin-bottom: 0.4rem;
}


/* ── 4. Admin Shell ───────────────────────────────────────── */
.admin-shell { min-height: 100vh; }


/* ── 5. Sidebar ───────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--sp-sidebar-2) 0%, var(--sp-sidebar) 100%);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-sidebar .text-muted {
  color: rgba(255, 255, 255, 0.45) !important;
}

/* Brand logo area */
.admin-brand {
  color: #fff;
  font-weight: 800;
}

/* Section labels */
.sidebar-section-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
  padding: 0 0.875rem;
  margin-top: 1.5rem;
  margin-bottom: 0.35rem;
}

/* Scrollable nav region */
.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.625rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Nav links */
.admin-sidebar .nav-pills {
  --bs-nav-pills-link-active-bg: var(--sp-primary);
}

.nav-pills .nav-link {
  color: rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 0.875rem;
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
}

.nav-pills .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

.nav-pills .nav-link.active {
  background: var(--sp-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
}

.nav-pills .nav-link svg,
.nav-pills .nav-link [data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-pills .nav-link.active [data-lucide],
.nav-pills .nav-link.active svg { opacity: 1; }

.sigap-logo { max-height: 52px; max-width: 100%; }

/* Mobile offcanvas: reset sidebar constraints */
.offcanvas-body .admin-sidebar {
  width: auto;
  height: auto;
  position: static;
  border-right: none;
  background: linear-gradient(160deg, var(--sp-sidebar-2) 0%, var(--sp-sidebar) 100%);
}


/* ── 6. Header / Navbar ───────────────────────────────────── */
.admin-header {
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-border);
  position: relative;
  z-index: 1050;
  min-height: var(--header-height);
  box-shadow: 0 1px 0 var(--sp-border-l);
}

.header-page-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sp-text);
  letter-spacing: -0.01em;
}

.admin-header .dropdown-menu {
  border-radius: 0.75rem;
  border: 1px solid var(--sp-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 0.5rem;
}

.admin-header .dropdown-item {
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
}


/* ── 7. Main Content Area ─────────────────────────────────── */
.admin-content {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

@media (min-width: 992px) {
  .admin-content { padding: 1.75rem 2rem; }
}

/* Legacy alias */
.admin-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.admin-card .card-body { padding: 1.75rem; }

.admin-card .form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--sp-text-2);
  margin-bottom: 0.4rem;
}

.admin-card .form-control,
.admin-card .form-select,
.admin-card .select2-selection--single {
  border-radius: var(--radius-input);
}

.admin-card form.row > [class*="col-"] { margin-bottom: 0.875rem; }
.admin-card .btn { border-radius: var(--radius-btn); }
.admin-card .btn.btn-sm { border-radius: calc(var(--radius-btn) - 0.1rem); }
.admin-card .table .btn { padding: 0.25rem 0.5rem; }
.admin-card .table .btn i { width: 14px; height: 14px; }
.admin-card .table td { vertical-align: middle; }


/* ── 8. Page Header ───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header__title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--sp-text);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.125rem;
}

.page-header__subtitle {
  font-size: 0.85rem;
  color: var(--sp-muted);
  margin: 0;
  font-weight: 400;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}


/* ── 9. Stat Cards (dashboard) ────────────────────────────── */
.stat-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Top accent stripe */
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.stat-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
}

/* Header row: label + icon */
.stat-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.stat-card__icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card__icon svg,
.stat-card__icon [data-lucide],
.stat-card__icon i {
  width: 20px;
  height: 20px;
  font-size: 1.1rem;
}

.stat-card__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sp-muted);
  padding-top: 0.125rem;
}

.stat-card__value {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--sp-text);
  margin-bottom: 0.4rem;
}

.stat-card__meta {
  font-size: 0.8rem;
  color: var(--sp-muted-l);
  font-weight: 500;
}

/* Module colors */
.stat-card--salary::before { background: #3b82f6; }
.stat-card--salary .stat-card__icon { background: #eff6ff; color: #2563eb; }

.stat-card--rank::before { background: #f59e0b; }
.stat-card--rank .stat-card__icon { background: #fffbeb; color: #d97706; }

.stat-card--pension::before { background: #8b5cf6; }
.stat-card--pension .stat-card__icon { background: #f5f3ff; color: #7c3aed; }


/* ── 10. Table Wrapper ────────────────────────────────────── */
.admin-table-wrapper {
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--sp-border);
  padding-bottom: 0.25rem;
}

/* Compact table styles */
.admin-table-wrapper .table {
  font-size: 0.875rem;
  margin-bottom: 0;
}

.admin-table-wrapper .table > thead > tr > th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sp-muted);
  background: #f9fafb;
  padding: 0.625rem 0.875rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--sp-border);
}

.admin-table-wrapper .table > tbody > tr > td {
  padding: 0.55rem 0.875rem;
  vertical-align: middle;
}

/* Stacked cell: name/NIP, old→new rank, etc. */
.cell-primary {
  font-weight: 600;
  color: var(--sp-text);
  line-height: 1.3;
}

.cell-secondary {
  font-size: 0.78rem;
  color: var(--sp-muted);
  line-height: 1.3;
}

.cell-arrow {
  font-size: 0.72rem;
  color: var(--sp-muted-l);
  margin: 0.1rem 0;
}

/* Icon-only square action buttons */
.tbl-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tbl-btn [data-lucide],
.tbl-btn svg {
  width: 13px;
  height: 13px;
}

.admin-table-wrapper .dataTables_wrapper .dataTables_filter input {
  border-radius: var(--radius-input);
  border-color: var(--sp-border);
}

.admin-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.admin-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--sp-primary) !important;
  border-color: var(--sp-primary) !important;
  color: #fff !important;
  border-radius: var(--radius-btn);
}

.admin-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button:not(.current):hover {
  background: var(--sp-primary-xs) !important;
  border-color: transparent !important;
  color: var(--sp-primary) !important;
  border-radius: var(--radius-btn);
}



/* ── 11. Action Group ─────────────────────────────────────── */
.action-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

.action-group .btn { white-space: nowrap; }


/* ── 12. Branded Primary Button ───────────────────────────── */
.btn-sigap-primary {
  background: var(--sp-primary);
  border: 0;
  color: #fff;
  border-radius: var(--radius-btn);
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-sigap-primary:hover,
.btn-sigap-primary:focus {
  background: var(--sp-primary-d);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}


/* ── 13. Flash Alert ──────────────────────────────────────── */
.alert {
  border-radius: 0.75rem;
  border: 0;
  font-size: 0.9rem;
  font-weight: 500;
}


/* ── 14. Login Page ───────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
}

/* Left brand panel */
.login-brand-panel {
  width: 440px;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--sp-sidebar-2) 0%, var(--sp-sidebar) 100%);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand-panel::before {
  content: '';
  position: absolute;
  width: 360px;
  height: 360px;
  background: var(--sp-primary);
  border-radius: 50%;
  opacity: 0.07;
  top: -130px;
  right: -100px;
  pointer-events: none;
}

.login-brand-panel::after {
  content: '';
  position: absolute;
  width: 240px;
  height: 240px;
  background: var(--sp-primary-l);
  border-radius: 50%;
  opacity: 0.06;
  bottom: 50px;
  left: -70px;
  pointer-events: none;
}

.login-brand-name {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 1.5rem;
}

.login-brand-tagline {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.25rem;
  letter-spacing: -0.01em;
}

.login-brand-desc {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.7;
  margin-top: 1rem;
  max-width: 340px;
}

.login-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: rgba(79, 70, 229, 0.25);
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: 100px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sp-primary-l);
  margin-top: 1.75rem;
}

.login-brand-footer {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.25);
  font-weight: 500;
}

/* Right form panel */
.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fc;
  background-image: radial-gradient(circle, rgba(0,0,0,0.025) 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 2rem;
}

.login-form-inner {
  width: 100%;
  max-width: 400px;
}

.login-form-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--sp-text);
  margin-bottom: 0.25rem;
  line-height: 1.1;
}

.login-form-subtitle {
  font-size: 0.875rem;
  color: var(--sp-muted);
  margin-bottom: 2rem;
  font-weight: 400;
}

.login-form-inner .form-label {
  font-weight: 700;
  font-size: 0.825rem;
  color: var(--sp-text-2);
  letter-spacing: -0.005em;
}

.login-form-inner .form-control {
  border-radius: 0.625rem;
  border-color: var(--sp-border);
  padding: 0.7rem 0.9rem;
  font-size: 0.925rem;
  background: var(--sp-surface);
  font-weight: 500;
}

.login-form-inner .form-control:focus {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.login-form-inner .btn-sigap-primary {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-radius: 0.625rem;
}

/* Mobile login fallback */
.login-card {
  max-width: 460px;
  border: 1px solid var(--sp-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
  background: var(--sp-surface);
  border-radius: 1.25rem;
}

.sigap-brand { color: var(--sp-primary); }
.logo-wrap img { max-height: 72px; }


/* ── 15. Form Layout ──────────────────────────────────────── */
.form-section {
  padding-bottom: 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--sp-border-l);
}

.form-section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-section__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sp-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.125rem;
}

.form-section__label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sp-border);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.5rem;
  border-top: 1px solid var(--sp-border-l);
  margin-top: 0.25rem;
}

/* Hint / help text */
.form-hint {
  font-size: 0.8rem;
  color: var(--sp-muted-l);
  margin-top: 0.3rem;
}

/* Attachment badge */
.edoc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  margin-top: 0.5rem;
}

.edoc-badge:hover { background: #dcfce7; color: #15803d; }

/* ── 16. Select2 Bootstrap Integration ───────────────────── */
.select2-container--default .select2-selection--single {
  height: calc(1.5em + 0.75rem + 2px);
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--radius-input);
  background-color: var(--sp-surface);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.5;
  color: var(--sp-text);
  font-size: 0.9rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: calc(1.5em + 0.75rem);
  top: 0;
  right: 0.5rem;
}

.select2-container { width: 100% !important; }

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: 0;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--sp-primary);
}


/* ── 16. Flatpickr ────────────────────────────────────────── */
.flatpickr-calendar { font-family: inherit; }
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--sp-primary);
  border-color: var(--sp-primary);
}
.flatpickr-day.today { border-color: var(--sp-primary); }
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  color: var(--sp-primary);
}


/* ── 17. Responsive ───────────────────────────────────────── */

/* Hide desktop sidebar on mobile — replaced by offcanvas */
@media (max-width: 991.98px) {
  .admin-sidebar { display: none; }
}

/* Style the mobile offcanvas to match sidebar theme */
#adminMenu {
  background: linear-gradient(160deg, var(--sp-sidebar-2) 0%, var(--sp-sidebar) 100%);
  width: 280px !important;
}

#adminMenu .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 1rem 1.25rem;
}

#adminMenu .offcanvas-title {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#adminMenu .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
  opacity: 0.5;
}

#adminMenu .btn-close:hover { opacity: 0.9; }

#adminMenu .offcanvas-body {
  padding: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 767px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header__actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .page-header__actions form {
    flex-wrap: wrap;
    width: 100%;
  }
  .page-header__actions .form-select,
  .page-header__actions .btn {
    width: 100% !important;
  }
  .admin-content {
    padding: 1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .admin-table-wrapper { overflow-x: auto; }
  .form-section { padding: 1rem; }
}

@media (max-width: 575px) {
  .page-header__title { font-size: 1.1rem; }
  .page-header__subtitle { font-size: 0.8rem; }
}
