/* ═══════════════════════════════════════════════════════
   RESPONSIVE GLOBAL
   Aplica a todas las páginas que usen header/footer
   ═══════════════════════════════════════════════════════ */

/* ─── Base ─── */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

/* ─── Contenedores fluidos ─── */
.card,
.dashboard-content,
.solicitudes-header,
.compra-layout,
.solicitud-nav {
    width: 100%;
    max-width: 100%;
}

/* ─── Grids fluidos ─── */
.grid {
    display: grid;
    gap: 12px;
}

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

/* ─── Header de página ─── */
.solicitudes-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.solicitudes-saldo {
    margin-left: auto;
}

/* ─── Tablas: scroll horizontal en móvil ─── */
.tabla-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}

.tabla {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

/* ─── Formularios ─── */
input, select, textarea, button {
    max-width: 100%;
    font-size: 16px;   /* evita zoom automático en iOS */
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

/* ─── Botones ─── */
.btn {
    white-space: nowrap;
    max-width: 100%;
}

/* ─── Flex helpers ─── */
.flex {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flex.gap-1 { gap: 8px; }

/* ─── Modal responsive ─── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box-lg {
    max-width: 900px;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR — BASE (desktop y móvil)
   Siempre vertical, apilado
   ═══════════════════════════════════════════════════════ */
.sidebar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 240px;
    min-height: 100vh;
    padding: 16px 0;
    gap: 4px;
    background: #fff;
}

.sidebar a,
.sidebar .nav-link,
.sidebar .menu-item,
.sidebar li {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}

.sidebar a:hover {
    background: rgba(0, 0, 0, .04);
}

.sidebar ul,
.sidebar nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0;
}

.sidebar a > i,
.sidebar a > svg,
.sidebar a > .icono {
    margin-right: 10px;
    flex-shrink: 0;
}

/* ─── Botón hamburguesa: oculto en desktop ─── */
.btn-hamburguesa {
    display: none;
    background: transparent;
    color: #ffffff;
    border: none;
    padding: 6px 10px;
    font-size: 1.6rem;
    cursor: pointer;
    margin-right: 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background .2s ease;
}

.btn-hamburguesa:hover {
    background: rgba(255, 255, 255, .15);
}

.btn-hamburguesa:active {
    background: rgba(255, 255, 255, .25);
}

/* ─── Backdrop para cerrar sidebar ─── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 9997;
}

.sidebar-backdrop.activo {
    display: block;
}

/* ═══════════════════════════════════════════════════════
   BREAKPOINTS
   ═══════════════════════════════════════════════════════ */

/* ─── Tablet (≤ 1024px) ─── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ─── Móvil (≤ 768px) ─── */
@media (max-width: 768px) {

    /* Grids a 1 columna */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Header de página: stack */
    .solicitudes-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .solicitudes-saldo {
        margin-left: 0;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Layout admin: contenido sin margen */
    .dashboard-layout {
        display: block;
        position: relative;
    }

    .dashboard-content {
        margin-left: 0 !important;
        width: 100%;
    }

    /* ─── SIDEBAR MÓVIL ─── */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 9998;
        box-shadow: 2px 0 12px rgba(0, 0, 0, .15);
        transform: translateX(-100%);
        transition: transform .28s ease;
        overflow-y: auto;
        padding: 16px 0;
    }

    .sidebar.abierta {
        transform: translateX(0);
    }

    /* Pestañas: apiladas verticales full-width */
    .sidebar a,
    .sidebar .nav-link,
    .sidebar .menu-item,
    .sidebar li {
        padding: 14px 18px;
        border-radius: 0;
        border-bottom: 1px solid rgba(0, 0, 0, .06);
        font-size: .95rem;
        text-align: left;
        justify-content: flex-start;
    }

    .sidebar a:last-child,
    .sidebar .nav-link:last-child {
        border-bottom: none;
    }

    /* Botón hamburguesa visible en móvil (blanco) */
    .btn-hamburguesa {
        display: inline-block;
        color: #ffffff;
    }

    /* Cards full-width */
    .card {
        padding: 12px;
        border-radius: 8px;
    }

    /* Tablas más chicas */
    .tabla {
        font-size: .82rem;
        min-width: 640px;
    }

    .tabla th,
    .tabla td {
        padding: 8px 6px;
    }

    /* Botones de acción en tablas */
    .btn-mini {
        font-size: .72rem;
        padding: 4px 6px;
    }

    /* Duración grid (renovar) */
    .duracion-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Modal ocupa casi toda la pantalla */
    .modal-box {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }

    /* Inputs full-width */
    input[type="text"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        width: 100%;
    }

    /* Buscadores con max-width inline se van a full */
    #renovar-buscar,
    #buscar-ventas,
    #buscar-renovaciones {
        max-width: 100% !important;
    }

    /* Filtros en línea: stack */
    .flex.gap-1 {
        flex-direction: column;
        align-items: stretch;
    }

    /* Textarea del mensaje de resultado */
    #resultado-renovar-mensaje,
    #resultado-mensaje {
        font-size: .75rem !important;
    }

    /* Preview de precio del modal */
    .precio-linea {
        font-size: .88rem;
    }
}

/* ─── Móvil pequeño (≤ 480px) ─── */
@media (max-width: 480px) {
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.05rem; }

    .card {
        padding: 10px;
    }

    .btn {
        padding: 8px 12px;
        font-size: .85rem;
    }

    .stat-num {
        font-size: 1.4rem;
    }

    .tabla {
        font-size: .78rem;
    }

    /* Duración: 1 columna */
    .duracion-grid {
        grid-template-columns: 1fr !important;
    }

    /* Saldo en header: stack */
    .solicitudes-saldo {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* ─── Landscape móvil ─── */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-box {
        max-height: 100vh;
    }
}

