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

:root {
    --primary: #1a472a;
    --primary-light: #2d6b43;
    --accent: #d45d31;
    --accent-hover: #b84a26;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --sidebar-width: 280px;
    --header-height: 70px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-family: 'Playfair Display', serif;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1a472a 0%, #0f2a1a 100%); /* Premium Gradient */
    color: white;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.25rem;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.15);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
    background: #f8fafc;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.dashboard-container.collapsed .sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
}

.dashboard-container.collapsed .main-content {
    margin-left: 80px;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo img {
    height: 45px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.sidebar-logo span {
    font-size: 1rem;
    font-weight: 800;
    transition: opacity 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: white;
    text-align: center;
}

.dashboard-container.collapsed .sidebar-logo span,
.dashboard-container.collapsed .nav-link span {
    display: none;
}

.dashboard-container.collapsed .nav-link {
    justify-content: center;
    padding: 0.8rem;
}

.dashboard-container.collapsed .nav-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    margin: 0.15rem 0;
    border: 1px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(8px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -1.25rem;
    top: 20%;
    height: 60%;
    width: 6px;
    background: var(--accent);
    border-radius: 0 10px 10px 0;
    box-shadow: 2px 0 15px var(--accent);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .nav-link:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Main Content */

.top-bar {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 2rem;
    color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    background: white;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stat-trend {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

/* Sections */
.dashboard-section {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
    width: 100%;
}

canvas {
    max-height: 300px !important;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title h2 {
    font-size: 1.5rem;
}

.month-tabs-container {
    display: flex;
    gap: 0.2rem;
    overflow-x: auto;
    margin-top: 1rem;
    border-bottom: 1px solid #e2e8f0;
    max-width: 100%;
}

.month-tab {
    padding: 0.6rem 1.2rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-bottom: 0.5rem;
}

.month-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0fdf4;
}

.month-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(22, 101, 52, 0.2);
    transform: translateY(-1px);
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8); /* Solid dark backdrop */
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1.5rem;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    padding: 3rem;
    border-radius: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalScaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
    from { transform: scale(0.95) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-content .section-title {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-content h2 {
    font-size: 1.8rem;
    color: var(--primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: 2px solid #f1f5f9;
    border-radius: 0.8rem;
    font-family: inherit;
    font-size: 1rem;
    color: #1e293b;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.form-group input:focus, 
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    background: white;
    box-shadow: 0 0 0 4px rgba(22, 101, 52, 0.1);
}

/* Custom File Upload Styling */
input[type="file"]::file-selector-button {
    background: #e2e8f0;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    color: #475569;
    cursor: pointer;
    margin-right: 1rem;
    transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
    background: #cbd5e1;
}

.modal-content .btn-primary {
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(22, 101, 52, 0.2);
}

/* Adjust Dashboard Content to fill space */
.main-content {
    flex: 1;
    padding: 2rem;
    background: #f8fafc;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
}

.view {
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 1rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
}

.ledger-table tbody tr:hover {
    background: #f8fafc;
}

.ledger-table tfoot tr:first-child td {
    border-top: 2px solid #e2e8f0;
}

.ledger-table #ledgerNetBalance {
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.status-pill {
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-approved {
    background: #dcfce7;
    color: #166534;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

/* Buttons & Links */
.btn-link {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-link:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.btn-link:active {
    transform: scale(0.9);
}

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

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

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

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

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

/* Utility */
.text-primary {
    color: var(--primary);
}

.text-accent {
    color: var(--accent);
}

@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 2rem 0.5rem;
    }

    .sidebar-logo span,
    .nav-link span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
    }
}

/* Mobile overlay backdrop */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 42, 26, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Base data-table-wrapper rules */
.data-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        width: 280px !important;
        max-width: 80%;
        height: 100vh;
        z-index: 1050;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.25);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.active {
        transform: translateX(0);
        display: flex !important;
    }

    .sidebar-logo span,
    .nav-link span {
        display: inline-block !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
        width: 100%;
        overflow-x: hidden;
    }

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

    .dashboard-container.collapsed .sidebar {
        width: 280px !important;
        padding: 2.5rem 1.25rem;
    }

    /* Table horizontal scroll adjustments */
    .data-table {
        min-width: 750px; /* Prevent table content from cramming on small viewports */
    }

    /* Adjust page headings & spacing on phone views */
    .header-bar {
        padding: 1rem 0.5rem;
        gap: 0.5rem;
    }

    .header-bar h1, #viewTitle {
        font-size: 1.3rem !important;
    }

    /* Scale margins and grid panels */
    .dashboard-grid, .stats-grid, .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Hide non-essential column texts or fields on mobile */
    .user-profile span {
        display: none !important; /* Only display user initial badge */
    }
}
/* Switch Styling for Maintenance Mode */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: white;
    color: var(--text-dark);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 5px solid var(--primary);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-notification.success {
    border-left-color: #22c55e;
}

.toast-notification.warning {
    border-left-color: #f59e0b;
}

.toast-notification.error {
    border-left-color: #ef4444;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 500;
}

.toast-content i {
    font-size: 1.2rem;
}

.toast-notification.success i { color: #22c55e; }
.toast-notification.warning i { color: #f59e0b; }
.toast-notification.error i { color: #ef4444; }
