/* ============================================================
   CSWD Beneficiary Management System - Government Style CSS
   ============================================================ */

:root {
    --primary:       #1a3a6b;
    --primary-dark:  #122a50;
    --primary-light: #2a5298;
    --accent:        #c8a951;
    --accent-dark:   #a88730;
    --sidebar-bg:    #0f2347;
    --sidebar-hover: #1a3a6b;
    --sidebar-active:#c8a951;
    --body-bg:       #f0f2f7;
    --card-bg:       #ffffff;
    --text-dark:     #1a1a2e;
    --text-muted:    #6c757d;
    --border-color:  #dee2e6;
    --success:       #198754;
    --warning:       #ffc107;
    --danger:        #dc3545;
    --info:          #0dcaf0;
    --sidebar-width: 270px;
    --topbar-height: 65px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background: var(--body-bg);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    font-size: 0.895rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 18px 20px;
    background: var(--primary-dark);
    border-bottom: 2px solid var(--accent);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    font-size: 1.2rem;
    font-weight: 800;
    flex-shrink: 0;
}

.sidebar-brand-text {
    line-height: 1.2;
}

.sidebar-brand-text .title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-brand-text .subtitle {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.6);
    line-height: 1.3;
}

.sidebar-section {
    padding: 12px 20px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 8px;
}

.sidebar-nav {
    padding: 8px 12px;
    flex: 1;
}

.sidebar-item {
    margin-bottom: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.855rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--accent);
    color: var(--primary-dark);
    font-weight: 600;
}

.sidebar-link.active .sidebar-icon {
    color: var(--primary-dark);
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
}

.sidebar-link:hover .sidebar-icon {
    color: rgba(255,255,255,0.9);
}

.sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 600;
}

/* Submenu */
.sidebar-submenu {
    padding-left: 14px;
    display: none;
}

.sidebar-submenu.show { display: block; }

.sidebar-submenu .sidebar-link {
    font-size: 0.82rem;
    padding: 7px 12px;
    color: rgba(255,255,255,0.6);
}

.sidebar-submenu .sidebar-link::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    margin-right: 5px;
    flex-shrink: 0;
}

.sidebar-submenu .sidebar-link.active::before {
    background: var(--primary-dark);
}

/* Collapse arrow */
.sidebar-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.sidebar-link[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(90deg);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    text-align: center;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
    display: none;
}

.topbar-toggle:hover { background: var(--body-bg); }

.topbar-breadcrumb {
    flex: 1;
}

.topbar-breadcrumb .page-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    line-height: 1;
}

.topbar-breadcrumb .breadcrumb {
    margin: 2px 0 0;
    font-size: 0.75rem;
    --bs-breadcrumb-divider: '›';
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    text-decoration: none;
}

.topbar-icon-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.topbar-notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    text-decoration: none;
    color: var(--text-dark);
}

.topbar-user:hover { background: var(--body-bg); }

.topbar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2px solid var(--accent);
    overflow: hidden;
    flex-shrink: 0;
}

.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.topbar-user-info {
    line-height: 1.2;
}

.topbar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
}