/* ═══════════════════════════════════════════════════════
   DESKTOP (≥ 769px): sidebar estático, hamburguesa oculta
   ═══════════════════════════════════════════════════════ */
@media (min-width: 769px) {
    .sidebar {
        transform: none !important;
        position: relative;
    }

    .sidebar-backdrop {
        display: none !important;
    }

    .btn-hamburguesa {
        display: none !important;
    }
}

/* ─── Impresión ─── */
@media print {
    .sidebar,
    .solicitud-nav,
    .btn,
    .flex.gap-1,
    .btn-hamburguesa,
    .sidebar-backdrop {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
.header-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;  /* izquierda | derecha */
    padding: 8px 16px;
}
@media (max-width: 768px) {
    .header-bar {
        justify-content: flex-start;
        padding-left: 12px;
    }

    .header-left {
        justify-content: flex-start;
        margin-right: auto;
    }

    .header-right {
    gap: 6px;
    flex-wrap: wrap;
        margin-left: auto;
    }

    .btn-hamburguesa {
        margin-right: 8px;
        padding-left: 0;
    }
/* ═══════════════════════════════════════════════════════
   SIDEBAR — soporte para .sidebar-nav / .sidebar-link
   (estructura usada por el vendedor)
   ═══════════════════════════════════════════════════════ */

/* Base: nav y links como columna (desktop y móvil) */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    margin: 0;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}

.sidebar-link:hover {
    background: rgba(0, 0, 0, .04);
}

.sidebar-link.active {
    background: rgba(29, 78, 216, .08);
    font-weight: 600;
    border-left: 3px solid var(--azul-600, #2563eb);
}

.sidebar-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* Header interno del sidebar (título "Panel Vendedor") */
.sidebar-header {
    padding: 8px 16px 12px;
    font-weight: 700;
    color: var(--azul-800, #1e3a8a);
    font-size: .95rem;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    margin-bottom: 8px;
}

/* ─── Móvil: apilado full-width con separadores ─── */
@media (max-width: 768px) {
    .sidebar-link {
        padding: 14px 18px;
        border-bottom: 1px solid rgba(0, 0, 0, .06);
        font-size: .95rem;
    }

    .sidebar-link:last-child {
        border-bottom: none;
    }

    .sidebar-link.active {
        border-left: 4px solid var(--azul-600, #2563eb);
    }

    .sidebar-nav {
        gap: 0;
    }
}
}
@media (max-width: 480px) {
    .logo strong {
        font-size: .85rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
    }
    .logo img {
        max-height: 26px;
        max-width: 80px;
    }
}
/* ═══════════════════════════════════════════════════════
   CARRITO MÓVIL — barra inferior + panel deslizable
   ═══════════════════════════════════════════════════════ */

/* Base: ocultos en desktop */
.carrito-bar-movil,
.carrito-movil-backdrop,
.solo-movil {
    display: none;
}

/* ─── Móvil (≤ 768px) ─── */
@media (max-width: 768px) {

    /* Carrito lateral → panel flotante deslizable */
    .carrito-card {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85vh;
        background: #fff;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .18);
        z-index: 9998;
        transform: translateY(100%);
        transition: transform .3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .carrito-card.carrito-abierto {
        transform: translateY(0);
    }

    .carrito-card .carrito-header {
        padding: 14px 16px;
        border-bottom: 1px solid rgba(0, 0, 0, .06);
        flex-shrink: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .carrito-card .carrito-header h3 {
        margin: 0;
        font-size: 1rem;
    }

    .carrito-card #carrito-vacio,
    .carrito-card .carrito-items,
    .carrito-card .carrito-resumen {
        overflow-y: auto;
        flex: 1;
        padding: 12px 16px;
    }

    .solo-movil {
        display: inline-flex !important;
    }

    /* ─── Barra inferior ─── */
    .carrito-bar-movil {
        /* Por defecto oculta */
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
        color: #fff;
        z-index: 9997;
        padding: 0 16px;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, .2);
        cursor: pointer;
    }

    /* Solo se muestra cuando JS agrega la clase .visible */
    .carrito-bar-movil.visible {
        display: flex !important;
    }

    .carrito-bar-info {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .carrito-bar-icono {
        font-size: 1.6rem;
    }

    .carrito-bar-total {
        font-weight: 700;
        font-size: 1.05rem;
        line-height: 1.1;
    }

    .carrito-bar-cantidad {
        font-size: .75rem;
        opacity: .9;
    }

    .carrito-bar-btn {
        background: rgba(255, 255, 255, .2);
        color: #fff;
        border: none;
        padding: 8px 14px;
        border-radius: 8px;
        font-weight: 600;
        font-size: .85rem;
        cursor: pointer;
    }

    .carrito-bar-btn:active {
        background: rgba(255, 255, 255, .35);
    }

    /* Backdrop */
    .carrito-movil-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 9996;
    }

    .carrito-movil-backdrop.activo {
        display: block;
    }

    /* Espacio para que la barra no tape el último producto */
    .compra-carrito-col {
        padding-bottom: 80px;
    }

    .compra-layout {
        display: block;
    }

    .compra-carrito-col {
        width: 100%;
    }
}