/* ────────────────────────────────────────────────────────────────
   Barangay e-Vakul — design language
   Batanes as inspiration, not decoration: deep sea blue, hill green,
   Ivatan stone-house gray, cogon cream, and a small accent of terracotta.
   The app itself stays clean and government-professional.
   ──────────────────────────────────────────────────────────────── */

:root {
  --sea-blue: #1e3a5f;
  --sea-blue-dark: #142a45;
  --sea-blue-light: #2d5580;
  --hill-green: #4f7a5c;
  --hill-green-light: #6b9678;
  --stone-gray: #6b6660;
  --stone-gray-light: #a8a29a;
  --cogon-cream: #f4ede0;
  --cogon-cream-dark: #e8dcc8;
  --accent-terracotta: #c1673b;
  --accent-terracotta-light: #d98a5f;

  --bg-page: #faf7f0;
  --bg-card: #ffffff;
  --bg-sidebar: var(--sea-blue-dark);
  --text-primary: #23262b;
  --text-secondary: #625d55;
  --text-inverse: #f4ede0;
  --border-soft: #e5ddcc;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 3px rgba(30, 58, 95, 0.08), 0 1px 2px rgba(30, 58, 95, 0.06);
  --shadow-elevated: 0 8px 24px rgba(20, 42, 69, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* subtle cogon-line texture on the page background, never on content cards */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    115deg,
    rgba(79, 122, 92, 0.025) 0px,
    rgba(79, 122, 92, 0.025) 1px,
    transparent 1px,
    transparent 14px
  );
}

a { color: var(--sea-blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── App shell ─────────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Batanes hills silhouette, faint, along the bottom of the sidebar */
.sidebar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 90px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.15));
  clip-path: polygon(0% 100%, 0% 70%, 12% 55%, 25% 68%, 40% 40%, 55% 62%, 70% 45%, 85% 66%, 100% 50%, 100% 100%);
  background-color: rgba(255,255,255,0.04);
}

.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(244, 237, 224, 0.12);
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--hill-green), var(--sea-blue-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-text strong { display: block; font-size: 15px; letter-spacing: 0.2px; }
.sidebar-brand-text span { display: block; font-size: 11px; opacity: 0.65; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  position: relative;
  z-index: 1;
}

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.5;
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-inverse);
  opacity: 0.82;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background 0.15s, opacity 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: rgba(244, 237, 224, 0.08); opacity: 1; }
.nav-link.active { background: rgba(244, 237, 224, 0.14); opacity: 1; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-terracotta); }
.nav-link .icon { width: 18px; text-align: center; }
.nav-link.locked { opacity: 0.35; cursor: not-allowed; }
.nav-link.locked:hover { background: none; }

.nav-group { margin-bottom: 2px; }
.nav-group-toggle { position: relative; }
.nav-group-caret { margin-left: auto; font-size: 10px; transition: transform 0.15s; flex-shrink: 0; }
.nav-group-toggle[aria-expanded="true"] .nav-group-caret { transform: rotate(180deg); }
.nav-submenu {
  max-height: 0; overflow: hidden; transition: max-height 0.2s ease;
  display: flex; flex-direction: column;
}
.nav-submenu.open { max-height: 200px; }
.nav-sublink {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 30px;
  border-radius: var(--radius-sm);
  color: var(--text-inverse); opacity: 0.75; font-size: 13px;
  margin-bottom: 2px;
}
.nav-sublink:hover { background: rgba(244, 237, 224, 0.08); opacity: 1; }
.nav-sublink .icon { width: 16px; text-align: center; font-size: 12px; }

.sidebar-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(244, 237, 224, 0.12);
  font-size: 11.5px;
  opacity: 0.55;
  position: relative;
  z-index: 1;
}

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

