/* Complete updated styles - REPLACE your entire style.css with this */

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

:root {
    --primary: #3498db;
    --secondary: #95a5a6;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --white: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary), #2980b9);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card h2 {
    color: var(--dark);
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 600;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.dashboard-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.dashboard-card h3 {
    color: var(--dark);
    margin-bottom: 10px;
    font-size: 20px;
}

.dashboard-card p {
    color: #7f8c8d;
    margin-bottom: 15px;
}

.dashboard-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

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

.btn-primary:hover {
    background: #2980b9;
}

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

.btn-secondary:hover {
    background: #7f8c8d;
}

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

.btn-danger:hover {
    background: #c0392b;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

select {
    background-color: white;
    cursor: pointer;
}

textarea {
    font-family: inherit;
    resize: vertical;
}

/* Search Wrapper */
.search-wrapper {
    position: relative;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e0e6ed;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
}

/* Keyboard navigation highlighting */
.suggestion-item {
    padding: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:hover,
.suggestion-item.suggestion-active {
    background: #e3f2fd;
    border-left: 3px solid var(--primary);
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* List Container */
.list-container {
    margin-top: 20px;
}

.list-item {
    background: white;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease;
}

.list-item:hover {
    border-color: var(--primary);
}

.list-item-content h3 {
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 18px;
}

.list-item-content p {
    color: #7f8c8d;
    margin-bottom: 5px;
    font-size: 14px;
}

.list-item-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* Meta grid for detailed umedwaar */
.list-item-detailed {
    background: white;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.meta-item {
    font-size: 14px;
    color: #555;
}

.meta-item strong {
    color: var(--dark);
    font-weight: 600;
}

.list-item-simple {
    padding: 10px 15px;
    border-left: 3px solid var(--primary);
    background: #f8f9fa;
    margin-bottom: 8px;
    border-radius: 4px;
}

.list-item-simple-with-delete {
    padding: 12px 15px;
    border-left: 3px solid var(--primary);
    background: #f8f9fa;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.list-item-simple-with-delete span {
    flex: 1;
}

/* Category Box */
.category-box {
    border: 2px solid #e0e6ed;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
}

.category-box-header {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-box-header h3 {
    margin: 0;
    font-size: 18px;
}

.category-box-content {
    padding: 20px;
}

.items-list {
    margin-top: 15px;
}

.expense-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--success);
}

.expense-item small {
    display: block;
    color: #7f8c8d;
    margin-top: 3px;
}

/* Category Group */
.category-group {
    margin-bottom: 30px;
}

.category-title {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

/* Expense Display */
.expense-category {
    margin-bottom: 25px;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 15px;
}

.expense-category h3 {
    color: var(--primary);
    margin-bottom: 15px;
}

.expense-item-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
}

.expense-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.expense-item-details {
    flex: 1;
    min-width: 0;
}

.expense-item-details strong {
    display: block;
    color: var(--dark);
    margin-bottom: 5px;
}

.expense-item-details span {
    display: block;
    color: #7f8c8d;
    font-size: 14px;
}

.expense-item-details small {
    display: block;
    color: #95a5a6;
    font-size: 12px;
    margin-top: 3px;
}

.expenses-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

/* Animations (kept for modal effects) */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
    font-size: 18px;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--warning);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
}

/* Total Display */
.total-display {
    background: #f8f9fa !important;
    font-weight: 600;
    font-size: 16px;
    color: var(--success);
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 32px;
}

.login-box h2 {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 30px;
    font-size: 16px;
    font-weight: normal;
}

.error-message {
    background: #fee;
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

/* ================================
   COMPLETE MODAL FIX - FINAL
   ================================ */

/* Modal - ABSOLUTELY FINAL FIX FOR SCROLLING */
.modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease;
    overflow-y: scroll !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
}

.modal-content {
    background-color: white;
    margin: 20px auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideDown 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-large .modal-content {
    max-width: 700px;
}

.modal-scrollable .modal-content {
    margin: 20px auto;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    color: #000;
}

/* Ensure body doesn't scroll when modal is open */
body.modal-open {
    overflow: hidden;
    height: 100vh;
}

/* Mobile modal fixes */
@media (max-width: 768px) {
    .modal {
        padding: 10px 0;
    }

    .modal-content {
        width: 95%;
        margin: 10px auto;
        padding: 20px 15px;
        max-height: none;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        padding: 20px 15px 40px;
    }

    .modal-close {
        right: 15px;
        top: 15px;
        font-size: 32px;
    }
}

/* Scrollbar styling for modals */
.modal::-webkit-scrollbar {
    width: 8px;
}

.modal::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.modal::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

/* ================================ */

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 15px;
    }

    header h1 {
        font-size: 22px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .list-item-actions {
        width: 100%;
        flex-direction: column;
    }

    .list-item-actions .btn {
        width: 100%;
    }

    .list-item-detailed {
        flex-direction: column;
    }

    .meta-grid {
        grid-template-columns: 1fr;
    }

    .expense-item-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .expense-item-row .btn {
        width: 100%;
    }

    .expenses-header {
        flex-direction: column;
        align-items: stretch;
    }

    .expenses-header .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 18px;
    }

    .card {
        padding: 15px;
    }

    .card h2 {
        font-size: 18px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Print Styles */
@media print {
    .btn, header, .modal {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Additional utility classes */
.text-center { text-align: center; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
