/* --- Global Styles & Variables --- */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-gradient: linear-gradient(90deg, #4f46e5 0%, #6366f1 100%);
    --secondary-color: #f8f9fa; /* Lighter background */
    --border-color: #e5e7eb;
    --text-color: #1f2937; /* Darker text */
    --text-light: #6b7280;
    --white: #ffffff;
    --danger: #ef4444;
    --success: #16a34a; /* Darker green */
    --warning: #f59e0b;
    --font-family: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.75rem; /* Slightly more rounded */
}

/* === Global Reset / Body Fix === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html, body {
    height: 100%;
}
body {
    font-family: var(--font-family);
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;   /* 🔥 Prevent horizontal scroll */
    margin: 0;            /* 🔥 Remove unwanted margins */
}

/* --- Authentication Pages (Login/Register) --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--primary-gradient);
}

.auth-card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth-card h2 { margin-top: 0; font-size: 2rem; font-weight: 700; }
.auth-card p { color: var(--text-light); margin-bottom: 2rem; }

.auth-switch { margin-top: 1.5rem; font-size: 0.9rem; }
.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }

/* --- Form Elements --- */
.form-group { margin-bottom: 1.5rem; text-align: left; }
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-grid .span-2 { grid-column: span 2; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease-in-out;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.btn-primary { background: var(--primary-gradient); color: var(--white); }
.btn-primary:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.btn-block { width: 100%; }
.btn-secondary {
    background-color: var(--white);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--secondary-color);
    border-color: #d1d5db;
}
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }

/* --- Alerts --- */
.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
}
.alert-danger { color: #991b1b; background-color: #fee2e2; border-color: #fecaca; }
.alert-success { color: #14532d; background-color: #dcfce7; border-color: #bbf7d0; }
.alert-warning { color: #92400e; background-color: #fef3c7; border-color: #fde68a; }
.alert a { font-weight: 600; color: inherit; }

/* --- Main App Layout --- */
.app-container { display: flex; }
.sidebar {
    width: 260px;
    background: var(--white);
    min-height: 100vh;
    border-right: 1px solid var(--border-color);
    position: fixed;
    transition: transform 0.3s ease;
}
.sidebar-header { padding: 1.75rem 1.5rem; border-bottom: 1px solid var(--border-color); }
.sidebar-header h3 { margin: 0; color: var(--text-color); font-size: 1.5rem; }
.sidebar ul { list-style-type: none; padding: 0; margin: 1.5rem 0; }
.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.5rem;
    margin: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}
.sidebar ul li.active a,
.sidebar ul li a:hover {
    background: #eef2ff;
    color: var(--primary-color);
}
.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 2.5rem;
    min-width: 0; /* 🔥 Fix flex overflow causing scroll */
}
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; }
.main-header h1 { margin: 0; font-size: 2.25rem; font-weight: 800; }
.user-info { font-weight: 500; }

/* --- Content Cards & Stats --- */
.content-card {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2.5rem;
}
.content-card h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}
.stat-card h4 { margin: 0 0 0.5rem 0; color: var(--text-light); font-weight: 600; }
.stat-card p { margin: 0; font-size: 2.5rem; font-weight: 800; color: var(--text-color); }
.stat-card p.positive { color: var(--success); }
.stat-card p.negative { color: var(--danger); }

/* --- Tables --- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
thead th {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tbody tr:hover { background-color: #f9fafb; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-success { color: var(--success); font-weight: 600; }
.badge { padding: 0.3em 0.7em; font-size: 75%; font-weight: 700; border-radius: 9999px; }
.badge-expense { background-color: #fee2e2; color: #991b1b; }
.badge-transfer { background-color: #dcfce7; color: #14532d; }

/* --- Tabs --- */
.tab-nav {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  border-bottom: 1px solid #ddd;
  padding: 5px 0;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-link {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 6px;
  background: #f8f8f8;
  white-space: nowrap;
}
.tab-link.active { background: #007bff; color: #fff; }
.tab-nav a.active, .tab-nav a:hover { color: #fff; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* --- Filters & Reports --- */
/* .filter-form { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-end; margin-bottom: 2rem; }
.filter-form label { font-weight: 600; font-size: 0.9rem; }
.filter-form select,
.filter-form input { margin-top: 0.25rem; padding: 0.5rem; }
.report-period { color: var(--text-light); font-size: 0.9rem; margin-top: -1rem; margin-bottom: 1.5rem; } */
.filter-form select,
.filter-form input[type="date"] {
    width: 100%;
    padding: 14px 16px; /* Bigger padding for mobile */
    font-size: 1rem;    /* Larger font */
    border: 1px solid #ccc;
    border-radius: 10px;
    outline: none;
    background-color: #fff;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.filter-form select:focus,
.filter-form input[type="date"]:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 6px rgba(79, 70, 229, 0.4);
}

/* Labels */
.filter-form label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 6px;
    color: #333;
}

/* Filter buttons */
.filter-form button {
    width: 100%; /* Full width on mobile */
    padding: 14px 0;
    border: none;
    border-radius: 10px;
    background-color: #4f46e5;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 0.5rem;
}

.filter-form button:hover {
    background-color: #3730a3;
}






/* --- Mobile Navigation --- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 15px rgba(0,0,0,0.08);
    z-index: 1000;
}
.mobile-nav ul {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    width: 100%;
}
.mobile-nav ul li:nth-child(3) {
    grid-column: 3;  /* 🔥 force Add button in middle */
    display: flex;
    justify-content: center;
}
.mobile-nav ul li a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 600;
    padding: 0.25rem;
    transition: all 0.2s ease;
}
.mobile-nav ul li a i { font-size: 1.5rem; margin-bottom: 0.2rem; width: 28px; }
.mobile-nav ul li a span { font-size: 0.65rem; }

/* Central Add button */
.mobile-nav ul li a.add-btn {
    background: var(--primary-gradient);
    color: var(--white);
    width: 56px; height: 56px;
    border-radius: 50%;
    transform: translateY(-20px);
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--white);
}
.mobile-nav ul li a.add-btn:hover { transform: translateY(-22px) scale(1.05); }
.mobile-nav ul li a.add-btn i { font-size: 1.75rem; margin: 0; }
.mobile-nav ul li a.add-btn span { display: none; }
.mobile-nav ul li.active a { color: var(--primary-color); }
.mobile-nav ul li.active a:not(.add-btn) { transform: translateY(-2px); }

/* --- Responsive --- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); z-index: 1100; }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem 1.5rem 6.5rem; /* 🔥 prevent overlap with mobile nav */
    }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .mobile-nav { display: block; }
}
@media (max-width: 768px) {
    .main-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .main-header h1 { font-size: 1.75rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }

    /* Table → Card */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr { display: block; width: 100%; }
    .table-responsive thead { display: none; }
    .table-responsive tr {
        margin-bottom: 12px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 10px;
        background: #fff;
    }
    .table-responsive td {
        display: flex;
        justify-content: space-between;
        padding: 6px 8px;
        font-size: 14px;
    }
    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #555;
        flex: 1;
        margin-right: 10px;
    }
    


    .filter-form {
        padding: 1rem;
    }

    .filter-form select,
    .filter-form input[type="date"] {
        font-size: 1.05rem;
        padding: 16px;
    }

    .filter-form label {
        font-size: 1.05rem;
    }

    .stats-grid,
    .content-card {
        width: 100%;
        margin-bottom: 1.5rem;
    }


}
