/* main.css */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary-color: #FFC107;       /* Goldish/Amber */
    --primary-hover-color: #E0A800; /* Darker Gold for hover */
    --nav-bg-color: #ffffff;        /* White background for navigation */
    --nav-text-color: #343a40;      /* Dark Charcoal for navigation text */
    --nav-link-active-bg: #ffecb3;  /* Darker Gold for active link */
    --text-color: #212529;
    --background-color: #f8f9fa;
    --expense-color: #dc3545;       /* Red */
    --income-color: #28a745;        /* Green */
    --secondary-color: #6c757d;     /* Standard Gray */
    --danger-color: #dc3545;
    --category-bg: #ffc107;         /* Yellow */
    --category-text: #000000;       /* Black */
    --category-border: #ffb300;     /* Darker Yellow Border */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    /* Prevent horizontal scroll on mobile if something overflows slightly */
    overflow-x: hidden;
}

/* =========================================
   2. TYPOGRAPHY
   ========================================= */
h1, h2, h3 {
    font-weight: 600;
    color: var(--nav-text-color);
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

/* =========================================
   3. COMPONENTS
   ========================================= */

/* --- Buttons (Standard) --- */
.btn {
    height: 38px;
    padding: 0 18px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--nav-text-color);
    font-weight: 700;
}

.btn-primary:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

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

.btn-danger:hover {
    background-color: #c82333;
}

/* HTMX Indicators */
.htmx-indicator {
    display: none;
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator {
    display: inline-block;
    opacity: 1;
    animation: fadeIn 0.5s ease-in;
}
.htmx-request.htmx-indicator {
    display: inline-block;
    opacity: 1;
}

/* Progress bar indicator */
.htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background-color: var(--primary-color);
    z-index: 9999;
    transition: width 300ms ease-out, opacity 300ms ease-out;
    opacity: 0;
}

.htmx-request .htmx-progress {
    width: 90%;
    opacity: 1;
}

/* HTMX Swapping Opacity */
.htmx-swapping {
    opacity: 0.5;
    transition: opacity 150ms ease-out;
}

#transaction-summary.htmx-request {
    opacity: 0.7;
    transition: opacity 200ms ease-in;
}

#transaction-results.htmx-request {
    opacity: 0.7;
    transition: opacity 200ms ease-in;
}

/* Material Icons Loading Fix */
.material-icons:empty {
    width: 24px;
    height: 24px;
    display: inline-block;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.spin-animation {
    animation: spin 1.5s linear infinite;
    display: inline-block;
}

/* --- Buttons (Small & Custom) --- */
.btn-sm {
    height: 31px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    border-radius: 4px;
    font-weight: 500;
}

.btn-danger-custom {
    background-color: #f8d7da; /* Light Red */
    color: #721c24;            /* Dark Red text */
    border: 1px solid #f5c6cb;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
}

.btn-subtle {
    background-color: transparent;
    color: #000000 !important;
    box-shadow: none !important;
    transform: none !important;
}

.btn-subtle-danger {
    background-color: transparent;
    color: var(--danger-color) !important;
    box-shadow: none !important;
    transform: none !important;
}

.btn-subtle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000 !important;
    transform: none !important;
    box-shadow: none !important;
}

.btn-subtle-danger:hover {
    background-color: #f8d7da;
    color: var(--danger-color) !important;
    transform: none !important;
    box-shadow: none !important;
}

.btn-subtle .material-icons {
    color: #000000 !important;
}

.btn-subtle-danger .material-icons {
    color: var(--danger-color) !important;
}

/* --- Buttons (Disabled State) --- */
.btn.btn-disabled,
.btn-primary.btn-disabled,
.btn-secondary.btn-disabled,
.btn-danger.btn-disabled {
    background-color: var(--secondary-color) !important;
    color: #f8f9fa !important;
    cursor: not-allowed !important;
    opacity: 0.65 !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* --- Form Elements --- */
select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
.form-control {
    height: 38px;
    padding: 0 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 15px;
    box-sizing: border-box;
    background-color: #fff;
    transition: border-color 0.2s;
}

select:focus,
input:focus,
.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

/* --- Hamburger Menu Icon (For Mobile Sidebar) --- */
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin-right: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    z-index: 1001; /* Ensure above overlay */
}

.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--nav-text-color);
    transition: 0.3s;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
}

.hamburger::before { transform: translateY(-7px); }
.hamburger::after { transform: translateY(7px); }


/* =========================================
   4. LAYOUT & UTILITIES
   ========================================= */

.container {
    width: 100%;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
    width: 100%;
}

.header-title-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

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

.header-extra {
    display: flex;
    align-items: center;
}

