/* ==========================================================================
   ADMIN STYLESHEET - PAROKI ST. ARNOLDUS JANSSEN TAMBOLAKA
   Palet: Navy (#12375F), Gold (#C69A3B), Ivory (#F8F7F2)
   ========================================================================== */

:root {
  --navy: #12375F;
  --navy-dark: #0A223E;
  --navy-light: #1C4D7F;
  --gold: #C69A3B;
  --gold-light: #FFF8E6;
  --ivory: #F8F7F2;
  --text: #1E293B;
  --text-muted: #64748B;
  --line: #E2E8F0;
  --card-bg: #FFFFFF;
  --red: #B42318;
  --green: #0E7A4A;
  --warn: #B26A00;
  
  --font-serif: 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 14px;
}

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

body {
  margin: 0;
  background-color: var(--ivory);
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--navy);
  text-decoration: none;
  transition: all 0.2s ease;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #FFFFFF;
  padding: 20px 14px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
  border-right: 3px solid var(--gold);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
  position: relative;
}

.side-brand-info {
  flex: 1;
  min-width: 0;
}

.side-close-btn {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.side-close-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #FCA5A5;
  color: #FCA5A5;
}

.side-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 2px;
}

.side-brand-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  display: block;
  letter-spacing: 0.5px;
}

.side-brand-sub {
  font-size: 11px;
  color: var(--gold);
  display: block;
}

.side-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #94A3B8;
  margin: 18px 10px 6px;
  text-transform: uppercase;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #CBD5E1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin: 2px 0;
  font-weight: 600;
  font-size: 13.5px;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #FFFFFF;
  transform: translateX(2px);
}

.sidebar a.active {
  background: rgba(198, 154, 59, 0.25) !important;
  color: #FFFFFF !important;
  border-left: 3px solid var(--gold);
  font-weight: 700;
}

.side-bottom-links {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-link-website {
  color: #E2E8F0 !important;
}
.side-link-logout {
  color: #FCA5A5 !important;
}
.side-link-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
}

/* Main Area */
.admin-main {
  margin-left: 260px;
  width: calc(100% - 260px);
  padding: 30px 36px;
  max-width: 1600px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  background: #FFFFFF;
  padding: 16px 22px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-titles {
  min-width: 0;
}

.admin-nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  background: var(--navy);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 9px 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  flex-shrink: 0;
  transition: background-color 0.2s, transform 0.2s;
}

.admin-nav-toggle:hover {
  background: var(--navy-dark);
}

.admin-nav-toggle .bar {
  display: block;
  width: 22px;
  height: 2.5px;
  background-color: #FFFFFF;
  border-radius: 2px;
  transition: all 0.25s ease;
}

.admin-nav-toggle.active .bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.admin-nav-toggle.active .bar:nth-child(2) {
  opacity: 0;
}
.admin-nav-toggle.active .bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.topbar h1 {
  font-family: var(--font-serif);
  font-size: 24px;
  margin: 0;
  color: var(--navy);
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.user-chip {
  background: var(--ivory);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.user-avatar-dot {
  color: var(--green);
  font-size: 10px;
}

/* Cards & Panel */
.panel {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* Buttons */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  background: var(--navy);
  color: #FFFFFF;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover, button:hover {
  background: var(--navy-dark);
}

.btn-gold {
  background: var(--gold) !important;
  color: #FFFFFF !important;
}
.btn-gold:hover {
  background: #AF852C !important;
}

.btn-danger {
  background: var(--red) !important;
  color: #FFFFFF !important;
}

.btn-light {
  background: var(--ivory) !important;
  color: var(--navy) !important;
  border: 1px solid var(--line);
}

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

/* Tabel */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

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

.table th {
  font-size: 12px;
  font-weight: 800;
  color: var(--navy);
  background: #F8FAFC;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background-color: #FAFBFD;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  background: #EEF2F6;
}
.badge.success {
  background: #E6F6ED;
  color: var(--green);
}
.badge.warn {
  background: #FFF4E5;
  color: var(--warn);
}
.badge.danger {
  background: #FEECEB;
  color: var(--red);
}

/* Formulir */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

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

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
}

input, select, textarea {
  width: 100%;
  border: 1px solid #CBD5E1;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  background: #FFFFFF;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(198, 154, 59, 0.15);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.help {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #FEECEB;
  color: var(--red);
  margin-bottom: 20px;
  font-weight: 600;
  border: 1px solid #FCA5A5;
}
.alert.success {
  background: #E6F6ED;
  color: var(--green);
  border-color: #86EFAC;
}

/* Statistik Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  border-top: 3px solid var(--gold);
}

.stat small {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
}

.stat strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--navy);
  margin-top: 6px;
}

.thumb {
  width: 80px;
  height: 55px;
  object-fit: cover;
  border-radius: 6px;
  background: #EEE;
}

/* Login Card */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ivory) 0%, #EFE9DB 100%);
  padding: 20px;
}

