/* ============================================================
   PrestaFácil · Sistema de diseño
   Base moderna sobre Bootstrap 5. Simple: solo variables + estilos.
   ============================================================ */

/* ---------- 1. Tokens / Variables ---------- */
:root {
    /* Marca */
    --pf-primary:        #2563eb;   /* Azul - confianza */
    --pf-primary-dark:   #1d4ed8;
    --pf-primary-light:  #eff6ff;
    --pf-accent:         #10b981;   /* Verde - dinero / aprobado */
    --pf-accent-dark:    #059669;
    --pf-danger:         #ef4444;
    --pf-warning:        #f59e0b;

    /* Neutros */
    --pf-ink:            #0f172a;   /* Texto principal */
    --pf-muted:          #64748b;   /* Texto secundario */
    --pf-line:           #e2e8f0;   /* Bordes */
    --pf-bg:             #f8fafc;   /* Fondo app */
    --pf-surface:        #ffffff;   /* Tarjetas */

    /* Gradientes */
    --pf-gradient:       linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --pf-gradient-accent:linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Sombras */
    --pf-shadow-sm:  0 1px 2px rgba(15, 23, 42, .06);
    --pf-shadow:     0 4px 16px rgba(15, 23, 42, .08);
    --pf-shadow-lg:  0 12px 32px rgba(15, 23, 42, .12);

    /* Radios */
    --pf-radius:     14px;
    --pf-radius-sm:  10px;
    --pf-radius-lg:  22px;

    /* Bootstrap overrides */
    --bs-primary:        var(--pf-primary);
    --bs-primary-rgb:    37, 99, 235;
    --bs-body-color:     var(--pf-ink);
    --bs-body-bg:        var(--pf-bg);
    --bs-border-color:   var(--pf-line);
}

/* ---------- 2. Base ---------- */
html { font-size: 16px; scroll-behavior: smooth; position: relative; min-height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--pf-bg);
    color: var(--pf-ink);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.02em; color: var(--pf-ink); }
a { color: var(--pf-primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--pf-primary-dark); }
.text-muted-2 { color: var(--pf-muted) !important; }

/* ---------- 3. Navbar ---------- */
.pf-navbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--pf-line);
    box-shadow: var(--pf-shadow-sm);
    padding: .75rem 0;
}

.pf-brand {
    display: flex; align-items: center; gap: .6rem;
    font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em;
    color: var(--pf-ink) !important;
}
.pf-brand:hover { color: var(--pf-ink) !important; }
.pf-brand-logo {
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--pf-gradient);
    display: grid; place-items: center;
    color: #fff; font-size: 1.2rem;
    box-shadow: var(--pf-shadow);
}
.pf-brand span { color: var(--pf-primary); }

.pf-navbar .nav-link {
    color: var(--pf-muted) !important;
    font-weight: 500;
    padding: .5rem 1rem !important;
    border-radius: var(--pf-radius-sm);
    transition: all .15s ease;
}
.pf-navbar .nav-link:hover { color: var(--pf-primary) !important; background: var(--pf-primary-light); }
.pf-navbar .nav-link.active { color: var(--pf-primary) !important; }

/* ---------- 4. Botones ---------- */
.btn {
    font-weight: 600;
    border-radius: var(--pf-radius-sm);
    padding: .6rem 1.35rem;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--pf-gradient);
    border: none;
    box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--pf-primary-dark);
    box-shadow: 0 6px 20px rgba(37, 99, 235, .45);
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--pf-gradient-accent);
    border: none; color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, .35);
}
.btn-accent:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16, 185, 129, .45); }

.btn-outline-primary {
    border: 1.5px solid var(--pf-line);
    color: var(--pf-ink);
    background: var(--pf-surface);
}
.btn-outline-primary:hover {
    border-color: var(--pf-primary);
    background: var(--pf-primary-light);
    color: var(--pf-primary);
}
.btn-lg { padding: .8rem 1.8rem; font-size: 1.05rem; }