/* Wrapper for content to respect Sidebar */
.main-content {
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    /* Default spacing (will be overridden by media queries) */
    padding: 24px;
    padding-top: 88px;
    margin-left: 0;
}

/* --- Empty States --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
    background-color: #ffffff;
    border: 2px dashed #ced4da;
    border-radius: 12px;
    margin-top: 20px;
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    color: #cbd5e1;
}

.empty-state-icon .material-icons {
    font-size: inherit;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--nav-text-color);
}

.empty-state p {
    max-width: 400px;
    margin: 0 auto;
}

.empty-state.empty-state-sm {
    padding: 30px 15px;
}

.empty-state.empty-state-sm .empty-state-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

/* Utility Classes */
.mt-1 { margin-top: 5px !important; }
.mt-2 { margin-top: 10px !important; }
.mt-3 { margin-top: 15px !important; }
.mt-4 { margin-top: 25px !important; }
.mt-5 { margin-top: 40px !important; }
.mb-1 { margin-bottom: 5px !important; }
.mb-2 { margin-bottom: 10px !important; }
.mb-3 { margin-bottom: 20px !important; }
.mb-4 { margin-bottom: 30px !important; }
.mb-5 { margin-bottom: 50px !important; }
.p-1 { padding: 5px !important; }
.p-2 { padding: 10px !important; }
.p-3 { padding: 15px !important; }
.p-4 { padding: 25px !important; }
.p-5 { padding: 40px !important; }
.hidden { display: none !important; }

.mobile-only {
    display: none !important;
}

/* =========================================
   5. RESPONSIVE QUERIES
   ========================================= */

/* =========================================
   5. RESPONSIVE QUERIES
   ========================================= */

/* MOBILE ONLY (max-width: 767px) */
@media (max-width: 767px) {
    /* 1. Wrapper flush with screen edges */
    .main-content {
        padding: 0;
        padding-top: 80px;
        overflow-x: hidden;
    }

    /* 2. Container full width, no rounded corners */
    .container {
        max-width: 100%;
        width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        padding: 20px 15px;
    }

    /* 3. Typography adjustments */
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-block !important;
    }

    .header {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 10px;
        align-items: center;
    }

    .header-title-container {
        display: contents;
    }

    .header h1 {
        grid-column: 1;
        grid-row: 1;
        margin: 0;
    }

    .header-actions {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        gap: 8px;
    }

    .header-extra {
        grid-column: 1 / span 2;
        grid-row: 2;
    }

    .flex-column-mobile {
        flex-direction: column !important;
        align-items: center !important;
    }
    .flex-column-mobile > * {
        width: auto !important;
    }

    /* 4. BUTTON FIXES */
    .btn {
        padding: 0 14px;
        width: auto;
        font-size: 14px;
        margin-bottom: 5px;
    }

    .header-actions .btn {
        margin-bottom: 0;
    }

    /* Exceptions: Only make the Login/Action buttons full width if desired,
       otherwise keep them auto. If you specifically want the filter buttons
       to fit in a row, this 'width: auto' fixes it. */

    /* Optional: Ensure filter buttons stack nicely if they are too wide */
    .filter-group .btn {
        flex: 1;
    }
}

/* DESKTOP / TABLET LANDSCAPE (min-width: 768px) */
@media (min-width: 768px) {
    .main-content {
        margin-left: 330px;
        padding: 30px;
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
    }

    .menu-toggle {
        display: none;
    }
}

/* =========================================
   6. UTILITIES
   ========================================= */
.d-flex { display: flex !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-start { justify-content: flex-start !important; }
.justify-content-end { justify-content: flex-end !important; }
.btn-full-width { width: 100% !important; }

/* Alerts */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Custom Alert Styles */
.messages-container {
    z-index: 1050;
    padding: 10px 24px 0 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@media (max-width: 767px) {
    .messages-container {
        padding: 10px 15px 0 15px;
        align-items: stretch;
    }
}

.alert {
    position: relative;
    padding: 12px 45px 12px 16px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    animation: fadeInDown 0.4s ease-out;
}

/* App Modal */
.app-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.app-modal-content {
    background-color: #fefefe;
    padding: 24px;
    border: none;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.app-modal-header {
    margin-bottom: 20px;
}

.app-modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--nav-text-color);
}

.app-modal-body {
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.5;
    color: #495057;
}

.app-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.messages-container .alert {
    max-width: 400px;
    width: 100%;
}

@media (max-width: 767px) {
    .messages-container .alert {
        max-width: none;
    }
}

@keyframes fadeInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 22px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: inherit;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: translateY(-50%) scale(1.1);
}