/* ===================================================================
   CALENDARIO DE PAGOS - Styles
   =================================================================== */

:root {
    --primary: #4CAF50;
    --primary-dark: #1B5E20;
    --primary-light: #81C784;
    --primary-lighter: #C8E6C9;
    --accent: #2E7D32;
    --background: #F8F9F5;
    --surface: #FFFFFF;
    --text: #1B5E20;
    --text-light: #558B2F;
    --text-muted: #689F38;
    --danger: #e74c3c;
    --warning: #f39c12;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 2px 8px rgba(27, 94, 32, 0.08);
    --shadow-md: 0 4px 16px rgba(27, 94, 32, 0.12);
    --shadow-lg: 0 8px 32px rgba(27, 94, 32, 0.16);
    --transition: 0.3s ease;
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--surface);
    padding: 16px 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.brand-educa {
    color: #1B4D4D;
}

.brand-billetera {
    color: var(--primary);
}

.btn-back {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color var(--transition);
}

.btn-back:hover {
    color: var(--primary);
}

/* Main */
.main {
    flex: 1;
    padding: 40px 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Calendar Wrapper */
.calendar-wrapper {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 32px;
}

/* Calendar Navigation */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.nav-btn {
    background: var(--primary-lighter);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    transition: all var(--transition);
}

.nav-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.current-month {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Calendar Grid */
.calendar-container {
    margin-bottom: 24px;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.weekday {
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 8px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    background: var(--background);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 4px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    min-height: 70px;
}

.calendar-day:hover {
    background: var(--primary-lighter);
    transform: scale(1.02);
}

.calendar-day.other-month {
    opacity: 0.4;
}

.calendar-day.today {
    background: var(--primary);
    color: white;
}

.calendar-day.today:hover {
    background: var(--primary-dark);
}

.calendar-day.has-payment {
    background: #fff3e0;
    border: 2px solid var(--warning);
}

.calendar-day.has-payment.today {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.day-number {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.payment-indicator {
    position: absolute;
    top: 28px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Single payment - large centered icon */
.payment-indicator.single {
    display: flex;
}

.payment-indicator.single .payment-emoji {
    font-size: 1.8rem;
    line-height: 1;
}

/* Multiple payments - grid layout */
.payment-indicator.multi {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    justify-items: center;
    align-items: center;
}

.payment-indicator.multi .payment-emoji {
    font-size: 0.9rem;
    line-height: 1;
}

.payment-more {
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    background: var(--primary);
    padding: 2px 4px;
    border-radius: 4px;
    grid-column: span 2;
    justify-self: center;
}

.calendar-day.today .payment-emoji {
    filter: brightness(1.2);
}

.calendar-day.today .payment-more {
    background: rgba(255, 255, 255, 0.35);
    color: white;
}




/* Monthly Summary */
.monthly-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.summary-card {
    background: var(--background);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    text-align: center;
}

.summary-card.total {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
}

.summary-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.summary-count,
.summary-amount {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Payments Section */
.payments-section {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.25rem;
    color: var(--primary-dark);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Center text/icon inside button */
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--background);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--primary-lighter);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Payments List */
.payments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.payments-list::-webkit-scrollbar {
    width: 6px;
}

.payments-list::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 3px;
}

.payments-list::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}

.payments-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.payment-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--background);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition);
}

.payment-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.payment-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.payment-info {
    flex: 1;
}

.payment-name {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 2px;
}

.payment-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.payment-amount {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.payment-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--primary-lighter);
    color: var(--primary-dark);
}

.action-btn.delete:hover {
    background: #fee;
    color: var(--danger);
}

/* Modal */
/* Modal - See fixed definitions at bottom of file */

.modal-sm {
    max-width: 360px;
    text-align: center;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--primary-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-text {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* Icon Picker */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--border-radius-sm);
    border: 2px solid #eee;
}

