/* Basic reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 85%; /* Reduce overall font size by 15% */
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

h1 {
    margin: -0px auto 20px auto;
    text-align: center;
    color: #2c3e50;
    font-size: 1.7em; /* Reduced from default 2em */
}

h2 {
    margin-bottom: 15px;
    color: #667d3a;
    font-size: 1.35em; /* Reduced from default 1.5em */
}

h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #667d3a;
    font-size: 1.1em; /* Reduced from 1.17em */
}

/* Header and navigation */
.main-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
    position: relative;
}

.home-link {
    color: #2c3e50;
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 15px;
    margin-top: 5px;
}

.main-nav a {
    color: #667d3a;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-weight: bold;
}

.main-nav a:hover {
    background-color: #f0f6e8;
}

.main-nav a.active {
    background-color: #667d3a;
    color: white;
}

/* Hamburger menu */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    z-index: 20;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #667d3a;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9em;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-logout {
    background: #e74c3c;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
}

.btn-profile {
    background: #667d3a;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
}

/* Footer navigation (for logout) */
.footer-navigation {
    margin-top: auto;
    padding-top: 20px;
    text-align: center;
    border-top: 1px solid #ddd;
}

/* Form styling */
.add-expense, .add-user, .add-category, .login-form, .user-profile, .user-expense-summary {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
}

/* Enhanced input and select styling for better iOS appearance */
input, select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
    background-color: #fff;
    -webkit-appearance: none; /* Removes default iOS styling */
    appearance: none; /* Standard property for removing default styling */
    color: #333;
    height: 40px; /* Slightly smaller for smaller fonts */
}

/* Custom styling for select elements to make them look like inputs */
select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path fill="%23667d3a" d="M0 0l6 6 6-6z"/></svg>');
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 12px 6px;
    padding-right: 30px; /* Make space for the arrow */
}

/* Remove focus rings on iOS */
input:focus, select:focus {
    outline: none;
    border-color: #667d3a;
}

.btn-submit {
    background: #667d3a;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    width: 100%;
    -webkit-appearance: none; /* Removes default iOS styling */
    appearance: none; /* Standard property for removing default styling */
    height: 40px;
}

.btn-submit:hover {
    background: #5a6e33;
}

