/* ==============================================
   archivo: estilos.css - Diseño del Sistema de Gastos por Mes
   ============================================== */

/* ========== RESET & GLOBAL ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, 'Segoe UI', 'Inter', 'Helvetica Neue', sans-serif;
}

body {
    background: linear-gradient(145deg, #e9f0fc 0%, #d9e2ef 100%);
    min-height: 100vh;
    padding: 2rem 1.5rem;
}

/* ========== LAYOUT PRINCIPAL ========== */
.dashboard {
    max-width: 1300px;
    margin: 0 auto;
}

/* ========== HERO / CABECERA ========== */
.hero {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 2.5rem;
    padding: 1.8rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255,255,255,0.5);
}

.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

h1 {
    font-size: 1.9rem;
    font-weight: 700;
    background: linear-gradient(135deg, #1C2A44, #2C3E66);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    letter-spacing: -0.3px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.sub {
    color: #2c3e50;
    opacity: 0.7;
    font-weight: 500;
    margin-top: 0.2rem;
    border-left: 3px solid #3b82f6;
    padding-left: 0.75rem;
}

.badge-gasto {
    background: #eef2ff;
    color: #1e40af;
    border-radius: 40px;
    padding: 0.2rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========== SELECTOR DE MES ========== */
.month-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 1rem;
}

.month-label {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

.month-select {
    padding: 0.7rem 1.2rem;
    border-radius: 2rem;
    border: 1.5px solid #e2e8f0;
    background: white;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 180px;
}

.month-select:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}

.month-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

/* ========== TARJETAS ESTADÍSTICAS ========== */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1.8rem;
}

.stat-card {
    background: white;
    border-radius: 1.8rem;
    padding: 1.2rem 1.8rem;
    flex: 1;
    min-width: 160px;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s;
    border: 1px solid rgba(0,0,0,0.03);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px -12px rgba(0, 0, 0, 0.15);
}

.stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: #5b6e8c;
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2.3rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
}

/* ========== ALERTAS ========== */
.alert {
    padding: 1rem 1.2rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* ========== PANEL PRINCIPAL ========== */
.main-panel {
    background: white;
    border-radius: 2rem;
    padding: 1.8rem 2rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.12);
    margin-bottom: 2rem;
    transition: all 0.2s;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
    border-bottom: 2px solid #edf2f7;
    padding-bottom: 1rem;
}

.panel-header h2 {
    font-weight: 600;
    font-size: 1.5rem;
    color: #0f172a;
}

/* ========== BOTÓN AÑADIR ========== */
.btn-add {
    background: linear-gradient(100deg, #3b82f6, #2563eb);
    border: none;
    padding: 0.85rem 1.9rem;
    border-radius: 3rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.btn-add:hover {
    background: linear-gradient(100deg, #2563eb, #1d4ed8);
    transform: scale(1.02);
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.35);
}

.btn-add:active {
    transform: scale(0.98);
}

/* ========== TABLA ========== */
.gastos-table-container {
    overflow-x: auto;
    border-radius: 1.5rem;
}

.gastos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.gastos-table th {
    text-align: left;
    padding: 1rem 0.8rem;
    background-color: #f8fafc;
    color: #334155;
    font-weight: 600;
    border-bottom: 1.5px solid #e2e8f0;
}

.gastos-table td {
    padding: 1rem 0.8rem;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
    color: #1e293b;
    font-weight: 500;
}

.gastos-table tr:hover td {
    background-color: #fafcff;
}

.monto-negativo {
    font-weight: 700;
    color: #dc2626;
    background: #fee2e2;
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 30px;
    font-size: 0.85rem;
}

.categoria-badge {
    background: #e6f0ff;
    padding: 0.2rem 0.9rem;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e3a8a;
    display: inline-block;
}

.btn-delete {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #94a3b8;
    transition: 0.1s;
    padding: 0.3rem 0.5rem;
    border-radius: 2rem;
}

.btn-delete:hover {
    color: #ef4444;
    background: #fee2e2;
    transform: scale(1.05);
}

.empty-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
    font-style: italic;
}

/* ========== GRÁFICO DE CATEGORÍAS ========== */
.chart-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #edf2f7;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1.2rem;
}

.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-item {
    width: 100%;
}

.chart-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart-cat-name {
    font-weight: 600;
    color: #334155;
}

.chart-cat-value {
    color: #5b6e8c;
}

.chart-bar-bg {
    background: #e2e8f0;
    border-radius: 1rem;
    height: 1.8rem;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 1rem;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
}

/* ========== MODAL ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 460px;
    border-radius: 2rem;
    padding: 2rem 1.8rem;
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.25);
    animation: fadeSlideUp 0.2s ease-out;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #0f172a;
}

.modal-content p {
    color: #475569;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 1.3rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #4b5563;
    margin-bottom: 0.3rem;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 1.2rem;
    border: 1.5px solid #e2e8f0;
    font-size: 1rem;
    transition: 0.2s;
    background: #fefefe;
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.8rem;
}

.modal-buttons button {
    flex: 1;
    padding: 0.8rem;
    border-radius: 3rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.btn-save {
    background: #3b82f6;
    color: white;
}

.btn-save:hover {
    background: #2563eb;
}

.btn-cancel {
    background: #f1f5f9;
    color: #334155;
}

.btn-cancel:hover {
    background: #e2e8f0;
}

/* ========== FOOTER ========== */
footer {
    text-align: center;
    font-size: 0.75rem;
    color: #4a627a;
    margin-top: 2rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 650px) {
    body {
        padding: 1rem;
    }
    .hero, .main-panel {
        padding: 1.2rem;
    }
    .stat-number {
        font-size: 1.6rem;
    }
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .btn-add {
        width: 100%;
        justify-content: center;
    }
    .hero-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
    .chart-label {
        flex-direction: column;
        gap: 0.2rem;
    }
    .month-selector {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-add {
        margin-left: 0 !important;
    }
    .month-select {
        width: 100%;
    }
}