/* ==================== CSS Variables ==================== */
:root {
    --primary-color: #4f46e5;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
}

/* ==================== Global Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-light);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Ensure Bootstrap Icons load properly */
.bi::before {
    font-family: "bootstrap-icons" !important;
    font-style: normal;
    font-weight: normal !important;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== Sidebar ==================== */
.sidebar {
    background: var(--bg-white);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    padding: 1.5rem;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

.sidebar .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
}

.sidebar .nav-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    font-weight: 500;
}

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

.sidebar .nav-item.active {
    background: var(--primary-color);
    color: white;
}

.sidebar .user-profile {
    position: absolute;
    bottom: 2rem;
    left: 1.5rem;
    right: 1.5rem;
}

.sidebar .user-card {
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 8px;
}

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

/* ==================== Main Content ==================== */
.main-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* ==================== Header ==================== */
.header {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
}

.header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header p {
    margin: 0.25rem 0 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ==================== Cards ==================== */
.stat-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid #e5e7eb;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.stat-card .label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card .change {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chart-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid #e5e7eb;
    margin-bottom: 2rem;
}

.chart-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* ==================== Colors ==================== */
.positive { color: var(--success-color); }
.negative { color: var(--danger-color); }
.neutral { color: var(--warning-color); }

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

/* ==================== Alerts ==================== */
.alert-box {
    border-left: 4px solid;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #f0fdf4;
    border-color: var(--success-color);
    color: #166534;
}

.alert-success::before {
    content: "\F26A";
    font-family: "bootstrap-icons";
    font-size: 1rem;
}

.alert-warning {
    background: #fffbeb;
    border-color: var(--warning-color);
    color: #92400e;
}

.alert-warning::before {
    content: "\F33A";
    font-family: "bootstrap-icons";
    font-size: 1rem;
}

.alert-danger {
    background: #fef2f2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-danger::before {
    content: "\F33A";
    font-family: "bootstrap-icons";
    font-size: 1rem;
}

.alert-error {
    background: #fef2f2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-error::before {
    content: "\F33A";
    font-family: "bootstrap-icons";
    font-size: 1rem;
}

.alert-info {
    background: #eff6ff;
    border-color: var(--info-color);
    color: #1e40af;
}

.alert-info::before {
    content: "\F431";
    font-family: "bootstrap-icons";
    font-size: 1rem;
}

/* ==================== Badges & Tags ==================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.expense-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.category-food { background: #fef3c7; color: #92400e; }
.category-transport { background: #dbeafe; color: #1e40af; }
.category-shopping { background: #fce7f3; color: #9f1239; }
.category-utilities { background: #e0e7ff; color: #3730a3; }
.category-entertainment { background: #dcfce7; color: #166534; }
.category-health { background: #fee2e2; color: #991b1b; }

/* ==================== Progress Bars ==================== */
.progress-bar-wrapper {
    background: #f1f5f9;
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s;
}

/* ==================== Expenses Table ==================== */
.expense-table {
    width: 100%;
    margin-top: 1rem;
}

.expense-table thead {
    background: var(--bg-light);
}

.expense-table th {
    padding: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: none;
    text-align: left;
}

.expense-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.expense-table tbody tr:hover {
    background: #fafbfc;
}

.expense-item {
    padding: 1rem 0;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expense-item:last-child {
    border-bottom: none;
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #4338ca;
}

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

.btn-secondary:hover {
    background: #475569;
}

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

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

.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline-secondary:hover {
    background: var(--bg-light);
}

.btn-group {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.action-btn {
    padding: 0.5rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

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

.action-btn.edit:hover {
    color: var(--primary-color);
}

.action-btn.delete:hover {
    color: var(--danger-color);
}

/* ==================== Search & Filters ==================== */
.search-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

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

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

.filter-btn-sm {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.813rem;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    display: inline-block;
}

.filter-btn-sm:hover {
    background: #ede9fe;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-btn-sm.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ==================== Modal ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ==================== Toggle Switch ==================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

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

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ==================== Login Page ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card .logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

/* ==================== Flash Messages ==================== */
.flash-messages {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    max-width: 400px;
}

.flash-message {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== Mobile Header ==================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-white);
    box-shadow: var(--card-shadow);
    z-index: 1000;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--primary-color);
}

.mobile-logo i {
    font-size: 1.5rem;
}

.mobile-user {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Hamburger Menu */
.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Overlay for mobile menu */
body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 999;
        top: 60px;
        height: calc(100vh - 60px);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 76px;
    }

    /* Hide desktop elements on mobile */
    .sidebar .logo {
        display: none;
    }

    /* Adjust nav items for mobile */
    .sidebar nav {
        padding-top: 1rem;
    }

    /* Table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Form adjustments */
    .expense-form {
        padding: 1rem;
    }

    .expense-form .row {
        margin-bottom: 1rem;
    }

    .expense-form .col-md-3 {
        margin-bottom: 0.5rem;
    }

    /* Card adjustments */
    .stat-card {
        padding: 1rem;
    }

    .chart-card {
        padding: 1rem;
    }
}

/* ==================== Utility Classes ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