/* Date shortcuts styling */
.date-shortcuts {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.date-btn {
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.85em;
    cursor: pointer;
    color: #667d3a;
    -webkit-appearance: none; /* Removes default iOS styling */
    appearance: none; /* Standard property */
}

.date-btn:hover {
    background: #eaeaea;
    border-color: #667d3a;
}

.date-btn.active {
    background: #f0f6e8;
    border-color: #667d3a;
    font-weight: bold;
}

/* Expense list styling */
.expenses-list, .users-list, .categories-list {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

th {
    background: #667d3a;
    color: #fff;
    text-align: left;
    padding: 8px;
    font-size: 0.9em;
}

td {
    padding: 8px;
    border-bottom: 1px solid #ddd;
}

tr:nth-child(even) {
    background: #f9f9f9;
}

.amount {
    font-weight: bold;
}

/* Mobile card view for expense list */
.expense-card {
    display: none; /* Hidden by default, shown only on mobile */
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.expense-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.expense-card .card-date {
    font-size: 0.85em;
    color: #777;
}

.expense-card .card-amount {
    font-weight: bold;
    font-size: 1.1em;
    color: #667d3a;
}

.expense-card .card-details {
    margin-top: 10px;
}

.expense-card .card-row {
    display: flex;
    margin-bottom: 5px;
}

.expense-card .card-label {
    font-weight: bold;
    width: 100px;
    color: #555;
    font-size: 0.9em;
}

.expense-card .card-value {
    flex: 1;
}

.expense-card .card-actions {
    margin-top: 10px;
    text-align: right;
}

.btn-edit, .btn-cancel {
    display: inline-block;
    background: #667d3a;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    text-decoration: none;
    margin-left: 8px;
}

.btn-cancel {
    background: #888;
}

.btn-edit:hover, .btn-cancel:hover {
    opacity: 0.9;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-actions .btn-submit {
    flex: 1;
}

.form-actions .btn-cancel {
    width: auto;
}

/* Category container with toggle button */
.category-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-container select {
    flex: 1;
}

.btn-toggle-category {
    width: 30px;
    height: 30px;
    background: #667d3a;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
}

.btn-toggle-category.active {
    background: #5a6e33;
    transform: rotate(45deg);
}

.btn-toggle-category:hover {
    opacity: 0.9;
}

/* Filter section styling */
.filter-section {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: nowrap;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group-half {
    flex: 1;
    min-width: 0;
}

.date-filter-container {
    display: flex;
    gap: 15px;
    flex: 1;
}

.filter-group-search {
    flex: 2;
}

.loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #667d3a;
}

.error {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding-bottom: 1px;
}

.btn-filter, .btn-reset {
    display: inline-block;
    background: #667d3a;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    text-decoration: none;
    height: 40px;
    line-height: 20px;
    -webkit-appearance: none;
    appearance: none;
}

.btn-reset {
    background: #888;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .main-header {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding-left: 40px;
        padding-right: 40px;
    }

    .menu-toggle {
        display: flex;
        margin-top: -15px;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: -250px;
        width: 250px;
        height: 100vh;
        background-color: white;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 60px 20px 20px;
        gap: 20px;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        z-index: 10;
    }

    .main-nav.active {
        left: 0;
    }

    .menu-toggle.active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

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

    .menu-toggle.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    body.menu-open {
        overflow: hidden;
    }

    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.4);
        z-index: 5;
    }

    .overlay.active {
        display: block;
    }

    .filter-row {
        flex-direction: row;
        gap: 8px;
    }

    .filter-group {
        width: 100%;
    }

    .date-filter-container {
        gap: 8px;
    }

    .filter-actions {
        flex-direction: row;
        justify-content: flex-end;
        margin-top: 0;
    }

    .btn-reset {
        width: auto;
    }

    @media (max-width: 480px) {
        .filter-row {
            flex-direction: row;
            flex-wrap: nowrap;
        }
    }
}

/* Form row for displaying fields side by side */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group-amount {
    width: 40%;
    min-width: 120px;
}

.form-group-category {
    flex: 1;
}

/* Summary page styling */
.summary-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.summary-box {
    flex: 1;
    min-width: 300px;
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.grand-total {
    font-size: 1.7em;
    color: #667d3a;
    font-weight: bold;
    margin: 15px 0;
    text-align: center;
}

.summary-table {
    width: 100%;
}

/* Mobile summary styling */
.mobile-summary {
    display: none;
}

.grand-total-mobile {
    background: #f8f8f8;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
}

.grand-total-label {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.grand-total-value {
    font-size: 1.4em;
    color: #667d3a;
    font-weight: bold;
}

.summary-card {
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px;
    margin-bottom: 10px;
}

.summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-card-title {
    font-weight: bold;
    font-size: 0.9em;
}

.summary-card-amount {
    font-weight: bold;
    color: #667d3a;
    font-size: 0.9em;
}

/* User profile styles */
.user-profile strong {
    font-weight: bold;
    margin-right: 5px;
}

.user-expense-summary {
    margin-bottom: 20px;
}

.user-expense-summary p {
    font-size: 0.9em;
}

/* Monthly breakdown styles */
.month-section {
    margin-bottom: 30px;
}

.month-header {
    font-size: 1.2em;
    color: #2c3e50;
    margin-bottom: 10px;
    border-bottom: 2px solid #667d3a;
    padding-bottom: 5px;
}

.month-total {
    font-size: 1.1em;
    margin-bottom: 15px;
    text-align: center;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 5px;
}

.category-breakdown-header {
    font-size: 1em;
    color: #667d3a;
    margin: 15px 0 10px 0;
    font-weight: bold;
}

.category-breakdown {
    margin-bottom: 15px;
    font-size: 0.9em;
}

.month-separator {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 20px 0;
}

/* Mobile monthly breakdown styles */
.mobile-month-section {
    margin-bottom: 25px;
}

.mobile-category-header {
    font-size: 0.9em;
    color: #667d3a;
    margin: 10px 0 5px 0;
    font-weight: bold;
}

.category-card {
    margin-left: 15px;
    margin-bottom: 5px;
    background: #f8f8f8;
}

.mobile-month-separator {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 15px 0;
}

/* Login specific styles */
.login-form {
    max-width: 400px;
    margin: 40px auto;
}

.error-message {
    color: #e74c3c;
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.9em;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    input, select {
        font-size: 16px; /* Keep this at 16px to prevent iOS zoom on input focus */
    }
    
    /* Hide the regular table on mobile */
    .expenses-list table, 
    .expenses-list thead, 
    .expenses-list tbody, 
    .expenses-list th, 
    .expenses-list td, 
    .expenses-list tr {
        display: none;
    }
    
    /* Show the card view instead */
    .expense-card {
        display: block;
    }
    
    .date-shortcuts {
        justify-content: space-between;
    }
    
    .date-btn {
        padding: 8px;
        flex: 1;
        text-align: center;
    }
    
    /* Summary page mobile view */
    .summary-container {
        display: none;
    }
    
    .mobile-summary {
        display: block;
    }
}

/* iOS specific styles */
@supports (-webkit-touch-callout: none) {
    /* Apply these styles only on iOS devices */
    select {
        background-color: #ffffff;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path fill="%23667d3a" d="M0 0l6 6 6-6z"/></svg>');
    }
    
    input[type="date"] {
        min-height: 40px;
        line-height: normal;
    }
}