/* style.css - Clean, compact, mobile-optimized design */

:root {
    --primary-green: #28a745;
    --primary-orange: #fd7e14;
    --dark: #212529;
    --light-bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #333333;
    --border: #dee2e6;
    --font-base: 15px;
    --font-small: 13px;
    --header-large: 26px;
    --header-small: 22px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--light-bg);
    color: var(--text);
    overflow-x: hidden;
    font-size: var(--font-base);
    line-height: 1.5;
}

.layout {
    display: flex;
    min-height: 100vh;
}

/* MOBILE HEADER - Logo centered at top */
.mobile-header {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 15px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    text-align: center;
}

.mobile-header .logo-box {
    margin-bottom: 8px;
}

.mobile-header img {
    width: 70px;
}

.mobile-header h2 {
    font-size: 18px;
    color: var(--primary-green);
    margin: 0;
}

.toggle-btn {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--primary-green);
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1999;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.logo-box {
    padding: 0 15px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
}

.logo-box img {
    width: 80px;
    margin-bottom: 8px;
}

.logo-box h2 {
    font-size: 19px;
    font-weight: 600;
    color: var(--primary-green);
    margin: 0;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: none;
    color: var(--dark);
}

.menu {
    list-style: none;
    padding: 0 12px;
    margin: 0;
    flex: 1;
}

.menu-link {
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--font-base);
    color: var(--text);
    border-radius: 10px;
    transition: all 0.2s;
}

.menu i {
    font-size: 19px;
    color: var(--primary-green);
}

.submenu-toggle {
    margin-left: auto;
    transition: transform 0.3s;
}

.menu-item.active > .menu-link,
.menu-link:hover {
    background: var(--primary-green);
    color: #fff;
}

.menu-item.active > .menu-link i,
.menu-link:hover i {
    color: #fff;
}

.menu-item.active .submenu-toggle {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f1f3f5;
    border-radius: 8px;
}

.menu-item.active .submenu {
    max-height: 300px;
    padding: 6px 0;
}

.submenu li {
    padding: 9px 12px 9px 48px;
    cursor: pointer;
    font-size: var(--font-base);
    transition: background 0.2s;
}

.submenu li:hover {
    background: var(--primary-orange);
    color: #fff;
}

/* MAIN CONTENT */
.content {
    flex: 1;
    padding: 25px;
    margin-left: 260px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

h1 {
    font-size: var(--header-large);
    font-weight: 600;
    margin-bottom: 12px;
}

.subtitle {
    font-size: var(--font-base);
    opacity: 0.7;
    margin-bottom: 20px;
}

/* FORM CARD - Compact */
.form-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    max-width: 700px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--dark);
    font-size: 14px;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: var(--font-base);
    transition: border 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(40,167,69,0.15);
}

/* BUTTONS - Compact, not full width */
.submit-btn {
    display: inline-block;
    width: auto;
    min-width: 160px;
    padding: 11px 20px;
    background: var(--primary-orange);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin: 8px 8px 8px 0;
}

.submit-btn:hover {
    background: #e96d00;
}

.submit-btn[style*="background:#6c757d"] {
    background: #6c757d !important;
}

.submit-btn[style*="background:#6c757d"]:hover {
    background: #5a6268 !important;
}

/* TABLE BUTTONS - Smaller */
.members-table td button {
    padding: 5px 10px;
    margin: 2px 3px 2px 0;
    font-size: 12px;
    border-radius: 5px;
}

/* MEMBERS TABLE */
.members-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

.members-table th, .members-table td {
    border: 1px solid var(--border);
    padding: 9px;
    text-align: left;
    vertical-align: top;
}

.members-table th {
    background: var(--primary-green);
    color: #fff;
    font-weight: 600;
}

