/* ===================== ADMIN PORTAL — YATBA SACCO ===================== */
:root {
    --navy: #001D3D;
    --navy-mid: #003566;
    --navy-light: #002855;
    --gold: #FFD700;
    --gold-hover: #FFC300;
    --bg: #f5f7fb;
    --white: #fff;
    --text: #222;
    --text-mid: #444;
    --text-light: #6b6b6b;
    --border: #e2e6ed;
    --shadow: 0 2px 12px rgba(0,29,61,.07);
    --shadow-lg: 0 8px 32px rgba(0,29,61,.1);
    --radius: 10px;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --sidebar-w: 250px;
    --topbar-h: 60px;
}

/* ---- RESET ---- */
*,*::before,*::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ---- LAYOUT ---- */
.admin-layout { display: flex; min-height: 100vh; width: 100%; max-width: 100vw; overflow-x: hidden; }

/* ---- SIDEBAR ---- */
.admin-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-mid) 100%);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 120;
    transition: transform .3s ease;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.3px;
}
.sidebar-brand h2 span { color: var(--gold); }
.sidebar-brand small {
    display: block;
    font-size: .68rem;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 4px;
    font-weight: 600;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 22px;
    font-size: .85rem;
    font-weight: 500;
    color: rgba(255,255,255,.55);
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
}
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,.1);
    border-left-color: var(--gold);
}
.sidebar-nav a i { width: 20px; text-align: center; font-size: .9rem; }
.sidebar-footer {
    padding: 14px 22px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .75rem;
    color: rgba(255,255,255,.3);
    flex-shrink: 0;
}

/* ---- SIDEBAR TOGGLE ---- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 200;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 42px; height: 42px;
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ---- SIDEBAR OVERLAY ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 110;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.active { display: block; }

/* ---- MAIN AREA ---- */
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-w));
}
.admin-topbar {
    background: var(--white);
    padding: 0 28px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
    overflow: hidden;
    max-width: 100%;
}
.admin-topbar h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.admin-topbar .admin-user {
    font-size: .82rem;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
}
.admin-content {
    padding: 24px 28px;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stats-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--navy-light);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.navy   { border-left-color: var(--navy); }
.stat-card.teal   { border-left-color: var(--navy-light); }
.stat-card.gold   { border-left-color: var(--gold); }
.stat-card.success{ border-left-color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info   { border-left-color: var(--info); }
.stat-card.warning{ border-left-color: var(--warning); }
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.2;
    margin-bottom: 4px;
    word-break: break-word;
}
.stat-card .stat-label {
    font-size: .72rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ---- CARDS ---- */
.admin-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}
.admin-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.admin-card-header h3 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--navy);
    min-width: 0;
}
.admin-card-body { padding: 20px; }

/* ---- TABLES ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .84rem;
}
.admin-table th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(0,29,61,.02); }
.admin-table .no-data {
    text-align: center;
    color: var(--text-light);
    padding: 36px 14px;
}

/* ---- BADGES ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,.1); color: #059669; }
.badge-danger  { background: rgba(239,68,68,.1);  color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.1); color: #d97706; }
.badge-info    { background: rgba(59,130,246,.1);  color: #2563eb; }
.badge-navy    { background: rgba(0,29,61,.08);    color: var(--navy); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    border: none;
    font-family: inherit;
    letter-spacing: .2px;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-teal { background: var(--navy-light); color: #fff; }
.btn-teal:hover { background: var(--navy-mid); }
.btn-gold { background: var(--gold); color: var(--navy); font-weight: 700; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
    background: transparent;
    color: var(--navy);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--navy); background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: .75rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .85rem;
    font-family: inherit;
    transition: border-color .2s;
    background: var(--white);
    color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(0,40,85,.08);
}
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-inline .form-group { margin-bottom: 0; }

/* ---- FILTERS BAR ---- */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filters-bar .form-group { margin-bottom: 0; min-width: 0; flex: 1; }
.filters-bar .form-group label { font-size: .72rem; }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .84rem;
    font-weight: 500;
}
.alert-success { background: rgba(16,185,129,.1); color: #059669; border: 1px solid rgba(16,185,129,.2); }
.alert-error   { background: rgba(239,68,68,.1);  color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.alert-warning { background: rgba(245,158,11,.1); color: #d97706; border: 1px solid rgba(245,158,11,.2); }
.alert-info    { background: rgba(59,130,246,.1);  color: #2563eb; border: 1px solid rgba(59,130,246,.2); }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
}
.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 44px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card .login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-card .login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
}
.login-card .login-brand h1 span { color: var(--gold); }
.login-card .login-brand p {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 4px;
}
.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: .88rem;
}

/* ---- GRID HELPERS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > * { min-width: 0; }

/* ---- SPACING ---- */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

/* ---- UTILITIES ---- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-light); }
.text-small  { font-size: .82rem; }
.fw-bold     { font-weight: 700; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

/* -- Tablet / Small desktop -- */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .admin-content { padding: 20px; }
}

