/* RSBSA SOCCSKSARGEN PAFFP — Theme
   DA-RFO XII · SOCCSKSARGEN (Region XII)
   Palette: DA institutional GREEN + GOLD, but a distinct treatment from the
   Davao build — a brighter emerald primary + rich antique-gold accent, with a
   signature gold top-stripe and gradient stat icons.
*/

:root {
  --paffp-primary:        #15663d;       /* emerald forest green */
  --paffp-primary-dark:   #0c4429;
  --paffp-primary-light:  #1f8a54;
  --paffp-accent:         #c8901a;       /* rich antique gold */
  --paffp-accent-dark:    #9c7016;
  --paffp-accent-light:   #f2c14e;
  --paffp-sidebar-bg:     #103d28;
  --paffp-sidebar-fg:     #e9f6ee;
  --paffp-content-bg:     #f4f8f5;
  --paffp-card-bg:        #ffffff;
  --paffp-border:         #dbe6df;
  --paffp-text:           #1d2a23;
  --paffp-muted:          #677a6e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
       background: var(--paffp-content-bg); color: var(--paffp-text); }

a { color: var(--paffp-primary); text-decoration: none; }
a:hover { color: var(--paffp-primary-dark); text-decoration: underline; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 260px;
  background: linear-gradient(180deg, var(--paffp-sidebar-bg) 0%, #082818 100%);
  color: var(--paffp-sidebar-fg);
  display: flex; flex-direction: column; z-index: 999;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}
.sidebar-brand {
  display: flex; align-items: center; gap: .5rem;
  padding: 1rem .6rem 1rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
}
.sidebar-brand:hover { text-decoration: none; color: #fff; }
.sidebar-brand img { width: 38px; height: 38px; flex-shrink: 0; }
.sidebar-brand-logos { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.sidebar-brand-logos img { width: 32px; height: 32px; object-fit: contain; }
.sidebar-brand-text {
  display: flex; flex-direction: column;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}
.sidebar-brand-text strong {
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  text-transform: uppercase;
}
.sidebar-brand-text .brand-rfo {
  font-size: .68rem;
  opacity: .85;
  margin-top: 2px;
  white-space: nowrap;
}
.sidebar-brand-text .brand-dts {
  font-weight: 700;
  color: #fff;
  font-size: .72rem;
  letter-spacing: .5px;
  margin-top: .25rem;
  white-space: nowrap;
}

#sidebar .nav-section { padding:.6rem .9rem .25rem; font-size:.65rem; letter-spacing:1px;
                        text-transform: uppercase; color: rgba(255,255,255,.5); }
#sidebar .nav-link { color: var(--paffp-sidebar-fg); padding:.55rem .9rem; font-size:.92rem;
                     border-left: 3px solid transparent; display:flex; align-items:center; gap:.6rem; }
#sidebar .nav-link:hover { background: rgba(255,255,255,.07); color:#fff; }
#sidebar .nav-link.active { background: rgba(255,255,255,.12); border-left-color: var(--paffp-accent-light); color:#fff; }
#sidebar .nav-link i { width: 18px; text-align:center; }
.sidebar-footer { padding: 1rem .9rem; border-top: 1px solid rgba(255,255,255,.1); margin-top:auto; }

/* ── Main area ───────────────────────────────────────────────────────── */
#main { margin-left: 260px; min-height: 100vh; display:flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--paffp-border);
          border-top: 3px solid var(--paffp-accent);   /* signature gold stripe */
          padding: .7rem 1.25rem; display:flex; align-items:center; gap:1rem;
          box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.topbar-user { margin-left:auto; display:flex; align-items:center; gap:.7rem; }
.topbar-user .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar-initial { display:flex; align-items:center; justify-content:center;
                  background: var(--paffp-primary); color:#fff; font-weight: 600; }
.user-name { font-weight:600; font-size:.9rem; }
.user-role { font-size:.75rem; color: var(--paffp-muted); }

.content { flex:1; padding: 1.4rem 1.5rem; }
.footer { background: #fff; border-top: 1px solid var(--paffp-border); text-align: center;
          padding: .6rem; color: var(--paffp-muted); }

/* ── Cards & components ─────────────────────────────────────────────── */
.card { border:1px solid var(--paffp-border); border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.card-header { background: #f3f8f4; border-bottom: 1px solid var(--paffp-border); font-weight: 600; }
.btn-primary { background: var(--paffp-primary); border-color: var(--paffp-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--paffp-primary-dark); border-color: var(--paffp-primary-dark); }
.btn-accent { background: var(--paffp-accent); color: #fff; border-color: var(--paffp-accent); }
.btn-accent:hover { background: var(--paffp-accent-dark); color:#fff; }
.text-primary { color: var(--paffp-primary) !important; }
.bg-primary  { background-color: var(--paffp-primary) !important; }

.stat-card { background: #fff; border: 1px solid var(--paffp-border); border-radius: 10px; padding: 1rem 1.2rem;
             display:flex; align-items:center; gap: 1rem; min-height: 72px; }
.stat-body { min-width: 0; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display:flex; align-items:center; justify-content:center;
             background: linear-gradient(135deg, var(--paffp-primary-light) 0%, var(--paffp-primary-dark) 100%);
             color: #fff; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.warning { background: var(--paffp-accent); }
.stat-icon.info    { background: #0d6efd; }
.stat-icon.success { background: #198754; }
.stat-icon.muted   { background: #6c757d; }
.stat-label { font-size:.78rem; color: var(--paffp-muted); text-transform: uppercase; letter-spacing:.5px; white-space: nowrap; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }

.table thead th { background: #eef5f0; color: var(--paffp-primary-dark); font-weight:600; border-bottom:2px solid var(--paffp-border); }
.table > :not(caption) > * > * { padding: .55rem .65rem; vertical-align: middle; }

.badge.bg-secondary { background-color: #6b7a72 !important; }

/* ── Auth ───────────────────────────────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, #15663d 0%, #082818 100%); min-height: 100vh;
             display:flex; align-items:center; justify-content:center; padding: 1rem; }
.auth-container { width: 100%; max-width: 460px; }
.auth-card { background: #fff; border-radius: 14px; padding: 2rem 1.8rem; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-header { display:flex; gap: .8rem; align-items:center; margin-bottom: 1.4rem; }
.auth-header img { width: 60px; height: 60px; }
.auth-header h1 { font-size: 1.25rem; margin:0; color: var(--paffp-primary-dark); }
.auth-header p { margin: 0; font-size: .82rem; color: var(--paffp-muted); }
.auth-footer { text-align: center; margin-top: 1.2rem; color: var(--paffp-muted); }

/* ── Public verification ────────────────────────────────────────────── */
.public-body { background: #eff6f1; min-height: 100vh; padding: 2rem 1rem; }
.public-container { max-width: 640px; margin: 0 auto; }
.public-header { display:flex; gap:.8rem; align-items:center; padding: 1rem; background: #fff;
                 border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); margin-bottom: 1rem; }
.public-header img { width: 48px; height: 48px; object-fit: contain; }
.public-header-logos { display: flex; gap: .5rem; }
.public-header h2 { margin:0; font-size: 1.2rem; color: var(--paffp-primary-dark); }
.public-footer { text-align:center; margin-top: 1.5rem; color: var(--paffp-muted); }

/* ── Help ───────────────────────────────────────────────────────────── */
.help-chapter { background:#fff; padding: 1.5rem; border-radius: 10px; border:1px solid var(--paffp-border); }
.help-chapter h2 { color: var(--paffp-primary-dark); margin-bottom: .4rem; }
.help-chapter h3 { color: var(--paffp-primary); margin-top: 1.5rem; font-size: 1.1rem; }
.help-chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.help-chapter-tile { display: block; padding: 1rem; background: #fff; border:1px solid var(--paffp-border); border-radius: 10px; color: inherit; }
.help-chapter-tile:hover { background: #eff6f1; text-decoration: none; color: var(--paffp-primary-dark); border-color: var(--paffp-primary-light); }
.help-chapter-tile .chap-no { color: var(--paffp-accent); font-size: .75rem; font-weight: 700; letter-spacing: 1px; }
.help-chapter-tile h4 { font-size: 1rem; margin: .2rem 0; color: var(--paffp-primary-dark); }
.help-chapter-tile p { font-size:.85rem; color: var(--paffp-muted); margin: 0; }

/* ── Sidebar backdrop ────────────────────────────────────────────── */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 30, 18, 0.55);
  z-index: 998;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

#sidebarToggle { border: none; }

/* ── Mobile (≤768px) ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: 280px;
    max-width: 85vw;
  }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }

  .topbar {
    padding: .6rem .9rem;
    gap: .6rem;
  }
  .topbar-title { font-size: .95rem; }
  .topbar-user .avatar { width: 32px; height: 32px; }
  .topbar-user .avatar-initial { font-size: .85rem; }

  .content { padding: 1rem .9rem; }
  .footer { padding: .5rem .9rem; font-size: .72rem; }

  .stat-card { padding: .6rem .7rem; gap: .5rem; min-height: 60px; }
  .stat-icon { width: 34px; height: 34px; font-size: 1rem; border-radius: 8px; }
  .stat-label { font-size: .62rem; letter-spacing: .3px; }
  .stat-value { font-size: 1.1rem; }
  .card-header { font-size: .85rem; padding: .5rem .75rem; }

  /* Buttons in action rows wrap & shrink */
  .d-flex.flex-wrap.gap-2 .btn { font-size: .8rem; padding: .35rem .6rem; }

  /* Tables — compact, scroll if needed */
  .table > :not(caption) > * > * { padding: .45rem .5rem; font-size: .82rem; }
  .table thead th { font-size: .72rem; letter-spacing: .3px; }

  /* Card padding */
  .card-body { padding: .9rem; }

  /* Help chapter grid — single column on mobile */
  .help-chapters-grid { grid-template-columns: 1fr; }

  /* Page-level form filters */
  form .row.g-2 > .col-md-1,
  form .row.g-2 > .col-md-2 { margin-top: .25rem; }
}

/* ── Hide less-important table columns on small screens ──────────── */
@media (max-width: 768px) {
  .table thead th.hide-sm,
  .table tbody td.hide-sm { display: none; }
}
@media (max-width: 480px) {
  .table thead th.hide-xs,
  .table tbody td.hide-xs { display: none; }
}

/* ── Compact dashboard on phones ─────────────────────────────────── */
@media (max-width: 480px) {
  .stat-card { padding: .5rem .6rem; gap: .4rem; min-height: auto; }
  .stat-icon { width: 30px; height: 30px; font-size: .85rem; border-radius: 6px; }
  .stat-label { font-size: .58rem; }
  .stat-value { font-size: .95rem; }
  body { font-size: 14px; }
  .topbar-title { font-size: .88rem; max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-name, .user-role { display: none; }
  .card-header { font-size: .78rem; }
  .card-body { padding: .6rem !important; }
  .progress { height: 16px !important; font-size: .7rem; }
  .fs-5 { font-size: 1rem !important; }
}

/* ── Helpful utility: stack action buttons full-width on phones ──── */
@media (max-width: 480px) {
  .btn-stack-sm { display: flex; flex-direction: column; gap: .4rem; }
  .btn-stack-sm > * { width: 100%; }
}

/* ── Larger touch targets ────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-control, .form-select { font-size: 16px; /* prevents iOS zoom */ }
  .btn { min-height: 38px; }
  #sidebar .nav-link { padding: .75rem .9rem; font-size: .95rem; }
}

/* ── Pagination on mobile ─────────────────────────────────────── */
@media (max-width: 480px) {
  .pagination { flex-wrap: wrap; }
  nav.mt-3 .d-flex { flex-direction: column; gap: .5rem; align-items: stretch !important; }
}

