/* SmartFlex Gastos - Styles */

:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #2c3e50;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --dark: #34495e;
    --white: #ffffff;
    --gray: #95a5a6;
    --border: #bdc3c7;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
}

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

.login-box {
    background: var(--white);
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    color: var(--secondary);
    font-size: 28px;
    margin-bottom: 5px;
}

.logo p {
    color: var(--gray);
    font-size: 14px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

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

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

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

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

.btn-info {
    background: #17a2b8;
    color: var(--white);
}

.btn-info:hover {
    background: #138496;
}

.btn-warning:hover {
    background: #e67e22;
}

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

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

/* Error messages */
.error-message {
    background: #fde8e8;
    color: var(--danger);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 14px;
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--secondary);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--secondary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--light);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--secondary);
    color: var(--white);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 20px;
}

.sidebar-header p {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 20px;
    color: var(--white);
    text-decoration: none;
    transition: background 0.3s;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-menu li a i {
    margin-right: 10px;
    width: 20px;
}

/* Menu sections and submenus */
.menu-section {
    margin-top: 10px;
}

.menu-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 5px;
    font-size: 11px;
    font-weight: bold;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: color 0.2s;
}

.menu-section-title:hover {
    color: rgba(255,255,255,0.8);
}

.menu-section-title::after {
    content: '';
    border: solid rgba(255,255,255,0.5);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-right: 5px;
}

.menu-section.expanded .menu-section-title::after {
    transform: rotate(-135deg);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.menu-section.expanded .submenu {
    max-height: 500px;
    transition: max-height 0.4s ease-in;
}

.submenu li a {
    padding-left: 35px !important;
    font-size: 13px;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 24px;
    color: var(--secondary);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light);
}

.card-header h3 {
    font-size: 16px;
    color: var(--secondary);
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary);
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--gray);
    margin-top: 5px;
}

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

table th {
    background: var(--light);
    font-weight: 600;
    color: var(--secondary);
}

table tbody tr:hover {
    background: #f8f9fa;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary { background: #cce5ff; color: #004085; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-info { background: #d1ecf1; color: #0c5460; }
.alert-success { background: #d4edda; color: #155724; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-danger { background: #f8d7da; color: #721c24; }

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Menu toggle - oculto por defecto en desktop */
.menu-toggle {
    display: none;
}

/* Sidebar overlay - oculto por defecto */
.sidebar-overlay {
    display: none;
}

/* =====================================================
   RESPONSIVE - Tablet (768px - 1024px)
   ===================================================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =====================================================
   RESPONSIVE - Mobile (max 768px)
   ===================================================== */
@media (max-width: 768px) {
    /* Container y Layout */
    .app-container {
        flex-direction: column;
    }

    /* Sidebar colapsable */
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        padding-bottom: 100px;
    }

    .sidebar.open {
        left: 0;
    }

    /* Overlay cuando sidebar esta abierto */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Menu toggle button */
    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 24px;
        cursor: pointer;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1001;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    .main-content {
        margin-left: 0;
        padding: 70px 15px 15px;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 20px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .page-header > div,
    .page-header .btn {
        width: 100%;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-value {
        font-size: 20px;
    }

    .stat-card .stat-label {
        font-size: 12px;
    }

    /* Grids */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Cards */
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .card-header h3 {
        font-size: 14px;
    }

    /* Charts - ajustar altura */
    .chart-container {
        height: 250px;
    }

    /* Tables responsive */
    .table-container {
        margin: 0 -15px;
        padding: 0 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
        font-size: 13px;
    }

    table th,
    table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Botones */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 11px;
    }

    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 12px;
        font-size: 16px; /* Prevenir zoom en iOS */
    }

    /* Modal */
    .modal-content {
        padding: 20px;
        margin: 10px;
        width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* User menu en sidebar */
    .user-menu {
        position: relative;
        bottom: auto;
        margin-top: 20px;
    }

    /* Filtros en fila */
    .filters-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .filters-row .form-group {
        flex: 1 1 calc(50% - 5px);
        min-width: 120px;
        margin-bottom: 10px;
    }

    /* Badges */
    .badge {
        padding: 3px 6px;
        font-size: 11px;
    }
}

/* =====================================================
   RESPONSIVE - Mobile Small (max 480px)
   ===================================================== */
@media (max-width: 480px) {
    .main-content {
        padding: 65px 10px 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    .page-header h1 {
        font-size: 18px;
    }

    table {
        font-size: 12px;
    }

    table th,
    table td {
        padding: 8px 6px;
    }

    .chart-container {
        height: 200px;
    }

    .login-box {
        padding: 25px 20px;
    }

    .logo h1 {
        font-size: 24px;
    }
}

/* User menu */
.user-menu {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 0 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