/* -- Mobile landscape / Tablet portrait -- */
@media (max-width: 768px) {
    :root { --topbar-h: 54px; }

    /* Sidebar: hidden off-screen */
    .sidebar-toggle { display: flex; }
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); }

    /* Main shifts to full width */
    .admin-main { margin-left: 0; max-width: 100vw; }

    /* Topbar */
    .admin-topbar {
        padding: 0 14px 0 58px;
        gap: 8px;
    }
    .admin-topbar h1 { font-size: 1rem; }
    .admin-content { padding: 16px 14px; }

    /* Grids → stack */
    .grid-2 { grid-template-columns: 1fr; gap: 16px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }

    /* Stat cards: 2-col on tablet */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 16px 14px; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-label { font-size: .68rem; }

    /* Cards */
    .admin-card-header { padding: 14px 16px; }
    .admin-card-body { padding: 16px; }

    /* Filters → stack vertically */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }
    .filters-bar .form-group { min-width: 100%; }
    .filters-bar .btn { width: 100%; }

    /* Tables scroll horizontally */
    .admin-table { min-width: 580px; }
    .admin-table th,
    .admin-table td { padding: 8px 10px; font-size: .78rem; }

    /* Buttons */
    .btn-group { gap: 4px; }
    .btn-sm { padding: 5px 10px; font-size: .72rem; }
    .btn-block { padding: 11px; }

    /* Login */
    .login-card { padding: 32px 24px; }
    .login-card .login-brand h1 { font-size: 1.3rem; }
}

/* -- Mobile portrait -- */
@media (max-width: 480px) {
    /* Stats go single column */
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card .stat-value { font-size: 1.15rem; }

    /* Topbar */
    .admin-topbar {
        padding: 0 10px 0 56px;
        height: 48px;
    }
    .admin-topbar h1 { font-size: .92rem; }
    .admin-topbar .admin-user { display: none; }
    .admin-topbar .btn { font-size: .7rem; padding: 4px 8px; gap: 4px; }

    /* Content */
    .admin-content { padding: 12px 10px; }

    /* Cards */
    .admin-card-header { padding: 12px 14px; }
    .admin-card-header h3 { font-size: .85rem; }
    .admin-card-body { padding: 14px; }

    /* Form */
    .form-group input,
    .form-group select,
    .form-group textarea { padding: 8px 10px; font-size: .82rem; }

    /* Login */
    .login-page { padding: 16px; }
    .login-card { padding: 24px 18px; }
    .login-card .login-brand h1 { font-size: 1.1rem; }

    /* Sidebar brand */
    .sidebar-brand { padding: 18px 16px; }
    .sidebar-brand h2 { font-size: 1.05rem; }
    .sidebar-nav a { padding: 10px 18px; font-size: .82rem; }
}
