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

:root {
    --bg-main: #f5f3f0;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #faf8f6;
    --border: #e8e2da;
    --border-hover: rgba(123, 31, 58, 0.3);

    --text-primary: #1c1017;
    --text-secondary: #6b5e68;
    --text-muted: #9e8f96;

    --primary: #7B1F3A;
    --primary-hover: #611730;
    --primary-glow: rgba(123, 31, 58, 0.18);
    --primary-light: #f6eaee;

    --success: #0d7c54;
    --success-bg: #e8f7f0;
    --success-border: #b6e2cd;

    --danger: #c4233b;
    --danger-bg: #fdedef;
    --danger-border: #f3bac2;

    --warning: #b5850d;
    --warning-bg: #fdf6e3;
    --warning-border: #f0dda0;

    --info: #2563a8;
    --info-bg: #e9f1fb;
    --info-border: #b3d0f0;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Global Reset & Base ────────────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #cdc4be;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ─── Typography & Helpers ───────────────────────────────────────────────────── */
a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

button, input, select, textarea {
    font-family: inherit;
    color: inherit;
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* ─── Layout: Sidebar & Content ─────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 24px 16px;
    box-shadow: 2px 0 18px rgba(123, 31, 58, 0.04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
    padding: 0 12px;
}

.brand svg {
    color: var(--primary);
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.nav-item a:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

.nav-item.active a {
    color: var(--primary);
    background: linear-gradient(135deg, rgba(123, 31, 58, 0.1), rgba(123, 31, 58, 0.04));
    border-left: 3px solid var(--primary);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #a8344f);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
    padding: 40px;
}

/* Header & Title bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ─── UI Cards & Panels ──────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px rgba(123, 31, 58, 0.07);
}

.grid-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-light);
    border: 1px solid rgba(123, 31, 58, 0.12);
}

.kpi-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.kpi-data {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Charts Grid */
.grid-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    min-height: 340px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Overspend alerts ───────────────────────────────────────────────────────── */
.alerts-section {
    margin-bottom: 32px;
}

.alert {
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }

/* ─── Forms styling ─────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: #ffffff;
}

/* File upload zone */
.file-upload-wrapper {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #fdfcfa;
}

.file-upload-wrapper:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.file-upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Colors palette picker */
.color-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.color-option.selected {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-secondary {
    background-color: #f0ebe7;
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #e5ddd6;
}

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

/* ─── Lists & Tables ────────────────────────────────────────────────────────── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    background: #faf8f6;
}

tr:hover td {
    background-color: var(--primary-light);
}

/* Status badge components */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-approved { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-active { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.badge-archived { background: #f0ebe7; color: var(--text-secondary); border: 1px solid var(--border); }

/* Account Badges */
.account-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.account-badge i, .account-badge svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}
.account-cash {
    background: rgba(16, 185, 129, 0.1);
    color: #0d7c54;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.account-bank {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Filters styling bar */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.filters-bar .form-control {
    width: auto;
    min-width: 160px;
}

/* ─── Modal View ────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(28, 16, 23, 0.55);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    box-shadow: 0 20px 60px rgba(123, 31, 58, 0.15);
}

@keyframes modalScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-close {
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--primary);
}

.receipt-preview {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 12px;
}

/* ─── Authentication Page Styles ────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #f5f3f0 0%, #f6eaee 50%, #f5f3f0 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    box-shadow: 0 12px 48px rgba(123, 31, 58, 0.1);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--primary);
}

.auth-logo svg {
    color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

/* ─── Responsive Styles ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    .filters-bar .form-control {
        width: 100%;
    }
}

/* ─── Print View Stylesheet ─────────────────────────────────────────────────── */
@media print {
    body {
        background: white;
        color: black;
    }
    .sidebar, .top-bar .btn, .filters-bar, .modal, .logout-btn, .table th.th-actions, .table td.td-actions {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 0 !important;
    }
    table {
        border-collapse: collapse;
        color: black;
    }
    th, td {
        border-bottom: 1px solid #ddd !important;
        color: black !important;
    }
    th {
        font-weight: bold;
    }
    h1, h2, h3 {
        color: black !important;
    }
}
