@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #06b6d4;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 78px;
    --bg-body: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.06);
    --shadow-lg: 0 10px 25px rgba(15,23,42,0.1);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== APP LAYOUT ==================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 16px rgba(0,0,0,0.15);
    overflow: hidden;
}

.sidebar-brand {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 4px 10px rgba(37,99,235,0.35);
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand-name {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.2px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-brand-sub {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-heading {
    color: #475569;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 14px 6px;
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-link i.bi {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    color: #64748b;
    transition: color 0.2s;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    color: #f1f5f9;
}

.sidebar-link:hover i.bi {
    color: #93c5fd;
}

.sidebar-link.active {
    background: linear-gradient(90deg, var(--sidebar-active) 0%, #1d4ed8 100%);
    color: var(--sidebar-text-active);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.sidebar-link.active i.bi {
    color: #ffffff;
}

/* Sidebar Dropdown */
.sidebar-link .dropdown-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}

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

.sidebar-submenu {
    list-style: none;
    padding: 4px 0 6px 36px;
    margin: 0;
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.sidebar-submenu-link:hover {
    color: #ffffff;
    background-color: rgba(255,255,255,0.06);
}

.sidebar-submenu-link.active {
    color: #60a5fa;
    font-weight: 600;
    background-color: rgba(37,99,235,0.15);
}

.sidebar-submenu-link .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #64748b;
    transition: background-color 0.2s;
}

.sidebar-submenu-link:hover .dot,
.sidebar-submenu-link.active .dot {
    background-color: #60a5fa;
}

/* ==================== MAIN CONTENT ==================== */
.main-wrapper {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== TOPBAR ==================== */
.topbar {
    background: #ffffff;
    height: 66px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.35rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background-color: #f1f5f9;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 20px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-main);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.topbar-logout {
    color: #ef4444;
    font-size: 1.15rem;
    padding: 6px;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.topbar-logout:hover {
    background-color: #fef2f2;
}

/* ==================== CONTENT BODY ==================== */
.content-body {
    padding: 28px;
    flex-grow: 1;
    min-width: 0;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

/* ==================== CARDS & CONTAINERS ==================== */
.card-custom {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-custom .card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-custom .card-body {
    padding: 20px;
}

/* Stat Cards */
.stat-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.primary::before { background-color: var(--primary); }
.stat-card.success::before { background-color: var(--success); }
.stat-card.danger::before { background-color: var(--danger); }
.stat-card.info::before { background-color: var(--info); }
.stat-card.warning::before { background-color: var(--warning); }

.stat-card .label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 1.45rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.primary { background: #eff6ff; color: #2563eb; }
.stat-icon.success { background: #ecfdf5; color: #10b981; }
.stat-icon.danger { background: #fef2f2; color: #ef4444; }
.stat-icon.info { background: #e0f2fe; color: #0284c7; }
.stat-icon.warning { background: #fffbeb; color: #d97706; }

/* ==================== BADGES & TAGS ==================== */
.badge-cash-in {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background-color: #dcfce7;
    color: #15803d;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 20px;
}

.badge-cash-out {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background-color: #fee2e2;
    color: #b91c1c;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 20px;
}

.party-badge {
    font-weight: 600;
    color: #1e293b;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.88rem;
    text-decoration: none;
    transition: background 0.2s;
}

.party-badge:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* ==================== TABLES ==================== */
.table-custom {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    white-space: nowrap;
}

/* Keep wide tables inside the card area so the page never overflows to the right */
.table-responsive .table-custom {
    table-layout: fixed;
    min-width: 900px;
}

.table-custom tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
    color: #334155;
}

.table-custom tbody tr:hover td {
    background-color: #f8fafc;
}

.amount-in {
    color: #16a34a;
    font-weight: 700;
}

.amount-out {
    color: #dc2626;
    font-weight: 700;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

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

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
}

.btn-success:hover {
    background-color: #059669;
    border-color: #059669;
}

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

.btn-outline-primary, .btn-outline-secondary, .btn-outline-success {
    font-weight: 600;
    border-radius: var(--radius-sm);
}

/* ==================== FORMS ==================== */
.form-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.form-control, .form-select {
    font-size: 0.9rem;
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    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(37,99,235,0.12);
}

/* ==================== FOOTER ==================== */
.footer-text {
    padding: 20px 28px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
}

/* ==================== LOGIN PAGE ==================== */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
    padding: 36px 32px;
}

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

.login-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #ffffff;
    font-size: 1.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 6px 16px rgba(37,99,235,0.35);
}

.login-brand h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.login-brand p {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0;
}

/* ==================== SIDEBAR COLLAPSE TOGGLE ==================== */
.sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px;
    padding: 10px 14px;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: var(--sidebar-text);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.sidebar-collapse-toggle:hover {
    background-color: var(--sidebar-hover);
    color: #f1f5f9;
}

.sidebar-collapse-toggle .bi {
    font-size: 1.05rem;
    line-height: 1;
}

.sidebar-collapse-toggle .bi-chevrons-right {
    display: none;
}

/* Desktop collapsed (icon-only) state */
.sidebar.sidebar-collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 0;
}

.sidebar.sidebar-collapsed .sidebar-brand-text {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-menu {
    padding: 20px 10px;
}

.sidebar.sidebar-collapsed .sidebar-heading {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
}

.sidebar.sidebar-collapsed .sidebar-link span,
.sidebar.sidebar-collapsed .sidebar-link .dropdown-arrow {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-submenu {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-collapse-toggle {
    justify-content: center;
    gap: 0;
    padding: 10px 0;
    margin: 12px;
}

.sidebar.sidebar-collapsed .sidebar-collapse-toggle .collapse-btn-label {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-collapse-toggle .bi-chevrons-left {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-collapse-toggle .bi-chevrons-right {
    display: inline-block;
}

.sidebar.sidebar-collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    max-width: calc(100% - var(--sidebar-width-collapsed));
}

/* ==================== MOBILE RESPONSIVE ==================== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.sidebar-collapsed {
        width: var(--sidebar-width);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    .content-body {
        padding: 18px 14px;
    }
    .topbar {
        padding: 0 16px;
    }
    .stat-card .value {
        font-size: 1.2rem;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .sidebar, .topbar, .footer-text, .no-print, .btn, .flash-container {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    .content-body {
        padding: 0 !important;
    }
    body {
        background: #ffffff !important;
    }
    .card-custom {
        border: none !important;
        box-shadow: none !important;
    }
}