.topbar {
  height: 62px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-title { font-size: 17px; font-weight: 600; color: var(--text-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title .breadcrumb-sub { font-size: 12px; font-weight: 400; color: var(--text-secondary); margin-left: 8px; }

.sidebar-toggle-btn {
  display: none; background: none; border: none; font-size: 19px;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  align-items: center; justify-content: center; color: var(--text-primary); flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--cogon-cream); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(20, 30, 40, 0.45); z-index: 150; }
.sidebar-overlay.open { display: block; }

.topbar-user { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-user-name { font-size: 13px; text-align: right; line-height: 1.3; }
.topbar-user-name strong { display: block; font-size: 13px; }
.topbar-user-name span { display: block; font-size: 11px; color: var(--text-secondary); }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sea-blue), var(--hill-green));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.btn-logout {
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn-logout:hover { background: var(--cogon-cream); }

.content-body { flex: 1; padding: 24px; overflow-y: auto; }

/* ── Notification bell ────────────────────────────────────────── */

.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  position: relative; background: none; border: none; font-size: 19px;
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.notif-bell-btn:hover { background: var(--cogon-cream); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; background: var(--accent-terracotta); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1;
}
.notif-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: min(320px, calc(100vw - 24px));
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated); z-index: 1500; overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: 12px 16px; font-size: 12.5px; font-weight: 700; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.notif-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft); background: none; border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left; font-size: 13px; color: var(--text-primary);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--cogon-cream); }
.notif-item .notif-count { background: var(--sea-blue); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; flex-shrink: 0; }
.notif-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-secondary); }

/* ── User menu dropdown ───────────────────────────────────────── */

.user-menu-wrap { position: relative; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 10px; background: none; border: none; padding: 4px 6px; border-radius: var(--radius-sm);
}
.user-menu-trigger:hover { background: var(--cogon-cream); }
.user-menu-caret { font-size: 10px; color: var(--text-secondary); }
.user-menu-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: min(210px, calc(100vw - 24px));
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated); z-index: 1500; overflow: hidden; padding: 6px;
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-primary);
}
.user-menu-item:hover { background: var(--cogon-cream); }
.user-menu-divider { height: 1px; background: var(--border-soft); margin: 6px 2px; }

/* ── Password field with show/hide toggle ─────────────────────── */

.password-input-wrap { position: relative; }
.password-input-wrap input { width: 100%; padding-right: 40px; }
.password-toggle-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 15px; opacity: 0.55; padding: 6px;
}
.password-toggle-btn:hover { opacity: 1; }

.link-btn { background: none; border: none; color: var(--sea-blue); font-size: 12.5px; font-weight: 600; text-decoration: underline; }

