/* FacturasGDS — estilos base. Los colores de marca vienen de --brand y --brand-2
   (definidos por empresa en layouts/base.blade.php). */

:root {
    --brand-oscuro: color-mix(in srgb, var(--brand) 82%, #000);
    --brand-suave: color-mix(in srgb, var(--brand) 10%, #fff);
    --fondo: #f4f6f9;
    --borde: #e3e7ee;
    --texto-2: #5b6575;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: #1d2533;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 31, 78, 121;
    --bs-link-hover-color: var(--brand-oscuro);
    --sidebar-ancho: 250px;
}

body {
    background: var(--fondo);
    font-size: .925rem;
}

a { color: var(--brand); }
a:hover { color: var(--brand-oscuro); }

/* ---------- Botones y formularios con color de marca ---------- */

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-oscuro);
    --bs-btn-hover-border-color: var(--brand-oscuro);
    --bs-btn-active-bg: var(--brand-oscuro);
    --bs-btn-active-border-color: var(--brand-oscuro);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-oscuro);
    --bs-btn-active-border-color: var(--brand-oscuro);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: color-mix(in srgb, var(--brand) 55%, #fff);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 18%, transparent);
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.form-label { font-weight: 500; margin-bottom: .3rem; }
.form-text { color: var(--texto-2); }

.page-link { color: var(--brand); }
.active > .page-link, .page-link.active { background-color: var(--brand); border-color: var(--brand); }

/* ---------- Estructura ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-ancho);
    background: var(--brand-oscuro);
    color: #fff;
    display: flex;
    flex-direction: column;
}

/* Bootstrap deja el offcanvas transparente (!important) en pantallas grandes */
.sidebar.offcanvas-lg,
.sidebar.offcanvas-lg.show {
    background-color: var(--brand-oscuro) !important;
    color: #fff;
}

@media (min-width: 992px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        flex-shrink: 0;
        overflow-y: auto;
    }
}

@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: var(--brand-oscuro); }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-marca {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #fff;
    text-decoration: none;
    min-width: 0;
}
.sidebar-marca:hover { color: #fff; }

.sidebar-logo {
    max-height: 44px;
    max-width: 190px;
    object-fit: contain;
    background: #fff;
    border-radius: .4rem;
    padding: .25rem .4rem;
}

.sidebar-iniciales {
    width: 38px;
    height: 38px;
    border-radius: .5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-2);
    color: #1d2533;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-nombre {
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-nombre small { font-size: .75rem; }

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

.nav-seccion {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255, 255, 255, .5);
    padding: 1rem .75rem .35rem;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: .45rem;
    color: rgba(255, 255, 255, .85);
    text-decoration: none;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
}
.nav-item-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-item-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item-link.active { background: rgba(255, 255, 255, .14); color: #fff; border-left-color: var(--brand-2); font-weight: 500; }
.nav-item-link.disabled { opacity: .5; cursor: default; }
.nav-item-link.disabled:hover { background: none; }

.badge-pronto {
    margin-left: auto;
    font-size: .65rem;
    background: rgba(255, 255, 255, .15);
    border-radius: 1rem;
    padding: .1rem .45rem;
}

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

.app-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--borde);
    padding: .6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: 58px;
}
.topbar-titulo { min-width: 0; }

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
}

.contenido { padding: 1.5rem; max-width: 1400px; width: 100%; }

@media (max-width: 575.98px) {
    .contenido { padding: 1rem; }
    .topbar { padding: .5rem 1rem; }
}

