@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

:root {
    --plus-color: #10b981;
    --minus-color: #ef4444;
    --balance-color: #3b82f6;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --card-bg-color: #fff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --primary: #3b82f6;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1400px;
    padding: 16px;
}

h1, h2 {
    text-align: center;
    margin-bottom: 16px;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-top: 0;
}

.card {
    background: var(--card-bg-color);
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* Balance Section */
.balance-section h2 {
    text-align: left;
}
.balance-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

@media (max-width: 480px) {
    .balance-details {
        grid-template-columns: 1fr;
    }
}

.balance-details h4 {
    margin: 0 0 4px;
    font-weight: 500;
    font-size: 13px;
    color: #64748b;
}
.money {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0;
}
.money.plus {
    color: var(--plus-color);
}
.money.minus {
    color: var(--minus-color);
}
#balance {
    font-weight: bold;
    color: var(--balance-color);
}


/* Grid Layout - Mobile First */
.grid-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Desktop: grid */
@media (min-width: 768px) {
    .grid-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

.column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Forms */
.form-control {
    margin-bottom: 12px;
}
.form-control label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
}
.form-control input,
.form-control select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px; /* Evita zoom en iOS */
    background: #fff;
}

.btn {
    color: #fff;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    margin-top: 8px;
    transition: all 0.2s ease;
}
.btn.plus { background-color: var(--plus-color); }
.btn.minus { background-color: var(--minus-color); }


/* Chart */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* History List */
#history-list {
    list-style-type: none;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}
.history-item {
    background-color: #fff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 4px solid;
    box-shadow: var(--shadow);
}

@media (min-width: 480px) {
    .history-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.history-item.plus { border-color: var(--plus-color); }
.history-item.minus { border-color: var(--minus-color); }

.history-item .description {
    flex: 1;
    font-weight: 500;
}
.history-item .category {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.history-item .amount {
    font-weight: 700;
    font-size: 15px;
}
.history-item.plus .amount { color: var(--plus-color); }
.history-item.minus .amount { color: var(--minus-color); }

.history-actions {
    display: flex;
    gap: 8px;
}

.delete-btn, .edit-btn {
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.delete-btn { background-color: #ef4444; }
.edit-btn { background-color: #3b82f6; }

/* Flex Between */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.flex-between h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin: 0;
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
}

.filters select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    background: #fff;
}

/* Summary */
#summary-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 30vh;
    overflow-y: auto;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 14px;
}
.summary-item span:first-child { font-weight: 600; }

.history-info {
    display: flex;
    flex-direction: column;
}
.history-info .date {
    font-size: 12px;
    color: #94a3b8;
}
.category-tag {
    font-size: 11px;
    color: #475569;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    display: inline-block;
}

#summary-container h3 {
    font-size: 14px;
    margin: 16px 0 8px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .balance-details {
        flex-direction: column;
    }
    .balance-details > div {
        margin-bottom: 12px;
    }
}

/* Header User - Mobile First */
.header-user {
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    margin-bottom: 16px;
    align-items: stretch;
}

.header-user h1 {
    text-align: center;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

@media (min-width: 480px) {
    .header-user {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: flex-end;
    justify-content: center;
}

.modal.show {
    display: flex;
}

@media (min-width: 480px) {
    .modal {
        align-items: center;
    }
}

.modal-content {
    width: 100%;
    max-width: 100%;
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 24px;
}

@media (min-width: 480px) {
    .modal-content {
        max-width: 400px;
        border-radius: 16px;
    }
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-buttons .btn {
    margin-top: 0;
}

/* ========================
    LOGIN SCREEN - MOBILE FIRST
    ======================== */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: 20px;
}

.login-content {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.login-logo h1 {
    color: #fff;
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -1px;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    margin: 0;
}

/* Botón de Google */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px 24px;
    background: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-google:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-google:active {
    transform: translateY(0);
}

.google-icon {
    width: 24px;
    height: 24px;
}

.login-footer {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    margin-top: 24px;
}

/* Botón de logout */
#logout-btn {
    padding: 10px 16px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

#logout-btn:hover {
    background: #dc2626;
}

/* User photo */
.user-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

#user-name {
    font-weight: 600;
    font-size: 14px;
}
