/* ============================================================
   Beneficiary Management System - Professional Admin Theme
   Sidebar + Topbar layout, mobile-responsive
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #111827;
    --sidebar-bg-light: #1f2937;
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --accent-color: #e11d48;
    --success-color: #16a34a;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --page-bg: #f1f5f9;
    --white: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.08);
    --shadow-md: 0 4px 10px rgba(15,23,42,0.10);
    --shadow-lg: 0 10px 25px rgba(15,23,42,0.14);
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--page-bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   App Shell (sidebar + main area)
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - hidden by default at every screen size; opens as an
   overlay drawer only when the ☰ button is clicked, so the table
   always gets the full page width by default. */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0b1120 100%);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: var(--shadow-lg);
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

.brand-icon {
    font-size: 26px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.18);
    border-radius: 10px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    overflow: hidden;
}

.brand-text strong {
    color: #fff;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text span {
    font-size: 12px;
    color: #94a3b8;
}

.sidebar-close {
    margin-left: auto;
    background: rgba(255,255,255,0.08);
    border: none;
    color: #cbd5e1;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: rgba(220, 38, 38, 0.3);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.nav-icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-user div:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    overflow: hidden;
}

.sidebar-user strong {
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user span {
    font-size: 11px;
    color: #94a3b8;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    background: rgba(220, 38, 38, 0.14);
    color: #fca5a5;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(220, 38, 38, 0.25);
    color: #fff;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(2px);
    z-index: 900;
}

.sidebar-overlay.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Main area - always full width; the sidebar floats above it as a
   drawer instead of pushing it, so the table view never shrinks. */
.main-area {
    flex: 1;
    margin-left: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--white);
    padding: 16px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: var(--shadow-sm);
}

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.hamburger {
    display: flex;
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.hamburger:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

.hamburger.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.content-area {
    padding: 24px 28px 60px;
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
}

/* Page sections (menu tabs) */
.page-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.page-section.active {
    display: block;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-left::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

/* Import Section */
.import-section {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.25s ease;
    cursor: pointer;
}

.import-section:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.import-section.dragover {
    background: #dbeafe;
    border-color: var(--primary-color);
}

.import-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.import-section h3 {
    font-size: 17px;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.import-section p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 16px;
}

.import-hint {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    margin-top: 4px;
}

#fileInput {
    display: none;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    padding: 11px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-export {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.btn-export:hover {
    background: #d1fae5;
}

.btn-light {
    background: var(--page-bg);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 38px;
}

/* Password field with show/hide toggle */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 46px;
}

.toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px 8px;
    color: var(--text-light);
    border-radius: 6px;
    line-height: 1;
}

.toggle-password:hover {
    background: var(--page-bg);
    color: var(--text-dark);
}

/* Filter Section */
.filter-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 18px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

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

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.amber { background: #fef3c7; }

.stat-number {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 12.5px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ============================================================
   Table Styling
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    margin-top: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 13px 15px;
    text-align: left;
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-light);
    border-bottom: 1.5px solid var(--border-color);
    white-space: nowrap;
    background: #f8fafc;
}

td {
    padding: 13px 15px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13.5px;
    white-space: nowrap;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
    background: #fafbfc;
}

tbody tr:hover {
    background: #eff6ff;
}

tbody tr:last-child td {
    border-bottom: none;
}

th.text-right, td.text-right {
    text-align: right;
}

/* Status Badge */
.badge {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* Alert Messages */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.25s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success-color); }
.alert-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger-color); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warning-color); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--primary-color); }

/* Loading Spinner */
.spinner {
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 0.9s linear infinite;
    margin: 18px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 8px 13px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-dark);
    background: var(--white);
}

.pagination a:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.pagination .active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* ============================================================
   Login Page
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%);
}

.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(0,0,0,0.25);
    padding: 40px 34px;
    width: 100%;
    max-width: 380px;
}

.login-brand {
    text-align: center;
    margin-bottom: 26px;
}

.login-brand .brand-icon {
    margin: 0 auto 14px;
    width: 58px;
    height: 58px;
    font-size: 30px;
    background: #dbeafe;
}

.login-brand h2 {
    font-size: 21px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.login-brand p {
    font-size: 13px;
    color: var(--text-light);
}

.login-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    border-left: 4px solid var(--danger-color);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .content-area {
        padding: 18px 14px 50px;
    }

    .card {
        padding: 18px;
    }

    .topbar {
        padding: 14px 16px;
    }

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

    .filter-section {
        grid-template-columns: 1fr;
    }

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

    .table-responsive {
        font-size: 12px;
    }

    th, td {
        padding: 10px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 12px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }
