/* ============================================================
   TAJIRIKA MICROFINANCE - Custom Styles
   ============================================================ */

:root {
    --brand-navy: #1b2a4e;
    --brand-gold: #c9a227;
    --brand-light-gold: #e0c468;
}

/* ============================================================
   SIDEBAR - self-contained layout, no reliance on Tailwind utilities
   ============================================================ */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: 16rem;
    background: linear-gradient(180deg, #1b2a4e 0%, #16305f 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}
@media (min-width: 768px) {
    .sidebar { transform: translateX(0); }
}
.sidebar.is-open { transform: translateX(0); }

/* ---- Brand / Logo row ---- */
.sidebar-brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
    padding: 0 1rem;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-logo { height: 2.25rem; object-fit: contain; }
.sidebar-brand-mark { display: flex; align-items: center; gap: 0.625rem; }
.sidebar-brand-letter {
    display: flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem;
    background: var(--brand-gold);
    color: #fff; font-weight: 900; font-size: 1.15rem;
    border-radius: 0.6rem;
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.15; }
.sidebar-brand-name { font-weight: 700; font-size: 0.85rem; margin: 0; }
.sidebar-brand-sub { font-size: 0.7rem; color: #cbb673; margin: 0; }
.sidebar-close-btn {
    background: none; border: none; color: #cbb673; cursor: pointer;
    font-size: 1.1rem; padding: 0.25rem;
}
.sidebar-close-btn:hover { color: #fff; }
@media (min-width: 768px) { .sidebar-close-btn { display: none; } }

/* ---- Logged-in user summary ---- */
.sidebar-user {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-avatar {
    flex-shrink: 0;
    width: 2.25rem; height: 2.25rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-gold);
    color: #fff; font-weight: 700; font-size: 0.9rem;
    border-radius: 999px;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name {
    font-size: 0.85rem; font-weight: 600; color: #fff; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 0.7rem; color: #cbb673; margin: 0; text-transform: capitalize; }

/* ---- Scrollable navigation area ---- */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }

/* ---- Top-level item: plain link OR group-toggle button share this base ---- */
.nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.15rem;
    border-radius: 0.6rem;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
    color: #c9b98a;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.is-active { background: var(--brand-gold); color: #fff; font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid rgba(255,255,255,0.4); outline-offset: 1px; }

/* Fixed icon box - alignment never depends on font glyph metrics */
.nav-icon {
    flex: 0 0 auto;
    width: 1.35rem; height: 1.35rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
}

/* Label eats remaining space -> anything after it (badge/chevron) is pushed right automatically */
.nav-label { flex: 1 1 auto; min-width: 0; }

/* Chevron for expandable groups */
.nav-chevron {
    flex: 0 0 auto;
    font-size: 0.7rem;
    color: #cbb673;
    transition: transform 0.2s ease;
}
.nav-group.is-open .nav-chevron { transform: rotate(180deg); }
.nav-group.is-open { background: rgba(255,255,255,0.06); color: #fff; }

/* Count badge */
.nav-badge {
    flex: 0 0 auto;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.35rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    margin-right: 0.35rem;
}
.nav-badge-red    { background: #ef4444; color: #fff; }
.nav-badge-yellow { background: #facc15; color: #78350f; }

/* ---- Submenu ---- */
.nav-submenu {
    display: flex;
    flex-direction: column;
    margin: 0 0 0.35rem 1.65rem;
    padding-left: 0.65rem;
    border-left: 2px solid rgba(255,255,255,0.1);
}
.nav-submenu.is-collapsed { display: none; }

.nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.42rem 0.6rem;
    margin: 1px 0;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.3;
    color: #b3a06a;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-subitem:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-subitem.is-active { background: var(--brand-gold); color: #fff; font-weight: 600; }
.nav-subicon { flex: 0 0 auto; width: 1rem; text-align: center; font-size: 0.8rem; }

/* ---- Sidebar footer: profile + logout, always pinned & visible ---- */
.sidebar-footer {
    flex: 0 0 auto;
    padding: 0.75rem;
    background: rgba(0,0,0,0.18);
    border-top: 2px solid rgba(255,255,255,0.1);
}
.sidebar-footer-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.4rem;
}
.sidebar-footer-avatar {
    flex-shrink: 0;
    width: 2rem; height: 2rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-gold);
    color: #fff; font-weight: 700; font-size: 0.8rem;
    border-radius: 999px;
}
.sidebar-footer-info { min-width: 0; flex: 1; }
.sidebar-footer-name {
    font-size: 0.78rem; font-weight: 600; color: #fff; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer-role { font-size: 0.68rem; color: #cbb673; margin: 0; text-transform: capitalize; }

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.55rem;
    font-size: 0.82rem;
    color: #c9b98a;
    text-decoration: none;
    margin-bottom: 0.25rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-footer-link:last-child { margin-bottom: 0; }
.sidebar-footer-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-footer-link i { width: 1.1rem; text-align: center; flex-shrink: 0; }
.sidebar-footer-logout {
    background: #dc2626;
    color: #fff;
    font-weight: 600;
}
.sidebar-footer-logout:hover { background: #b91c1c; color: #fff; }

/* Cards */
.stat-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #f1f5f9;
    transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* Form Controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #fff;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    text-decoration: none;
}
.btn-primary   { background: var(--brand-navy);  color: #fff; }
.btn-primary:hover { background: #16233f; }
.btn-success   { background: var(--brand-gold); color: #fff; }
.btn-success:hover { background: #a8841f; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: #f59e0b; color: #fff; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8125rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { 
    background: #f8fafc; 
    padding: 0.75rem 1rem; 
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}
.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
}
.data-table tr:hover td { background: #f8fafc; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: #fff;
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

/* Chart container */
.chart-container { position: relative; height: 280px; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.625rem !important;
    border-radius: 0.375rem !important;
    font-size: 0.875rem !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--brand-navy) !important;
    color: #fff !important;
    border-color: var(--brand-navy) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .stat-card { padding: 1rem; }
}

/* Landing page */
.landing-hero {
    background: linear-gradient(135deg, var(--brand-navy) 0%, #16233f 50%, #24365e 100%);
    min-height: 85vh;
    display: flex;
    align-items: center;
}
.landing-nav { background: rgba(30,58,138,0.95); backdrop-filter: blur(10px); }
.service-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    transition: all 0.3s;
}
.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(30,58,138,0.12);
    border-color: var(--brand-gold);
}

/* ============================================================
   PRINT STYLES - Hide navigation, show only content
   ============================================================ */
@media print {
    /* Hide sidebar, topbar, buttons, filters */
    #sidebar,
    #overlay,
    header,
    .btn,
    form:not(.print-include),
    .nav-link,
    #flash-msg,
    .chart-container { display: none !important; }

    /* Reset layout */
    body { background: #fff !important; font-size: 11px !important; }
    .md\:ml-64 { margin-left: 0 !important; }
    main { padding: 0 !important; }

    /* Tables */
    .data-table th { background: #1b2a4e !important; color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .data-table td, .data-table th { padding: 5px 8px !important; font-size: 10px !important; }
    .stat-card, .bg-white { box-shadow: none !important; border: 1px solid #e5e7eb !important; }

    /* Page breaks */
    tr { page-break-inside: avoid; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
}