.icon-option {
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-option:hover {
    border-color: var(--primary-light);
    background: var(--primary-lighter);
    transform: scale(1.15);
}

.icon-option.selected {
    border-color: var(--primary);
    background: var(--primary-lighter);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

@media (max-width: 600px) {
    .icon-picker {
        grid-template-columns: repeat(5, 1fr);
    }

    .icon-option {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }
}

/* Footer */
.footer {
    background: var(--surface);
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    /* Fix overlap with modal */
    position: relative;
    z-index: 0;
}

/* Responsive */
@media (max-width: 600px) {
    .page-header h1 {
        font-size: 1.5rem;
    }

    .container {
        padding: 0 12px;
    }

    .calendar-wrapper {
        padding: 12px;
    }

    .current-month {
        font-size: 1.1rem;
    }

    .calendar-day {
        min-height: 0;
        /* Let aspect-ratio drive height */
        padding: 2px;
    }

    .day-number {
        font-size: 0.85rem;
    }

    .weekday {
        font-size: 0.75rem;
    }

    .monthly-summary {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .section-header .btn {
        width: 100%;
        justify-content: center;
    }

    .payment-item {
        flex-wrap: wrap;
    }

    .payment-amount {
        width: 100%;
        text-align: right;
        order: 3;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
    }
}

/* Layout Grid for Desktop */
@media (min-width: 1024px) {

    /* Widen the container for this specific layout */
    .calendar-layout {
        max-width: 1200px !important;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 6fr 4fr;
        /* 60% Calendar, 40% List */
        gap: 40px;
        align-items: start;
        padding-left: 40px;
        padding-right: 40px;
    }

    /* Override default container width if needed */
    .container.calendar-layout {
        width: 100%;
        max-width: 1200px;
    }

    .calendar-layout .page-header {
        grid-column: 1 / -1;
        margin-bottom: 24px;
        text-align: left;
    }

    .calendar-layout .calendar-wrapper {
        margin-bottom: 0;
        padding: 20px;
        /* Constrain width to make calendar smaller and prevent huge cells */
        max-width: 550px;
    }

    .calendar-layout .payments-section {
        position: sticky;
        top: 100px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    .calendar-day {
        /* Remove min-height to ensure strictly square shape based on width */
        min-height: 0;
        aspect-ratio: 1 / 1;
    }

    .payment-indicator.single .payment-emoji {
        font-size: 1.3rem;
    }
}

/* Delete Modal Visuals */
.modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.delete-icon {
    background: #fce4ec;
    /* Light pink */
    color: #e91e63;
    /* Pink/Red */
}

.delete-icon svg {
    width: 40px;
    height: 40px;
}

.modal-sm {
    padding-top: 40px;
    padding-bottom: 30px;
}

.modal-sm h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-sm .modal-actions {
    margin-top: 32px;
    gap: 16px;
    justify-content: center;
}

.modal-sm .btn {
    min-width: 120px;
    justify-content: center;
    padding: 12px 24px;
}


/* Sync Modal Icon */
.sync-icon {
    background: #e3f2fd;
    color: #4285F4;
}



/* Sync Modal Icon */
.sync-icon {
    background: #e3f2fd;
    color: #4285F4;
}

.success-icon {
    background: #e8f5e9;
    color: #4CAF50;
}

/* Financial Tips Card */
.tips-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #bbf7d0;
    border-radius: 16px;
    padding: 20px 24px;
    margin-top: 20px;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.1);
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.tips-icon {
    font-size: 1.6rem;
    background: #dcfce7;
    padding: 8px;
    border-radius: 10px;
}

.tips-title {
    font-weight: 700;
    color: #166534;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.tips-text {
    color: #15803d;
    line-height: 1.7;
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.tips-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #22c55e;
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.tips-btn:hover {
    background: #16a34a;
    transform: translateX(4px);
}

/* Icon Picker Grid Layout */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 0;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.icon-option {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-option:hover {
    background: var(--surface-hover);
    transform: scale(1.1);
}

.icon-option.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Export Confirmation Modal Styles */
.modal-md {
    max-width: 500px;
}

.export-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--background);
    border-radius: var(--border-radius-sm);
    margin: 16px 0;
    list-style: none;
}

.export-list li {
    padding: 8px 12px;
    border-bottom: 1px solid var(--primary-lighter);
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.export-list li:last-child {
    border-bottom: none;
}

.modal-subtext {
    text-align: center;
    color: var(--text-muted);
    margin-top: 12px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--primary-lighter);
    margin-top: 16px;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-lighter);
}

/* Login Overlay Styles */
/* Login Overlay Styles */
#authScreen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#authScreen.overlay-vanish {
    opacity: 0;
    pointer-events: none;
    z-index: -1 !important;
    display: none !important;
}

.login-card {
    background: var(--surface);
    padding: 48px;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-icon {
    font-size: 4rem;
    margin-bottom: 24px;
}

.login-card h2 {
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-google:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.btn-google img {
    width: 24px;
    height: 24px;
}

/* Start Screen Styles */
.start-screen {
    background: white;
    padding: 60px 40px;
    border-radius: 30px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    max-width: 450px;
}

.btn-start {
    background: var(--primary);
    color: white;
    font-size: 1.2rem;
    padding: 16px 32px;
    border-radius: 50px;
    border: none;
    width: 100%;
    margin: 20px 0;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

.login-privacy {
    color: #64748b;
    margin-top: 16px;
}

/* =========================================
   MISSING MODAL STYLES (Fixes Delete Freeze)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    /* Must be > 9999 */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    /* Force visibility override against fixed.css */
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* Mobile Modal Fixes */
@media (max-width: 600px) {
    .modal-card {
        width: 95%;
        padding: 20px;
        margin: auto;
        /* Center in flex container */
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-overlay {
        padding: 10px;
    }

    /* Fix form inputs on mobile */
    .form-group input,
    .form-group select {
        padding: 10px;
        font-size: 16px;
        /* Avoid iOS zoom */
    }
}