.topbar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
    flex: 1;
    padding: 24px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 1px rgba(0,0,0,0.04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0 !important;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header .card-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.95rem;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stat-card {
    border-radius: 14px;
    padding: 22px;
    color: #fff;
    position: relative;
    overflow: hidden;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    bottom: -40px; right: 20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}

.stat-card .stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-sub {
    font-size: 0.72rem;
    opacity: 0.7;
    margin-top: 8px;
}

.stat-card-blue    { background: linear-gradient(135deg, #1a3a6b, #2a5298); }
.stat-card-green   { background: linear-gradient(135deg, #1a7a4a, #28a065); }
.stat-card-orange  { background: linear-gradient(135deg, #c44b00, #e85d04); }
.stat-card-purple  { background: linear-gradient(135deg, #5a189a, #7b2d8b); }
.stat-card-gold    { background: linear-gradient(135deg, #9a6f00, #c8a951); }
.stat-card-teal    { background: linear-gradient(135deg, #006d77, #0d9488); }

/* ============================================================
   TABLES
   ============================================================ */
.table {
    font-size: 0.845rem;
}

.table thead th {
    background: var(--body-bg);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 10px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f2f5;
}

.table tbody tr:hover { background: #f8f9ff; }

.table-responsive { border-radius: 0 0 12px 12px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    font-size: 0.845rem;
    font-weight: 500;
    border-radius: 8px;
    padding: 8px 18px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--primary-dark);
    font-weight: 600;
}

.btn-accent:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #fff;
}

.btn-sm {
    font-size: 0.775rem;
    padding: 5px 12px;
    border-radius: 6px;
}

.btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 5px;
    min-width: 28px;
    min-height: 28px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.855rem;
    padding: 9px 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}

.input-group-text {
    background: var(--body-bg);
    border-color: var(--border-color);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 0.855rem;
}

.form-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   BENEFICIARY PROFILE CARD
   ============================================================ */
.beneficiary-photo {
    width: 110px;
    height: 130px;
    object-fit: cover;
    border-radius: 10px;
    border: 3px solid var(--border-color);
}

.beneficiary-photo-placeholder {
    width: 110px;
    height: 130px;
    border-radius: 10px;
    background: var(--body-bg);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2.5rem;
}

.id-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(26,58,107,0.08);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid rgba(26,58,107,0.15);
    margin: 2px;
}

/* ============================================================
   ASSISTANCE HISTORY TABLE
   ============================================================ */
.assistance-type-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.at-burial   { background: #6c757d; }
.at-medical  { background: #dc3545; }
.at-scholar  { background: #0d6efd; }
.at-tupad    { background: #198754; }
.at-disaster { background: #fd7e14; }
.at-other    { background: #6f42c1; }

/* ============================================================
   STATUS WORKFLOW
   ============================================================ */
.status-timeline {
    position: relative;
    padding-left: 24px;
}

.status-timeline::before {
    content: '';
    position: absolute;
    left: 9px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-dot {
    position: absolute;
    left: -21px; top: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--border-color);
    border: 2px solid #fff;
}

.timeline-dot.active  { background: var(--success); }
.timeline-dot.current { background: var(--primary); box-shadow: 0 0 0 3px rgba(26,58,107,0.2); }

.timeline-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.timeline-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.search-box-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-search-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: 2px dashed var(--border-color);
    background: var(--body-bg);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.quick-search-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(26,58,107,0.04);
}

/* ============================================================
   QR CODE
   ============================================================ */
.qr-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    gap: 8px;
}

.qr-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ============================================================
   ALERTS / NOTICES
   ============================================================ */
.govt-notice {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.govt-notice-icon {
    font-size: 2rem;
    opacity: 0.85;
    flex-shrink: 0;
}

/* ── Dashboard Pending Action Chips ── */
.alert-action-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .15s;
    cursor: pointer;
}
.alert-action-chip:hover {
    background: #ffe69c;
    color: #664d03;
    text-decoration: none;
}
.alert-action-chip.alert-action-chip-danger {
    background: #f8d7da;
    color: #842029;
    border-color: #dc3545;
}
.alert-action-chip.alert-action-chip-danger:hover {
    background: #f5c2c7;
    color: #58151c;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar-toggle {
        display: flex;
    }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f2347 0%, #1a3a6b 50%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -100px; right: -100px;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(200,169,81,0.08);
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -150px; left: -100px;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-seal {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 15px rgba(26,58,107,0.3);
    border: 3px solid var(--accent);
}

.login-seal i {
    font-size: 2rem;
    color: #fff;
}

.login-header h4 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-header p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary  { color: var(--primary) !important; }
.bg-primary    { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.rounded-10 { border-radius: 10px; }
.rounded-12 { border-radius: 12px; }

.gap-2 { gap: 8px; }

.fs-xs { font-size: 0.72rem; }
.fs-sm { font-size: 0.82rem; }

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

/* DataTables override */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    font-size: 0.82rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--body-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--primary) !important;
    border-radius: 6px;
}

.page-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1040;
}

.page-overlay.show { display: block; }
