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

/* =====================================================
   SIDEBAR
===================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: var(--z-sidebar);
    transition: transform 0.3s ease, width 0.3s ease;
    overflow: hidden;
}

/* Collapsed state */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-footer-user,
.sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .nav-item i { margin: 0; }
.sidebar.collapsed .sidebar-section-label { display: none; }

/* Sidebar Header */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.logo-container { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.logo-icon-wrap {
    width: 34px; height: 34px;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-brand);
}
.logo-text {
    font-family: var(--font-heading);
    font-weight: var(--weight-bold);
    font-size: 1.15rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    transition: opacity 0.2s, width 0.2s;
}

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: var(--space-3) 0; overflow-y: auto; }

.sidebar-section-label {
    padding: var(--space-5) var(--space-5) var(--space-2);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-5);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    border-left: 3px solid transparent;
    transition: var(--transition-fast);
    cursor: pointer;
    position: relative;
    text-decoration: none;
}
.nav-item i { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { flex: 1; white-space: nowrap; transition: opacity 0.2s; }
.nav-badge {
    background: var(--error);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--weight-bold);
    padding: 2px 7px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.nav-item:hover  { background: var(--primary-50); color: var(--primary-brand); border-left-color: var(--primary-200); }
.nav-item.active { background: var(--primary-50); color: var(--primary-brand); border-left-color: var(--primary-brand); font-weight: var(--weight-semibold); }

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}
.sidebar-footer-user { flex: 1; min-width: 0; transition: opacity 0.2s; }
.sidebar-footer-user .user-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); truncate: true; }
.sidebar-footer-user .user-role { font-size: var(--text-xs); color: var(--text-muted); }

/* =====================================================
   MAIN CONTENT
===================================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

/* =====================================================
   HEADER
===================================================== */
.header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: var(--space-4); }
.header-right { display: flex; align-items: center; gap: var(--space-3); }

.menu-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}
.menu-btn:hover { background: var(--bg-main); color: var(--text-main); }

.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-main);
    padding: 9px 16px;
    border-radius: var(--radius-full);
    width: 280px;
    border: 1.5px solid transparent;
    transition: var(--transition-fast);
}
.search-bar:focus-within { border-color: var(--primary-200); background: var(--bg-white); box-shadow: 0 0 0 4px rgba(37,99,235,0.06); }
.search-bar i { color: var(--text-light); font-size: 1rem; flex-shrink: 0; }
.search-bar input { background: transparent; border: none; font-size: var(--text-sm); color: var(--text-main); width: 100%; }
.search-bar input::placeholder { color: var(--text-light); }

.header-icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    transition: var(--transition-fast);
    border: none;
    font-size: 1.1rem;
}
.header-icon-btn:hover { background: var(--bg-main); color: var(--primary-brand); }

.header-divider { width: 1px; height: 24px; background: var(--border-light); }

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 6px 6px 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition-fast);
    background: transparent;
}
.user-profile-btn:hover { background: var(--bg-main); border-color: var(--border-color); }
.user-profile-info { text-align: left; }
.user-profile-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-main); line-height: 1.2; }
.user-profile-role { font-size: var(--text-xs); color: var(--text-muted); }

/* Header Wallet Card */
.header-wallet-card {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    padding: 4px;
    padding-left: 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition-fast);
    gap: 12px;
}
.header-wallet-card:hover { background: var(--primary-50); border-color: var(--primary-200); }

.wallet-info { display: flex; flex-direction: column; }
.wallet-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; line-height: 1; margin-bottom: 2px; }
.wallet-amount { font-size: 0.95rem; font-weight: 700; color: var(--primary-brand); line-height: 1; }

.add-money-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-brand);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-brand-sm);
}
.add-money-btn:hover { background: var(--primary-600); transform: translateY(-1px); }

.notif-badge {
    position: absolute;
    top: 0; right: 0;
    width: 16px; height: 16px;
    background: var(--error);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-white);
}

.dropdown-header { padding: 12px 16px; background: var(--bg-main); border-bottom: 1px solid var(--border-light); }

/* =====================================================
   CONTENT AREA
===================================================== */
.content-body {
    padding: var(--space-8);
    max-width: var(--content-max-width);
    width: 100%;
    flex: 1;
    animation: fadeUp 0.35s ease;
}

.page-header { margin-bottom: var(--space-6); }
.page-title  { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--text-main); margin-bottom: 4px; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-muted); }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

/* =====================================================
   GRID LAYOUTS
===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: var(--space-5);
    align-items: start;
}

.content-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
}

.sidebar-col { display: flex; flex-direction: column; gap: var(--space-5); }

/* =====================================================
   SIDEBAR OVERLAY (mobile)
===================================================== */
.sidebar-overlay {
    position: fixed; inset: 0;
    background: var(--bg-overlay);
    z-index: calc(var(--z-sidebar) - 1);
    display: none;
    animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active { display: block; }

/* =====================================================
   RESPONSIVE — Tablet
===================================================== */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid { grid-template-columns: 1fr; }
    .content-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .content-body { padding: var(--space-5); }
    .stats-grid { gap: var(--space-4); }
}

/* =====================================================
   RESPONSIVE — Mobile
===================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        box-shadow: var(--shadow-2xl);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { transform: translateX(-100%); }

    .main-content { margin-left: 0 !important; }

    .header { padding: 0 var(--space-4); }
    .search-bar { display: none; }

    .content-body { padding: var(--space-4); }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
    .content-grid { grid-template-columns: 1fr; }
    .content-grid-3 { grid-template-columns: 1fr; }

    .page-header-row { flex-direction: column; }
    .page-actions { width: 100%; justify-content: flex-end; }

    .form-row { grid-template-columns: 1fr; }

    .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 100%; align-self: flex-end; }
    .modal-backdrop { align-items: flex-end; padding: 0; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-title { font-size: var(--text-xl); }
}