.encabezado {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.encabezado-acciones { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumb a { text-decoration: none; }

.aviso-suscripcion {
    padding: .55rem 1.5rem;
    font-size: .875rem;
    display: flex;
    gap: .5rem;
    align-items: center;
}
.aviso-info { background: #e8f1fb; color: #1b4a7a; }
.aviso-alerta { background: #fff3cd; color: #7a5a00; }

/* ---------- Componentes ---------- */

.card {
    border: 1px solid var(--borde);
    border-radius: .65rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--borde);
    font-weight: 600;
    padding: .85rem 1.1rem;
}
.card-body { padding: 1.1rem; }

.tarjeta-dato .valor { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tarjeta-dato .etiqueta { color: var(--texto-2); font-size: .82rem; }
.tarjeta-dato .icono {
    width: 42px;
    height: 42px;
    border-radius: .6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-suave);
    color: var(--brand);
    font-size: 1.25rem;
}

.table { --bs-table-hover-bg: #f7f9fc; margin-bottom: 0; }
.table > thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--texto-2);
    font-weight: 600;
    background: #fafbfd;
    white-space: nowrap;
    border-bottom-width: 1px;
}
.table > :not(caption) > * > * { padding: .65rem .85rem; vertical-align: middle; }
.table-card { overflow-x: auto; }
.fila-link { cursor: pointer; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge-estado { font-weight: 500; padding: .35em .6em; border-radius: 1rem; font-size: .75rem; }
.estado-activa, .estado-aprobado { background: #e6f4ea; color: #1e7b34; }
.estado-prueba { background: #e8f1fb; color: #1b4a7a; }
.estado-suspendida, .estado-rechazado, .estado-anulado { background: #fde8e8; color: #a61b1b; }
.estado-inactivo { background: #eef0f3; color: #5b6575; }
.estado-pendiente { background: #fff3cd; color: #7a5a00; }

.cant-pos { color: #1e7b34; }
.cant-neg { color: #b42318; }

.filtros { background: #fff; border: 1px solid var(--borde); border-radius: .65rem; padding: .85rem; margin-bottom: 1rem; }

.vacio { text-align: center; padding: 2.5rem 1rem; color: var(--texto-2); }
.vacio i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

.dl-datos dt { color: var(--texto-2); font-weight: 500; font-size: .82rem; }
.dl-datos dd { margin-bottom: .75rem; }

.seccion-form { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-2); font-weight: 600; margin: 1.25rem 0 .75rem; }
.seccion-form:first-child { margin-top: 0; }

.muestra-color { width: 2.6rem; padding: .25rem; }

/* ---------- Login ---------- */

.login-pagina {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--brand) 22%, transparent) 0, transparent 45%),
        radial-gradient(circle at 85% 85%, color-mix(in srgb, var(--brand-2) 20%, transparent) 0, transparent 40%),
        var(--fondo);
}

.login-caja { width: 100%; max-width: 410px; }
.login-caja .card { border-radius: 1rem; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.login-marca { text-align: center; margin-bottom: 1.5rem; }
.login-marca img { max-height: 80px; max-width: 260px; object-fit: contain; }
.login-marca .sidebar-iniciales { width: 56px; height: 56px; font-size: 1.3rem; border-radius: .8rem; }
.login-pie { text-align: center; font-size: .8rem; color: var(--texto-2); margin-top: 1.25rem; }

/* ---------- Pantallas de mensaje ---------- */

.mensaje-pagina { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; text-align: center; }
.mensaje-pagina .codigo { font-size: 4rem; font-weight: 700; color: var(--brand); line-height: 1; }

/* ---------- Portal de clientes ---------- */

.portal-barra {
    background: #fff;
    border-bottom: 3px solid var(--brand);
    padding: .6rem 0;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.portal-contenedor { max-width: 1100px; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; width: 100%; }
.portal-marca { display: flex; align-items: center; gap: .6rem; color: var(--bs-body-color); text-decoration: none; }
.portal-marca img { max-height: 44px; max-width: 200px; object-fit: contain; }
.portal-nav { gap: .25rem; margin-left: 1rem; }
.portal-nav a { padding: .45rem .8rem; border-radius: .45rem; color: var(--texto-2); text-decoration: none; font-weight: 500; }
.portal-nav a:hover { background: var(--brand-suave); color: var(--brand); }
.portal-nav a.active { background: var(--brand-suave); color: var(--brand); }
.portal-saldo { border-top: 4px solid var(--brand); }

.btn-mp {
    --bs-btn-bg: #009ee3;
    --bs-btn-border-color: #009ee3;
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #007eb5;
    --bs-btn-hover-border-color: #007eb5;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #006a99;
    --bs-btn-active-color: #fff;
}

.badge-menu { margin-left: auto; background: var(--brand-2); color: #1d2533; border-radius: 1rem; font-size: .7rem; padding: .1rem .5rem; font-weight: 600; }

/* ---------- Reportes ---------- */
.barra-reporte { height: 4px; background: #eef0f3; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.barra-reporte span { display: block; height: 100%; background: var(--brand); border-radius: 2px; }
.min-w-0 { min-width: 0; }

/* ---------- Menú lateral en celulares ----------
   El panel tiene alto fijo: la lista de opciones tiene que poder desplazarse */
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
    .sidebar-header, .sidebar-footer { flex-shrink: 0; }
    .sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2rem;
    }
}

/* Secciones del menú que se despliegan y contraen */
.nav-grupo-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; background: none; border: 0; text-align: left; cursor: pointer; }
.nav-grupo-toggle:hover { color: rgba(255, 255, 255, .85); }
.nav-grupo-toggle .bi { font-size: .7rem; transition: transform .15s ease; }
.nav-grupo.cerrado .nav-grupo-toggle .bi { transform: rotate(-90deg); }
.nav-grupo.cerrado .nav-grupo-items { display: none; }

/* Impresión de pantallas (reportes): solo el contenido */
@media print {
    .sidebar, .topbar, .aviso-suscripcion, .filtros, .encabezado-acciones, .btn, .breadcrumb, form, .alert { display: none !important; }
    .app-shell, .app-main, .contenido { display: block !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
    body { background: #fff !important; }
    .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ccc !important; }
    .card-header a { display: none !important; }
    .row > [class*="col-"] { flex: 0 0 auto; }
    .col-xl-6 { width: 50% !important; }
    .col-xl-3, .col-sm-6 { width: 25% !important; }
    a { color: inherit !important; text-decoration: none !important; }
    @page { size: A4; margin: 12mm; }
}
