/* ============================================================
   BANCO MUNDIAL - Sistema de Ahorro y Préstamos
   Archivo: styles.css
   Fase 1: Estilos globales, variables y layout base
   ============================================================ */

/* --- Variables de color y diseño --- */
:root {
    --bm-primary:        #1a3c6e;   /* Azul corporativo oscuro */
    --bm-primary-light:  #2457a0;
    --bm-primary-dark:   #0f2444;
    --bm-accent:         #e8a020;   /* Dorado */
    --bm-accent-light:   #f0b84a;
    --bm-success:        #1a8754;
    --bm-danger:         #b02a37;
    --bm-warning:        #cc8a00;
    --bm-info:           #0d6efd;
    --bm-light:          #f5f7fa;
    --bm-gray:           #6c757d;
    --bm-gray-light:     #e9ecef;
    --bm-white:          #ffffff;
    --bm-text:           #212529;
    --bm-text-muted:     #6c757d;

    /* Sidebar */
    --sidebar-width:     260px;
    --sidebar-bg:        #0f2444;
    --sidebar-text:      #c8d8f0;
    --sidebar-active:    #e8a020;
    --sidebar-hover-bg:  rgba(255,255,255,0.07);

    /* Sombras */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
    --shadow-md:  0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:  0 8px 32px rgba(0,0,0,.14);

    /* Bordes */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;

    /* Transición */
    --transition: all .22s ease;
}