.inactive-row {
    background: #fdf2f2;
    color: #721c24;
    opacity: 0.9;
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 992px) {
    body {
        font-size: var(--font-small);
    }

    .sidebar {
        width: 240px;
        transform: translateX(-100%);
    }

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

    .content {
        margin-left: 0;
        padding: 15px;
        padding-top: 110px; /* Space for taller mobile header */
    }

    .mobile-header {
        display: flex;
    }

    .close-btn {
        display: block;
    }

    .menu-link {
        padding: 10px 12px;
        font-size: 14px;
    }

    .menu i {
        font-size: 18px;
    }

    h1 {
        font-size: var(--header-small);
    }

    .form-card {
        padding: 18px;
        border-radius: 12px;
    }

    .form-group {
        margin-bottom: 14px;
    }

    input, select {
        padding: 9px 11px;
        font-size: 14px;
    }

    .submit-btn {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 140px;
    }

    .members-table {
        font-size: 12px;
    }

    .members-table th, .members-table td {
        padding: 6px;
    }

    .members-table td button {
        padding: 4px 8px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .mobile-header {
        padding: 10px 12px;
    }

    .mobile-header img {
        width: 60px;
    }

    .mobile-header h2 {
        font-size: 16px;
    }

    .content {
        padding: 12px;
        padding-top: 100px;
    }

    .form-card {
        padding: 15px;
    }

    .submit-btn {
        width: 100%;
        min-width: unset;
    }
}
.dashboard h1 {
    font-size: 2.2em;
    color: var(--primary-green);
    margin-bottom: 8px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.metric-card {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.metric-card h3 {
    margin: 0 0 12px;
    font-size: 1.1em;
    color: #666;
}

.metric-card h2 {
    margin: 0;
    font-size: 2.4em;
    font-weight: 700;
}

.balance-dist {
    margin-top: 15px;
    font-size: 0.95em;
    line-height: 1.6;
    color: #555;
}

.metric-link {
    margin-top: 12px;
    font-size: 0.9em;
    color: var(--primary-green);
    font-weight: 600;
}

.section-card {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.section-card h3 {
    margin: 0 0 15px;
    font-size: 1.4em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-link {
    font-size: 0.9em;
    color: var(--primary-green);
    cursor: pointer;
}

.members-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    text-align: center;
}

.members-summary .stat h2 {
    font-size: 2.2em;
    margin: 0;
}

#financial-chart {
    max-height: 400px;
    margin-top: 20px;
}

.chart-note {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    margin: 10px 0 0;
}
#financial-chart {
    width: 100% !important;
    height: 400px !important;
}

.section-card .chart-note {
    font-size: 0.9em;
    color: #666;
    margin: 10px 0 20px;
}
/* === IMPROVED MOBILE HEADER (Centered Logo + Title) === */
.mobile-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    height: 70px;
}

.mobile-header h2 {
    font-size: 19px;
    margin: 0;
    flex: 1;
    text-align: center;
}

.mobile-header .mobile-logo {
    display: none; /* Hide duplicate logo if not needed */
}

/* Better spacing when sidebar is open on mobile */
.sidebar.open ~ .content {
    margin-left: 0 !important;
}

/* === FIX OVERLAPPING CONTENT ON MOBILE === */
@media (max-width: 992px) {
    .content {
        padding-top: 90px; /* Increased from 110px → more reliable */
    }

    /* Ensure main content doesn't get hidden behind fixed mobile header */
    .page-header {
        margin-top: 10px;
    }
}

/* === MAKE TABLES MOBILE-FRIENDLY (Horizontal Scroll) === */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.members-table {
    min-width: 700px; /* Forces horizontal scroll on small screens */
    font-size: 14px;
}

@media (max-width: 480px) {
    .members-table {
        font-size: 13px;
    }
    
    .members-table th,
    .members-table td {
        padding: 8px 6px;
    }
}

/* === BETTER FORM BUTTON ALIGNMENT === */
.form-card .submit-btn {
    margin-top: 15px;
}

/* On mobile, make button full-width for easier tap */
@media (max-width: 480px) {
    .form-card .submit-btn {
        width: 100%;
        display: block;
        margin: 20px auto 0;
    }
}

/* === DASHBOARD IMPROVEMENTS === */
.metrics-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1100px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Make metric cards more balanced */
.metric-card h2 {
    font-size: 2.2em;
}

.expenses-card h2 {
    color: #dc3545;
}

/* === SETTINGS & EXPENSES PAGE IMPROVEMENTS === */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (min-width: 768px) {
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .settings-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.section-card {
    position: relative;
}

.inline-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 12px;
}

.inline-edit input {
    flex: 1;
    min-width: 160px;
}

.inline-edit button {
    white-space: nowrap;
}

/* === GENERAL UX IMPROVEMENTS === */
.required-label::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

.help-text {
    font-size: 0.9em;
    color: #666;
    margin: 8px 0 16px;
    font-style: italic;
}

.save-note {
    text-align: center;
    margin: 40px 0 20px;
    padding: 16px;
    background: #d4edda;
    border-radius: 12px;
    color: #155724;
    font-weight: 500;
}

/* Loading state */
#main-content:empty::before {
    content: "Loading...";
    display: block;
    text-align: center;
    padding: 60px;
    color: #666;
    font-size: 1.1em;
}
/* === SETTINGS PAGE IMPROVEMENTS === */
.settings-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 10px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin: 30px 0;
}

.nav-card {
    background: #fff;
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.nav-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    border-color: var(--primary-green);
}

.nav-card h3 {
    font-size: 1.4em;
    color: var(--primary-green);
    margin: 0 0 12px 0;
}

.nav-card p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
}

/* List View in Settings */
.items-list {
    min-height: 80px;
    margin-bottom: 20px;
}

.item-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 14px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 12px;
}

.item-row input {
    flex: 1;
    min-width: 180px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.item-row input[type="number"] {
    width: 140px;
}

.remove-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.remove-btn:hover {
    background: #c82333;
}

.add-btn {
    background: var(--primary-green);
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.empty-text {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 30px 0;
}

.save-status {
    text-align: center;
    padding: 18px;
    background: #d4edda;
    color: #155724;
    border-radius: 12px;
    margin: 40px 0 20px;
    font-weight: 600;
    font-size: 1.1em;
}

/* Better spacing for settings forms */
.settings-page .form-card {
    max-width: 800px;
}

/* Make inline inputs look better */
.edit-input {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 14px;
}

.edit-input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(40,167,69,0.15);
}

/* Responsive adjustments for settings grid */
@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .item-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .item-row input {
        min-width: 100%;
    }
    
    .item-row .remove-btn {
        width: 100%;
    }
}
.ledger-table th {
    background: #343a40;
    color: #fff;
    text-align: center;
}

.ledger-table td {
    text-align: left;
    vertical-align: middle;
}

.ledger-table td:nth-child(4),
.ledger-table td:nth-child(5),
.ledger-table td:nth-child(6),
.ledger-table tfoot td {
    text-align: right !important;
}

.ledger-table tfoot td {
    border-top: 3px double #dee2e6;
    font-size: 1.1em;
}
