/* ============================================
   Mobile-First Budget App Stylesheet
   ============================================ */

/* ============================================
   1. CSS Variables (Design Tokens)
   ============================================ */
:root {
    /* Colors - Modern, Vibrant Palette */
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --success-color: #22c55e;

    /* Neutral Colors */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Touch Targets */
    --touch-target-min: 44px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
}

/* ============================================
   2. Base & Typography
   ============================================ */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    /* Prevent zoom on mobile */
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
    padding-bottom: env(safe-area-inset-bottom);
    /* Safe area for notched phones */
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

/* ============================================
   3. Mobile-Optimized Container
   ============================================ */
.mobile-container {
    padding: var(--spacing-md);
    max-width: 100%;
    padding-bottom: 80px;
    /* Space for bottom nav */
}

@media (min-width: 768px) {
    .mobile-container {
        padding: var(--spacing-lg);
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* ============================================
   4. Cards - Modern, Touch-Friendly
   ============================================ */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-normal);
    margin-bottom: var(--spacing-md);
}

.card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.card-body {
    padding: var(--spacing-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Project Cards - Enhanced for Mobile */
.project-card {
    position: relative;
    cursor: pointer;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.project-card .card-link {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
}

/* ============================================
   5. Buttons - Large, Touch-Optimized
   ============================================ */
.btn {
    min-height: var(--touch-target-min);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-danger {
    background: transparent;
    border: 2px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-lg {
    min-height: 56px;
    font-size: 1.125rem;
    padding: 16px 32px;
}

.btn-sm {
    min-height: 36px;
    font-size: 0.875rem;
    padding: 8px 16px;
}

.btn-block {
    width: 100%;
    display: flex;
}

/* Floating Action Button (FAB) */
.fab {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom));
    right: var(--spacing-md);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 1.5rem;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 1000;
    transition: all var(--transition-normal);
    display: flex;
    justify-content: center;
    align-items: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.3);
}

.fab:active {
    transform: scale(0.95);
}

@media (min-width: 768px) {
    .fab {
        bottom: var(--spacing-xl);
    }
}

/* ============================================
   6. Bottom Navigation Bar (Mobile)
   ============================================ */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    gap: var(--spacing-sm);
}

.bottom-nav .btn {
    flex: 1;
    box-shadow: none;
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none;
        /* Hide on desktop */
    }
}

/* ============================================
   7. Forms - Mobile-Optimized
   ============================================ */
.form-control,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
    min-height: var(--touch-target-min);
    padding: 12px 16px;
    font-size: 16px;
    /* Prevent zoom on iOS */
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    transition: all var(--transition-fast);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

/* Mobile-friendly checkboxes */
.form-check {
    padding: var(--spacing-sm) 0;
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
}

.form-check-input {
    width: 24px;
    height: 24px;
    margin-right: var(--spacing-sm);
    margin-right: var(--spacing-sm);
    cursor: pointer;
    flex-shrink: 0;
}

.form-check-label {
    font-size: 1rem;
    cursor: pointer;
    flex: 1;
}

/* ============================================
   8. Tables to Cards (Mobile)
   ============================================ */
@media (max-width: 767px) {
    .table-responsive {
        display: block;
    }

    .mobile-hidden-table {
        display: none !important;
    }

    .expense-card {
        background: var(--surface-color);
        border-radius: var(--radius-md);
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-md);
        border-left: 4px solid var(--primary-color);
        box-shadow: var(--shadow-sm);
    }

    .expense-card-header {
        display: flex;
        justify-content: space-between;
        align-items: start;
        margin-bottom: var(--spacing-sm);
    }

    .expense-card-title {
        font-weight: 700;
        font-size: 1.125rem;
        color: var(--text-primary);
    }

    .expense-card-amount {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--primary-color);
    }

    .expense-card-meta {
        display: flex;
        gap: var(--spacing-md);
        color: var(--text-secondary);
        font-size: 0.875rem;
        margin-bottom: var(--spacing-sm);
    }

    .expense-card-actions {
        display: flex;
        gap: var(--spacing-sm);
        margin-top: var(--spacing-md);
    }
}

/* ============================================
   9. Stats Cards (Dashboard)
   ============================================ */
.stats-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stats-card-label {
    font-size: 0.875rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
}

.stats-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

/* ============================================
   10. List Groups
   ============================================ */
.list-group-item {
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    transition: background var(--transition-fast);
}

.list-group-item:hover {
    background: var(--bg-color);
}

/* ============================================
   11. Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-info {
    background: var(--info-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

/* ============================================
   12. Loading States
   ============================================ */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   13. Utility Classes
   ============================================ */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: var(--spacing-xs);
}

.mb-2 {
    margin-bottom: var(--spacing-sm);
}

.mb-3 {
    margin-bottom: var(--spacing-md);
}

.mb-4 {
    margin-bottom: var(--spacing-lg);
}

.mt-3 {
    margin-top: var(--spacing-md);
}

.mt-4 {
    margin-top: var(--spacing-lg);
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.gap-2 {
    gap: var(--spacing-sm);
}

.w-100 {
    width: 100%;
}

/* ============================================
   14. Responsive Grid
   ============================================ */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}

.col,
[class*="col-"] {
    padding: 0 8px;
    /* width: 100%;  -- Removed to let Bootstrap handle grid widths (like col-6 = 50%) */
}

/* Ensure col-6 works as expected on mobile */
.col-6 {
    width: 50%;
}

@media (min-width: 768px) {
    .col-md-4 {
        width: 33.333%;
    }

    .col-md-6 {
        width: 50%;
    }

    .col-md-8 {
        width: 66.666%;
    }

    .col-md-10 {
        width: 83.333%;
    }

    .col-md-12 {
        width: 100%;
    }
}

/* ============================================
   15. Navbar - Mobile Optimized
   ============================================ */
.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    color: white !important;
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
}

/* ============================================
   16. Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn var(--transition-normal);
}

/* ============================================
   17. Safe Area (Notched Phones)
   ============================================ */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
    }
}

/* ============================================
   18. Logo Styles
   ============================================ */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.logo-text {
    font-weight: 800;
    font-size: 1.25rem;
    color: white;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Login Page Logo Variation */
.login-logo-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1rem;
}