.login-card {
  width: min(440px, 94%);
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 36px 32px;
  box-shadow: 0 15px 40px rgba(18, 55, 95, 0.08);
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--gold);
  display: grid;
  place-items: center;
  padding: 6px;
}

.login-card h1 {
  text-align: center;
  font-family: var(--font-serif);
  color: var(--navy);
  font-size: 26px;
  margin-bottom: 4px;
}

.login-card > p {
  text-align: center;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 24px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-card button {
  margin-top: 10px;
  width: 100%;
  padding: 12px;
  background: var(--navy);
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}
.back-link:hover {
  color: var(--navy);
}

/* Dashboard Quick Links */
.dashboard-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.dashboard-links a {
  background: #FFFFFF;
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.dashboard-links a:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.dashboard-links strong {
  display: block;
  color: var(--navy);
  margin-bottom: 4px;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   ADMIN STATISTIK EDITOR
   -------------------------------------------------------------------------- */
.stats-control-panel .toolbar {
  align-items: flex-end;
}

.year-form, .add-year-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.year-form select {
  min-width: 180px;
}

.add-year-form input {
  min-width: 140px;
}

.stat-info {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 11px 14px;
  background: #F8FAFC;
  border-radius: 8px;
  color: #475467;
  font-size: 13px;
}

.statistics-editor {
  padding: 20px;
}

.stats-table-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 15px;
  margin-bottom: 16px;
}

.stats-table-title h2 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 21px;
}

.stats-table-title p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.stats-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FFFFFF;
}

.stats-edit-table {
  min-width: 1420px;
}

.stats-edit-table th, .stats-edit-table td {
  text-align: center;
  vertical-align: middle;
  padding: 7px 6px;
}

.stats-edit-table .group-row th {
  background: var(--navy);
  color: #FFFFFF;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-edit-table .subhead th {
  background: #EEF4FA;
  color: var(--navy);
  font-size: 11px;
  white-space: nowrap;
}

.stats-edit-table .region-cell {
  text-align: left;
  min-width: 210px;
  position: sticky;
  left: 0;
  background: #FFFFFF;
  z-index: 2;
  padding-left: 12px;
}

.stats-edit-table .region-cell strong {
  font-size: 12.5px;
  color: var(--navy);
}

.stats-edit-table .stat-input {
  width: 68px;
  padding: 7px 5px;
  text-align: center;
  border-radius: 6px;
  font-size: 12.5px;
}

.stats-edit-table .stat-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(198, 154, 59, 0.2);
  outline: none;
}

.stats-edit-table .total-row td {
  background: #FFF5DC !important;
  color: var(--navy);
  font-size: 12.5px;
  border-top: 2px solid var(--gold);
}

.stats-edit-table .total-row td.region-cell {
  position: sticky;
  left: 0;
  background: #FFF5DC !important;
  z-index: 2;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1.55fr 0.7fr;
  gap: 12px;
  margin-top: 18px;
}

.summary-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #F8FAFC;
}

.summary-box h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 13.5px;
}

.summary-box > div {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-box span {
  font-size: 12px;
  color: var(--text-muted);
}

.summary-box b {
  display: block;
  color: var(--navy);
  font-size: 16px;
  margin-top: 2px;
}

.summary-box.meninggal {
  background: #FFF4F3;
  border-color: #FECACA;
}
.summary-box.meninggal > strong {
  display: block;
  font-size: 26px;
  color: var(--red);
}

.auto-note {
  margin: 14px 0;
  padding: 10px 14px;
  background: #EEF8F2;
  color: var(--green);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.statistics-editor .form-actions {
  justify-content: flex-end;
}

.statistics-editor textarea {
  min-height: 90px;
}

/* Modal / Popup Standar */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 34, 62, 0.65);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  width: min(95vw, 600px);
  max-height: 90vh;
  overflow-y: auto;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  border-top: 4px solid var(--gold);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: 24px;
}