/* --- Reset y base --- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    font-size: .938rem;
    color: var(--bm-text);
    background: var(--bm-light);
    min-height: 100vh;
    margin: 0;
}

a { color: var(--bm-primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--bm-accent); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bm-primary-dark) 0%, var(--bm-primary) 60%, var(--bm-primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--bm-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: var(--bm-primary-dark);
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--bm-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.8rem;
}

.login-header h1 {
    color: var(--bm-white);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.login-header p {
    color: var(--bm-sidebar-text);
    font-size: .85rem;
    margin: .25rem 0 0;
    color: #a0b8d8;
}

.login-body {
    padding: 2rem;
}

/* ============================================================
   LAYOUT PRINCIPAL (SIDEBAR + CONTENT)
   ============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.4rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: var(--bm-accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    line-height: 1.1;
}

.sidebar-brand-text strong {
    display: block;
    color: var(--bm-white);
    font-size: .95rem;
    font-weight: 700;
}

.sidebar-brand-text small {
    color: #7a9abf;
    font-size: .72rem;
}

.sidebar-user {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: .7rem;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: var(--bm-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bm-white);
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.sidebar-user-info small {
    display: block;
    color: #7a9abf;
    font-size: .7rem;
}

.sidebar-user-info span {
    display: block;
    color: var(--bm-white);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.sidebar-nav {
    padding: .75rem 0;
    flex: 1;
}

.sidebar-section-title {
    padding: .6rem 1.2rem .2rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #4d6f96;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.2rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--bm-white);
}

.sidebar-nav a.active {
    color: var(--bm-accent);
    background: rgba(232,160,32,.1);
    font-weight: 700;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--bm-accent);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: .95rem;
}

.sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

/* --- Contenido principal --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
    background: var(--bm-white);
    padding: .9rem 1.5rem;
    border-bottom: 1px solid var(--bm-gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--bm-primary-dark);
    margin: 0;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--bm-primary);
    cursor: pointer;
    padding: .2rem .5rem;
}

/* --- Área de contenido --- */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   CARDS Y WIDGETS
   ============================================================ */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bm-white);
    margin-bottom: 1.25rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bm-gray-light);
    padding: 1rem 1.25rem;
    font-weight: 700;
    color: var(--bm-primary-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.card-header i { color: var(--bm-accent); }

/* Tarjetas de resumen (dashboard) */
.stat-card {
    border-radius: var(--radius-md);
    padding: 1.25rem;
    color: var(--bm-white);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}

.stat-card-primary  { background: linear-gradient(135deg, var(--bm-primary), var(--bm-primary-light)); }
.stat-card-success  { background: linear-gradient(135deg, #145c3a, var(--bm-success)); }
.stat-card-warning  { background: linear-gradient(135deg, #a06800, var(--bm-warning)); }
.stat-card-accent   { background: linear-gradient(135deg, #9b6b00, var(--bm-accent)); }

.stat-card-icon {
    font-size: 2rem;
    opacity: .7;
    margin-bottom: .5rem;
}

.stat-card-value {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .2rem;
}

.stat-card-label {
    font-size: .78rem;
    opacity: .85;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-label {
    font-weight: 600;
    font-size: .875rem;
    color: var(--bm-primary-dark);
    margin-bottom: .3rem;
}

.form-control, .form-select {
    border: 1.5px solid #d0d9e8;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    padding: .55rem .85rem;
    transition: border-color .2s, box-shadow .2s;
    color: var(--bm-text);
}

.form-control:focus, .form-select:focus {
    border-color: var(--bm-primary-light);
    box-shadow: 0 0 0 3px rgba(36,87,160,.15);
    outline: none;
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--bm-danger);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .875rem;
    padding: .5rem 1.1rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--bm-primary);
    border-color: var(--bm-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--bm-primary-light);
    border-color: var(--bm-primary-light);
    color: #fff;
}

.btn-accent {
    background: var(--bm-accent);
    border-color: var(--bm-accent);
    color: var(--bm-primary-dark);
}
.btn-accent:hover {
    background: var(--bm-accent-light);
    border-color: var(--bm-accent-light);
    color: var(--bm-primary-dark);
}

.btn-outline-primary {
    border-color: var(--bm-primary);
    color: var(--bm-primary);
}
.btn-outline-primary:hover {
    background: var(--bm-primary);
    color: #fff;
}

/* ============================================================
   BADGES Y ESTADOS
   ============================================================ */
.badge {
    font-size: .72rem;
    font-weight: 700;
    padding: .3em .6em;
    border-radius: 30px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .7rem;
    border-radius: 30px;
    font-size: .75rem;
    font-weight: 700;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-activo      { color: var(--bm-success); background: #d1f0e2; }
.status-pendiente   { color: #a06000; background: #fef3cd; }
.status-solicitado  { color: var(--bm-primary); background: #dce8fa; }
.status-aprobado    { color: var(--bm-success); background: #d1f0e2; }
.status-rechazado   { color: var(--bm-danger); background: #fde2e4; }
.status-pagado      { color: var(--bm-gray); background: var(--bm-gray-light); }

/* ============================================================
   TABLAS
   ============================================================ */
.table {
    font-size: .875rem;
    margin-bottom: 0;
}

.table thead th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bm-primary-dark);
    background: var(--bm-light);
    border-bottom: 2px solid var(--bm-gray-light);
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: .7rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--bm-gray-light);
    color: var(--bm-text);
}

.table tbody tr:hover {
    background: #f0f4fa;
}

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: .85rem 1.1rem;
    font-size: .9rem;
}

.alert-info    { background: #dce8fa; color: #0a3880; }
.alert-success { background: #d1f0e2; color: #0b3a20; }
.alert-warning { background: #fef3cd; color: #6e4500; }
.alert-danger  { background: #fde2e4; color: #6b0e18; }

/* ============================================================
   COMPONENTE: SALDO ESPERADO vs DISPONIBLE
   ============================================================ */
.saldo-widget {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.saldo-widget-esperado {
    background: linear-gradient(135deg, #1a3c6e, #2457a0);
    color: #fff;
    padding: 1.2rem 1.5rem;
}

.saldo-widget-disponible {
    background: linear-gradient(135deg, #145c3a, #1a8754);
    color: #fff;
    padding: 1.2rem 1.5rem;
}

.saldo-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .8;
    margin-bottom: .25rem;
}

.saldo-valor {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.saldo-sub {
    font-size: .78rem;
    opacity: .75;
    margin-top: .2rem;
}

/* ============================================================
   LOADER / SPINNER
   ============================================================ */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bm-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity .4s;
}

.page-loader.hide {
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   RESPONSIVE - MOBILE FIRST
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .btn-sidebar-toggle {
        display: block;
    }
    .content-area {
        padding: 1rem;
    }
    .stat-card-value {
        font-size: 1.15rem;
    }
    .table-responsive {
        font-size: .82rem;
    }
}

/* Overlay para cerrar sidebar en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}
.sidebar-overlay.show {
    display: block;
}

/* ============================================================
   UTILIDADES EXTRAS
   ============================================================ */
.text-primary-dark { color: var(--bm-primary-dark) !important; }
.text-accent       { color: var(--bm-accent) !important; }
.bg-primary-dark   { background: var(--bm-primary-dark) !important; }
.fw-800            { font-weight: 800 !important; }
.rounded-md        { border-radius: var(--radius-md) !important; }
.shadow-md         { box-shadow: var(--shadow-md) !important; }

.divider-text {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--bm-text-muted);
    font-size: .8rem;
    margin: 1rem 0;
}
.divider-text::before, .divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--bm-gray-light);
}