/* ---------- 5. Tarjetas ---------- */
.card, .pf-card {
    background: var(--pf-surface);
    border: 1px solid var(--pf-line);
    border-radius: var(--pf-radius);
    box-shadow: var(--pf-shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease;
}
.pf-card { padding: 1.5rem; }
.pf-card-hover:hover { transform: translateY(-4px); box-shadow: var(--pf-shadow-lg); }

.pf-icon-badge {
    width: 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center;
    background: var(--pf-primary-light); color: var(--pf-primary);
    font-size: 1.5rem; margin-bottom: 1rem;
}
.pf-icon-badge.accent { background: #d1fae5; color: var(--pf-accent-dark); }
.pf-icon-badge.warning { background: #fef3c7; color: #b45309; }

/* ---------- 6. Hero ---------- */
.pf-hero {
    position: relative;
    padding: 5rem 0 4rem;
    overflow: hidden;
}
.pf-hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(60% 60% at 80% 0%, rgba(37, 99, 235, .10) 0%, transparent 70%),
                radial-gradient(50% 50% at 0% 100%, rgba(16, 185, 129, .10) 0%, transparent 70%);
    z-index: -1;
}
.pf-eyebrow {
    display: inline-flex; align-items: center; gap: .5rem;
    background: var(--pf-primary-light); color: var(--pf-primary);
    font-weight: 600; font-size: .85rem;
    padding: .4rem .9rem; border-radius: 999px;
    margin-bottom: 1.25rem;
}
.pf-hero h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.05; }
.pf-hero .lead { color: var(--pf-muted); font-size: 1.2rem; max-width: 34rem; }

/* Panel/tarjeta destacada del hero */
.pf-hero-card {
    background: var(--pf-surface);
    border: 1px solid var(--pf-line);
    border-radius: var(--pf-radius-lg);
    box-shadow: var(--pf-shadow-lg);
    padding: 2rem;
}

/* ---------- 7. Formularios ---------- */
.form-control, .form-select {
    border: 1.5px solid var(--pf-line);
    border-radius: var(--pf-radius-sm);
    padding: .65rem .9rem;
    background: var(--pf-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.form-label { font-weight: 600; font-size: .9rem; color: var(--pf-ink); margin-bottom: .4rem; }

/* Inputs de fecha: en móvil (iOS/Android) el valor se recortaba y el campo se veía vacío */
input[type="date"].form-control {
    -webkit-appearance: none;
    appearance: none;
    min-height: 2.9rem;
    line-height: 1.3;
}
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
    color: var(--pf-ink);
}
input[type="date"]::-webkit-datetime-edit {
    padding: 0;
    color: var(--pf-ink);
}

/* ---------- 8. Badges / estados ---------- */
.pf-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    font-weight: 600; font-size: .78rem;
    padding: .3rem .7rem; border-radius: 999px;
}
.pf-badge.ok   { background: #d1fae5; color: var(--pf-accent-dark); }
.pf-badge.wait { background: #fef3c7; color: #b45309; }
.pf-badge.no   { background: #fee2e2; color: #b91c1c; }

/* ---------- 9. Tablas ---------- */
.table { --bs-table-bg: transparent; }
.table thead th {
    text-transform: uppercase; font-size: .75rem; letter-spacing: .04em;
    color: var(--pf-muted); font-weight: 700; border-bottom: 1px solid var(--pf-line);
}
.table tbody td { padding: .9rem .75rem; vertical-align: middle; border-color: var(--pf-line); }

/* ---------- 10. Stats ---------- */
.pf-stat { text-align: center; }
.pf-stat .num { font-size: 2rem; font-weight: 800; color: var(--pf-primary); letter-spacing: -.03em; }
.pf-stat .lbl { color: var(--pf-muted); font-size: .9rem; }

/* ---------- 11. Footer ---------- */
.pf-footer {
    margin-top: auto;
    background: var(--pf-surface);
    border-top: 1px solid var(--pf-line);
    color: var(--pf-muted);
    padding: 1.5rem 0;
    font-size: .9rem;
}
.pf-footer a { color: var(--pf-muted); }
.pf-footer a:hover { color: var(--pf-primary); }

/* ---------- 12. Utilidades ---------- */
main { flex: 1 0 auto; }
.section { padding: 4rem 0; }
.pf-container { max-width: 1140px; }
::selection { background: var(--pf-primary); color: #fff; }

/* ---------- 13. App shell (área interna) ---------- */
.pf-app { flex-direction: row; }

.pf-sidebar {
    width: 264px; flex-shrink: 0;
    background: linear-gradient(185deg, #172554 0%, #1e3a8a 55%, #1e40af 100%);
    border-right: none;
    position: sticky; top: 0; height: 100vh;
    padding: 1.25rem 1rem;
    overflow-y: auto;
}
.pf-sidebar .pf-brand,
#sideMenu .pf-brand { margin-bottom: 1.75rem; padding: 0 .4rem; color: #fff !important; }
.pf-sidebar .pf-brand span,
#sideMenu .pf-brand span { color: #93c5fd; }

/* Menú móvil (offcanvas) con el mismo estilo oscuro */
#sideMenu.offcanvas { background: linear-gradient(185deg, #172554 0%, #1e3a8a 100%); color: #fff; }
#sideMenu .offcanvas-header { border-bottom: 1px solid rgba(255, 255, 255, .12); }
#sideMenu .btn-close { filter: invert(1) grayscale(1) brightness(2); }

.pf-side-nav { display: flex; flex-direction: column; gap: .3rem; }
.pf-side-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .72rem .9rem; border-radius: var(--pf-radius-sm);
    color: rgba(255, 255, 255, .72); font-weight: 500; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.pf-side-link i { font-size: 1.15rem; }
.pf-side-link:hover { background: rgba(255, 255, 255, .10); color: #fff; }
.pf-side-link.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, .45);
}
.pf-side-link.active:hover { color: #fff; }
.pf-side-sep { height: 1px; background: rgba(255, 255, 255, .14); margin: 1rem .4rem; }

.pf-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pf-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .9rem 1.5rem;
    background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--pf-line);
    position: sticky; top: 0; z-index: 20;
}
.pf-page-title { font-size: 1.2rem; margin: 0; }
.pf-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.pf-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--pf-gradient); color: #fff; display: grid; place-items: center; font-weight: 700; }
.pf-content { padding: 1.75rem 1.5rem; flex: 1; }

.pf-page-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; }
.pf-page-head h2 { margin: 0 0 .25rem; font-size: 1.5rem; }

.pf-empty { text-align: center; padding: 3rem 1rem; color: var(--pf-muted); }
.pf-empty i { font-size: 2.5rem; color: var(--pf-primary); opacity: .5; display: block; margin-bottom: .75rem; }

/* ---------- 14. Calendario de pagos ---------- */
.pf-cal-mes { font-weight: 700; margin: 1.1rem 0 .5rem; color: var(--pf-ink); text-transform: capitalize; }
.pf-cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: .5rem; }
.pf-cal-dia {
    position: relative;
    border: 1px solid var(--pf-line); border-radius: 12px; padding: .55rem .35rem .45rem;
    text-align: center; background: var(--pf-surface);
}
.pf-cal-dia .n { position: absolute; top: 4px; left: 7px; font-size: .6rem; color: var(--pf-muted); }
.pf-cal-dia .ic { position: absolute; top: 3px; right: 6px; font-size: .8rem; }
.pf-cal-dia .dow { font-size: .66rem; text-transform: uppercase; color: var(--pf-muted); letter-spacing: .04em; }
.pf-cal-dia .num { font-size: 1.5rem; font-weight: 800; line-height: 1; margin: .12rem 0; color: var(--pf-ink); }
.pf-cal-dia .val { font-size: .72rem; color: var(--pf-muted); }

.pf-cal-dia.pagada { background: #d1fae5; border-color: #a7f3d0; }
.pf-cal-dia.pagada .num, .pf-cal-dia.pagada .ic { color: var(--pf-accent-dark); }
.pf-cal-dia.parcial { background: #fef3c7; border-color: #fde68a; }
.pf-cal-dia.parcial .num, .pf-cal-dia.parcial .ic { color: #b45309; }
.pf-cal-dia.vencida { background: #fee2e2; border-color: #fecaca; }
.pf-cal-dia.vencida .num, .pf-cal-dia.vencida .ic { color: #b91c1c; }

.pf-cal-leyenda { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--pf-muted); margin-top: .75rem; }
.pf-cal-leyenda span { display: inline-flex; align-items: center; gap: .35rem; }
.pf-cal-leyenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ============================================================
   15. Responsive / móvil
   ============================================================ */
main { min-width: 0; }
.pf-content { overflow-x: hidden; }

@media (max-width: 640px) {
    .pf-content { padding: 1rem .85rem; }
    .pf-topbar { padding: .75rem .85rem; }
    .pf-page-title { font-size: 1.05rem; }
    .pf-page-head h2 { font-size: 1.3rem; }
    /* Encabezado apilado: título arriba, acciones abajo a lo ancho */
    .pf-page-head { gap: .7rem; flex-direction: column; align-items: stretch; }
    .pf-card { padding: 1.1rem; }

    /* Tablas apiladas como tarjetas en móvil */
    .table-responsive table.table thead { display: none; }
    .table-responsive table.table,
    .table-responsive table.table tbody,
    .table-responsive table.table tr,
    .table-responsive table.table td,
    .table-responsive table.table tfoot { display: block; width: 100%; }

    .table-responsive table.table tr {
        border: 1px solid var(--pf-line);
        border-radius: var(--pf-radius-sm);
        margin: .5rem; padding: .25rem .35rem;
        background: var(--pf-surface);
    }

    .table-responsive table.table td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        text-align: right; border: none; padding: .5rem .65rem; min-height: 0;
    }
    .table-responsive table.table td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--pf-muted);
        text-align: left; font-size: .78rem; flex-shrink: 0;
    }
    /* Celda de acciones: botones a la derecha, sin etiqueta rara */
    .table-responsive table.table td.text-end { justify-content: flex-end; }
    .table-responsive table.table td.text-end::before { content: ""; }

    /* Filtros y encabezados que estiran botones a lo ancho */
    .pf-page-head > .d-flex { width: 100%; }
    .pf-page-head > .d-flex .btn { flex: 1 1 auto; }

    /* Barras de filtro: cada campo a todo el ancho (no se aprietan) */
    .pf-card > form.d-flex { flex-direction: column; align-items: stretch; }
    .pf-card > form.d-flex > * { max-width: 100% !important; width: 100%; }

    /* Modales usan casi toda la pantalla en móvil */
    .modal-dialog:not(.modal-mapa-dialog) { margin: .4rem; }
    .modal-xl, .modal-lg { max-width: none; }
    #mapaModal .modal-mapa-dialog { width: 98vw; max-width: 98vw; margin: .3rem auto; }
    #mapa { height: calc(100vh - 170px) !important; }

    /* Calendario de pagos un poco más compacto */
    .pf-cal-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: .4rem; }

    /* Login en móvil: sin card, el formulario sobre el fondo */
    .pf-hero { padding: 1.5rem 0; }
    .pf-hero .pf-hero-card {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }
}

/* Tablet: filtros y grillas se comportan bien */
@media (min-width: 641px) and (max-width: 991.98px) {
    .pf-sidebar { width: 230px; }
}