/* ==========================================================================
   RESPONSIVE ADMIN BREAKPOINTS
   1200px, 1024px (Tablet/Mobile Off-Canvas), 768px, 576px, 480px, 360px
   ========================================================================== */

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .dashboard-links {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Tablet Portrait & Mobile: Sidebar Bertransformasi Menjadi Off-Canvas Drawer */
@media (max-width: 1023px) {
  body.sidebar-active {
    overflow: hidden;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 34, 62, 0.60);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.4);
  }

  .side-close-btn {
    display: inline-flex;
  }

  .admin-nav-toggle {
    display: inline-flex;
  }

  .admin-main {
    margin-left: 0;
    width: 100%;
    padding: 20px 22px;
    max-width: 100%;
  }

  .topbar {
    padding: 14px 18px;
    gap: 14px;
  }

  .topbar h1 {
    font-size: 22px;
  }
}

@media (max-width: 768px) {
  .admin-main {
    padding: 16px 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-left {
    width: 100%;
  }

  .user-chip {
    align-self: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stats-summary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-links {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px 16px;
    margin-bottom: 16px;
  }

  .table th, .table td {
    padding: 10px 12px;
  }

  .stats-table-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

@media (max-width: 576px) {
  .year-form, .add-year-form {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .year-form select, .add-year-form input {
    width: 100%;
    min-width: 0;
  }

  .year-form div, .add-year-form div {
    width: 100%;
  }

  .stat-info {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .admin-main {
    padding: 12px 10px;
  }

  .topbar {
    padding: 12px 12px;
    border-radius: var(--radius-sm);
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar p {
    font-size: 12px;
  }

  .user-chip {
    font-size: 12px;
    padding: 6px 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat {
    padding: 14px;
  }

  .stat strong {
    font-size: 24px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .btn, .toolbar button {
    width: 100%;
    justify-content: center;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn, .form-actions button {
    width: 100%;
    justify-content: center;
  }

  .login-card {
    padding: 24px 18px;
  }

  .login-card h1 {
    font-size: 22px;
  }
}

@media (max-width: 360px) {
  .topbar h1 {
    font-size: 17px;
  }

  .admin-nav-toggle {
    width: 38px;
    height: 38px;
    padding: 8px 7px;
  }

  .admin-nav-toggle .bar {
    width: 20px;
    height: 2px;
  }
}

/* ==========================================================================
   PRINT STYLES - ADMIN PANEL
   ========================================================================== */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .sidebar,
  .sidebar-backdrop,
  .admin-nav-toggle,
  .side-close-btn,
  .side-bottom-links,
  .user-chip,
  .toolbar a.btn,
  .toolbar button,
  .form-actions,
  .actions,
  .alert,
  .year-form,
  .add-year-form,
  .auto-note {
    display: none !important;
  }

  .admin-layout {
    display: block !important;
  }

  .admin-main {
    margin: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .topbar {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 0 12pt 0 !important;
    margin-bottom: 14pt !important;
    border-bottom: 2pt solid #000000 !important;
  }

  .topbar h1 {
    color: #000000 !important;
    font-size: 18pt !important;
  }

  .panel {
    border: 1pt solid #CCCCCC !important;
    box-shadow: none !important;
    padding: 10pt !important;
    page-break-inside: avoid;
  }

  .table-wrap, .stats-table-wrap {
    overflow: visible !important;
    border: 0 !important;
  }

  .table, .stats-edit-table {
    min-width: 0 !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .table th, .table td,
  .stats-edit-table th, .stats-edit-table td {
    border: 1pt solid #333333 !important;
    padding: 5pt 6pt !important;
    color: #000000 !important;
    font-size: 9pt !important;
    background: #FFFFFF !important;
  }

  .stats-edit-table .stat-input {
    border: 0 !important;
    width: auto !important;
    padding: 0 !important;
    font-weight: 700 !important;
  }
}