/* ── Cards / stats ─────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; bottom: 0; width: 3px;
  background: var(--accent-color, var(--sea-blue));
}
.stat-card .stat-icon { font-size: 20px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-header h2 { margin: 0; font-size: 18px; font-weight: 600; text-align: left; }
.section-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-secondary); }

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sea-blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent { background: var(--accent-terracotta); color: #fff; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; border: 1px solid var(--border-soft); color: var(--text-primary); }
.btn-outline:hover { background: var(--cogon-cream); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-danger { background: #c0392b; color: #fff; }

/* ── Tables ────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }
table.data-table { width: 100%; border-collapse: collapse; background: var(--bg-card); font-size: 13px; }
table.data-table th {
  text-align: left; padding: 11px 14px; background: var(--cogon-cream);
  color: var(--text-secondary); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-soft);
}
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: rgba(79, 122, 92, 0.04); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: rgba(79,122,92,0.14); color: var(--hill-green); }
.badge-blue { background: rgba(30,58,95,0.1); color: var(--sea-blue); }
.badge-orange { background: rgba(193,103,59,0.14); color: var(--accent-terracotta); }
.badge-gray { background: rgba(107,102,96,0.14); color: var(--stone-gray); }
.badge-red { background: rgba(192,57,43,0.12); color: #c0392b; }

/* ── Forms ─────────────────────────────────────────────────────── */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.span-2 { grid-column: span 2; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text-primary);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--sea-blue-light); box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}
.form-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.field-error { display: block; color: #c0392b; font-size: 11.5px; margin-top: 4px; }

/* ── Modal ─────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 30, 40, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-elevated);
  width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto;
}
.modal-card.wide { max-width: 880px; }
.modal-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 22px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--bg-card); z-index: 2;
}
.modal-card-header h3 { margin: 0; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-secondary); line-height: 1; flex-shrink: 0; }
.modal-card-body { padding: 22px; }
.modal-card-footer { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Login screen ──────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--sea-blue-dark) 0%, var(--sea-blue) 55%, var(--hill-green) 130%);
  position: relative; overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 15% 85%, rgba(244,237,224,0.06) 0%, transparent 40%),
    repeating-linear-gradient(135deg, rgba(244,237,224,0.025) 0px, rgba(244,237,224,0.025) 2px, transparent 2px, transparent 22px);
}
.login-card {
  background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-elevated);
  width: 100%; max-width: 400px; padding: 36px 32px; position: relative; z-index: 1;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand-icon {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--hill-green), var(--sea-blue)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.login-brand h1 { margin: 0; font-size: 19px; }
.login-brand p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.login-error { background: rgba(192,57,43,0.1); color: #c0392b; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; }
.login-hint { text-align: center; font-size: 11.5px; color: var(--text-secondary); margin-top: 18px; line-height: 1.6; }

/* ── Certificate print sheet ───────────────────────────────────── */

.cert-sheet {
  background: #fffdf8; border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 40px 48px; max-width: 720px; margin: 0 auto; position: relative; box-shadow: var(--shadow-card);
  font-family: Georgia, 'Times New Roman', serif; color: #1a1a1a;
}
.cert-sheet-watermark {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 54px; font-weight: 700; color: rgba(30,58,95,0.05); transform: rotate(-25deg);
  pointer-events: none; letter-spacing: 4px; white-space: nowrap;
}
.cert-sheet-header { text-align: center; margin-bottom: 20px; }
.cert-sheet-header .cert-logos { display: flex; justify-content: center; gap: 20px; margin-bottom: 8px; }
.cert-sheet-header .cert-logos img { width: 56px; height: 56px; object-fit: contain; }
.cert-sheet-header h2 { margin: 4px 0 0; font-size: 15px; letter-spacing: 1px; }
.cert-sheet-header h1 { margin: 10px 0 0; font-size: 22px; text-decoration: underline; letter-spacing: 1px; }
.cert-sheet-body { font-size: 14.5px; line-height: 2; text-align: justify; margin: 26px 0; }
.cert-sheet-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 40px; }
.cert-sheet-signatory { text-align: center; font-size: 13px; }
.cert-sheet-signatory .sig-name { font-weight: 700; border-top: 1px solid #333; padding-top: 4px; margin-top: 34px; }
.cert-sheet-qr { text-align: center; font-size: 10px; color: var(--text-secondary); }
.cert-sheet-qr img { width: 70px; height: 70px; }
.cert-doc-number { position: absolute; bottom: 14px; left: 20px; font-size: 9.5px; color: var(--text-secondary); font-family: monospace; }

/* ── Utility ───────────────────────────────────────────────────── */

.text-muted { color: var(--text-secondary); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-btn { padding: 10px 16px; background: none; border: none; font-size: 13px; color: var(--text-secondary); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.tab-btn.active { color: var(--sea-blue); border-bottom-color: var(--sea-blue); font-weight: 600; }
.coming-soon-badge { font-size: 9px; background: var(--accent-terracotta); color: #fff; padding: 1px 6px; border-radius: 8px; margin-left: auto; }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 3px;
  background: var(--accent-terracotta); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 8px; line-height: 1; vertical-align: 2px;
}

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 200; height: 100vh; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-field.span-2 { grid-column: span 1; }

  .sidebar-toggle-btn { display: flex; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-user { gap: 8px; }
  .content-body { padding: 16px; }
  .cert-sheet { padding: 26px 18px; }
  .cert-sheet-footer { flex-wrap: wrap; gap: 20px; }
}

@media (max-width: 640px) {
  .topbar-user-name { display: none; }
  .user-menu-caret { display: none; }
}
