/* =========================================================
   Esquina Imagen — ei.css
   MOBILE-FIRST: los estilos base (sin media query) son los de
   mobile. Los @media (min-width: ...) van agregando/ajustando
   para pantallas más grandes. Mismas clases de siempre, no
   rompe facturas.php / servicios.php / botonera.php /
   camaras.php / login / tv.php.

   Breakpoints usados (equivalentes a los max-width originales):
   481px, 601px, 769px, 901px, 993px
   ========================================================= */

:root {
    --ei-blue: #0baaf9;
    --ei-blue-dark: #093a4b;
    --ei-lime: #cbec64;
    --ei-accent: #1f80e0;

    --ei-radius-sm: 8px;
    --ei-radius-md: 12px;
    --ei-radius-lg: 16px;
    --ei-radius-pill: 999px;

    --ei-shadow-sm: 0 1px 3px rgba(9, 58, 75, 0.08), 0 1px 2px rgba(9, 58, 75, 0.06);
    --ei-shadow-md: 0 4px 14px rgba(9, 58, 75, 0.1), 0 2px 6px rgba(9, 58, 75, 0.06);
    --ei-shadow-lg: 0 12px 32px rgba(9, 58, 75, 0.14), 0 4px 12px rgba(9, 58, 75, 0.08);

    --ei-border: #e6ebf0;
    --ei-text-muted: #6b7787;

    --ei-transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Centrado de tabla de facturación */
table.facturacion-table th,
table.facturacion-table td {
    text-align: center;
    vertical-align: middle;
}

/* Player de canales responsivo (mobile primero) */
.canal-responsive-player {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    min-width: 120px;
    aspect-ratio: 16/9;
    border-radius: var(--ei-radius-md);
    box-shadow: var(--ei-shadow-md);
    background: #16181d;
    display: block;
    transition: box-shadow var(--ei-transition);
}
.canal-responsive-player:hover {
    box-shadow: var(--ei-shadow-lg);
}
@media (min-width: 601px) {
    .canal-responsive-player {
        min-width: 160px;
    }
}
@media (min-width: 901px) {
    .canal-responsive-player {
        min-width: 0;
    }
}

/* Player de cámaras responsivo (mobile primero) */
.cam-responsive-player {
    width: 100% !important;
    height: auto !important;
    max-width: 100vw;
    min-width: 120px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    aspect-ratio: 16/9;
    border-radius: var(--ei-radius-md);
    box-shadow: var(--ei-shadow-md);
    background: #16181d;
    display: block;
}
@media (min-width: 601px) {
    .cam-responsive-player {
        max-width: 100%;
        min-width: 160px;
        margin-left: 0;
        margin-right: 0;
    }
}
@media (min-width: 901px) {
    .cam-responsive-player {
        min-width: 0;
    }
}

.w3-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
/* En mobile, las celdas de grilla (#camaras-grilla / #canales-grilla) van sin
   el padding lateral de 8px que agrega w3-row-padding, para aprovechar el
   ancho completo. Desde 601px se restaura el padding original de w3.css. */
.w3-row-padding > .w3-col {
    padding-left: 0 !important;
    padding-right: 0 !important;
}
@media (min-width: 601px) {
    .w3-row-padding > .w3-col {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

.camaras-header {
    background: linear-gradient(120deg, var(--ei-blue) 0%, var(--ei-accent) 100%);
    color: white;
    padding: 12px;
    border-radius: var(--ei-radius-lg) var(--ei-radius-lg) 0 0;
    box-shadow: var(--ei-shadow-sm);
    margin-bottom: 0;
}
.camaras-card {
    background: #fff;
    border-radius: 0 0 var(--ei-radius-lg) var(--ei-radius-lg);
    box-shadow: var(--ei-shadow-md);
    margin-top: -8px;
    padding: 0;
}
@media (min-width: 901px) {
    .camaras-header {
        padding: 14px 24px 18px 24px;
    }
    .camaras-card {
        padding: 0;
    }
}

.cam-wrap {
    border-radius: var(--ei-radius-sm);
    background: #f8fbff;
    box-shadow: var(--ei-shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition:
        transform var(--ei-transition),
        box-shadow var(--ei-transition);
}
.cam-wrap:hover {
    transform: translateY(-2px);
    box-shadow: var(--ei-shadow-md);
}
.cam-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ei-accent);
    font-size: 1.1em;
    letter-spacing: 0.2px;
}

/* iframe: sin uso actual en el proyecto, se mantiene por compatibilidad */
iframe {
    height: 160px;
}
@media (min-width: 601px) {
    iframe {
        height: 220px;
    }
}
@media (min-width: 901px) {
    iframe {
        height: auto;
    }
}

.video-poster {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 16/9;
    background: #16181d;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ei-radius-sm);
    overflow: hidden;
}
.video-poster-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--ei-radius-sm);
    transition: transform var(--ei-transition);
}
.video-poster:hover .video-poster-img {
    transform: scale(1.02);
}

#camaras-grilla,
#canales-grilla {
    padding-top: 20px;
}

.facturas-header {
    background: linear-gradient(120deg, var(--ei-blue) 0%, var(--ei-accent) 100%);
    color: white;
    padding: 12px;
    border-radius: var(--ei-radius-lg) var(--ei-radius-lg) 0 0;
    box-shadow: var(--ei-shadow-sm);
    margin-bottom: 0;
}
.facturas-card {
    background: #fff;
    border-radius: 0 0 var(--ei-radius-lg) var(--ei-radius-lg);
    box-shadow: var(--ei-shadow-md);
    margin-top: -8px;
    padding: 12px;
}
@media (min-width: 601px) {
    .facturas-header {
        padding: 14px 24px 18px 24px;
    }
    .facturas-card {
        padding: 24px;
    }
}

.facturas-table th {
    background: #f2f6fa;
    font-weight: 600;
    text-align: left;
    padding: 12px 8px;
    color: var(--ei-blue-dark);
}
.facturas-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--ei-border);
}
.facturas-table tr:last-child td {
    border-bottom: none;
}
.facturas-table tbody tr {
    transition: background-color var(--ei-transition);
}
.facturas-table tbody tr:hover {
    background-color: #f7fafd;
}
.right {
    text-align: right;
}

/* Utilidad sin uso actual en el proyecto, se mantiene por compatibilidad */
@media (max-width: 600px) {
    .hide-sm {
        display: none;
    }
}

.ei-bg {
    background-repeat: no-repeat !important;
    background: var(--ei-blue);
    background: linear-gradient(
        180deg,
        rgba(11, 170, 249, 0.2) 0%,
        rgba(203, 236, 100, 0.2) 44%,
        rgba(255, 255, 255, 1) 100%
    );
}

.bill-card {
    max-width: 665px;
    margin: 12px;
    border-radius: var(--ei-radius-lg);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--ei-shadow-md);
}
.bill-header {
    font-size: 14px;
    color: var(--ei-text-muted);
    padding: 10px 16px;
    background: #f7f9fb;
}
.amount {
    font-size: 36px;
    font-weight: 700;
    margin: 6px 0;
    letter-spacing: -1px;
    color: var(--ei-blue-dark);
}
@media (min-width: 481px) {
    .bill-card {
        margin: 18px auto;
    }
    .amount {
        font-size: 46px;
    }
}
.pay-btn {
    background: var(--ei-blue-dark);
    color: #fff;
    border-radius: var(--ei-radius-pill);
    padding: 10px 22px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition:
        background-color var(--ei-transition),
        transform var(--ei-transition),
        box-shadow var(--ei-transition);
    box-shadow: var(--ei-shadow-sm);
}
.pay-btn:hover {
    background-color: #0b4c63;
    box-shadow: var(--ei-shadow-md);
    transform: translateY(-1px);
}
.pay-btn:active {
    transform: translateY(0);
}
.meta {
    color: var(--ei-text-muted);
    font-size: 13px;
    margin-top: 6px;
}
.note {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--ei-border);
    background: #fff;
    font-size: 13px;
    color: #2d7d46;
}
.note .fa-circle-check {
    background: #e8f7ec;
    color: #2d7d46;
    border-radius: 50%;
    padding: 6px;
    font-size: 16px;
}

.vjs-ei.video-js {
    color: #fff;
    background-color: #000;
    min-width: 270px;
}
.vjs-ei .vjs-control-bar {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.25) 100%);
    height: 48px;
}
.vjs-ei .vjs-play-progress,
.vjs-ei .vjs-volume-level {
    background-color: var(--ei-accent);
}
.vjs-ei .vjs-slider {
    background: rgba(255, 255, 255, 0.25);
}
.vjs-ei .vjs-control {
    color: #fff;
    opacity: 0.85;
    transition: opacity var(--ei-transition);
}
.vjs-ei .vjs-control:hover {
    opacity: 1;
}
.vjs-ei .vjs-time-tooltip {
    background: var(--ei-accent);
    color: #fff;
}
.vjs-ei .vjs-fullscreen-control {
    font-size: 1.2em;
    bottom: 3px;
}

.botonera-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}
.botonera-btn {
    flex: 1 1 45%;
    min-width: 140px;
    max-width: 48%;
    margin-bottom: 16px;
    border-radius: var(--ei-radius-md);
    box-shadow: var(--ei-shadow-sm);
    transition:
        transform var(--ei-transition),
        box-shadow var(--ei-transition);
}
.botonera-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--ei-shadow-md);
}

.bgimg {
    background: var(--ei-blue);
    background: linear-gradient(
        180deg,
        rgba(11, 170, 249, 0.2) 0%,
        rgba(203, 236, 100, 0.2) 44%,
        rgba(255, 255, 255, 1) 100%
    );
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Contenedor centrador del login (mobile primero) */
.ei-container {
    height: 80vh !important;
    overflow-y: auto;
}
@media (min-width: 601px) {
    .ei-container {
        height: 90vh !important;
    }
}

/* Logo del login: más chico en mobile para no empujar el formulario
   fuera de pantalla en teléfonos bajos */
.login-logo {
    height: 100px;
}
@media (min-width: 481px) {
    .login-logo {
        height: 150px;
    }
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 20px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--ei-radius-lg);
    box-shadow: var(--ei-shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.6);
}
@media (min-width: 481px) {
    .login-card {
        padding: 32px;
    }
}

/* Sidebar del panel: nunca ocupa más del 88% del viewport en teléfonos
   muy angostos (deja ver el overlay detrás) */
#mySidebar {
    width: min(300px, 88vw) !important;
}

/* Tablas de facturas (mobile primero: compactas) */
#tablaFacturas,
#tablaFacturasHistorial {
    width: 100%;
    table-layout: fixed;
}
#tablaFacturas th,
#tablaFacturas td,
#tablaFacturasHistorial th,
#tablaFacturasHistorial td {
    padding: 6px 4px;
    font-size: 12px;
}
@media (min-width: 601px) {
    #tablaFacturas,
    #tablaFacturasHistorial {
        table-layout: auto;
    }
    #tablaFacturas th,
    #tablaFacturasHistorial th {
        padding: 12px 8px;
        font-size: inherit;
    }
    #tablaFacturas td,
    #tablaFacturasHistorial td {
        padding: 10px 8px;
        font-size: inherit;
    }
}

/* Vencimiento (pendientes) y acciones (historial) quedan ocultas.
   "Fecha de pago" del historial (.col-vencimiento) sí se muestra. */
/* !important: w3.css fuerza display:table-cell en td/th de .w3-table-all */
#tablaFacturas .col-vencimiento,
#tablaFacturasHistorial .col-acciones {
    display: none !important;
}

/* Foco accesible consistente (no rompe nada, solo mejora UX/teclado) */
a:focus-visible,
button:focus-visible,
.pay-btn:focus-visible {
    outline: 2px solid var(--ei-accent);
    outline-offset: 2px;
}

/* Acciones de facturas: apiladas en mobile, en fila desde tablet */
.acciones-facturas {
    flex-direction: column !important;
}
@media (min-width: 769px) {
    .acciones-facturas {
        flex-direction: row !important;
    }
}

/* Estas dos reglas quedan sin condición para asegurar 0 padding/margin
   extra en .w3-main en cualquier tamaño (antes solo aplicaba hasta 992px,
   pero por defecto w3.css tampoco le da padding, así que es equivalente) */
.w3-main {
    padding: 0 !important;
}

/* =========================================================
   Pantalla de inicio (botonera.php + saludo mobile de index.php)
   Mobile-first.
   ========================================================= */

/* Saludo mobile con avatar, en vez de texto plano centrado */
.home-greeting {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 420px;
    margin: 0 auto;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--ei-radius-lg);
    box-shadow: var(--ei-shadow-sm);
}
.home-greeting-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--ei-shadow-sm);
    flex-shrink: 0;
}
.home-greeting-text {
    text-align: left;
    min-width: 0;
}
.home-greeting-hello {
    margin: 0;
    font-size: 12px;
    color: var(--ei-text-muted);
}
.home-greeting-name {
    font-size: 15px;
    color: var(--ei-blue-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Botonera: tarjetas de acceso rápido */
.botonera {
    margin-top: 24px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 4px;
}
.botonera-link {
    width: 100%;
    min-height: 108px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px 12px;
    background: linear-gradient(135deg, var(--ei-blue) 0%, var(--ei-accent) 100%);
    color: #fff;
    text-decoration: none;
    border-radius: var(--ei-radius-md);
    box-shadow: var(--ei-shadow-sm);
    transition:
        transform var(--ei-transition),
        box-shadow var(--ei-transition);
}
.botonera-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--ei-shadow-md);
}
.botonera-link:active {
    transform: translateY(0);
}
.botonera-icon {
    font-size: 24px;
    line-height: 1;
}
.botonera-label {
    font-size: 16px;
    font-weight: 600;
}
.botonera-sub {
    font-size: 11.5px;
    font-weight: 400;
    opacity: 0.85;
}
@media (min-width: 601px) {
    .botonera-link {
        min-height: 140px;
        padding: 24px 16px;
        gap: 8px;
    }
    .botonera-icon {
        font-size: 30px;
    }
    .botonera-label {
        font-size: 18px;
    }
    .botonera-sub {
        font-size: 12.5px;
    }
}

.login-logo {
    height: 150px;
}

/* Carrusel de novedades: tarjeta con marco propio, para que nunca se vea
   como un espacio vacío/roto mientras carga o si no hay slides */
.home-promo {
    max-width: 800px;
    margin: 28px auto 0;
    background: #fff;
    border-radius: var(--ei-radius-lg);
    box-shadow: var(--ei-shadow-sm);
    padding: 16px 8px 4px;
}
.home-promo-title {
    margin: 0 0 12px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ei-blue-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
#swiperSlides:empty {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#swiperSlides:empty::before {
    content: "Cargando novedades...";
    color: var(--ei-text-muted);
    font-size: 13px;
}
@media (min-width: 601px) {
    .home-promo {
        padding: 20px 16px 8px;
    }
    #swiperSlides:empty {
        min-height: 260px;
    }
}

/* =========================================================
   Panel de facturas (facturas.php)
   Mobile-first.
   ========================================================= */

/* Títulos de sección dentro de la tarjeta de facturas */
.facturas-card h4 {
    color: var(--ei-blue-dark);
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

/* Total en la tabla: destacado, igual paleta que .amount */
.facturas-table td.col-total {
    font-weight: 700;
    color: var(--ei-blue-dark);
}

/* Estado como badge de color en vez de texto plano */
.estado-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--ei-radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.estado-pendiente {
    color: #b3261e;
}
.estado-procesando {
    background: #fff4de;
    color: #9a6700;
}
.estado-pagado {
    background: #e8f7ec;
    color: #2d7d46;
}

/* Estado vacío de las tablas (sin facturas / sin pagos) */
.tabla-vacia {
    text-align: center !important;
    color: var(--ei-text-muted);
    padding: 22px 8px !important;
    font-style: italic;
    font-size: 13px;
}

/* Botón de pago: estado deshabilitado más claro, estado activo con más peso */
#pagarSeleccionadasMP {
    transition:
        background-color var(--ei-transition),
        box-shadow var(--ei-transition),
        transform var(--ei-transition);
}
#pagarSeleccionadasMP:disabled {
    box-shadow: none !important;
    cursor: not-allowed;
}
#pagarSeleccionadasMP:not(:disabled) {
    box-shadow: var(--ei-shadow-sm);
}
#pagarSeleccionadasMP:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--ei-shadow-md);
}
#seleccionadasContador {
    color: var(--ei-blue-dark) !important;
}

/* =========================================================
   Teléfonos muy angostos (<= 400px, incl. 320px / 280px)
   ========================================================= */
html,
body {
    overflow-x: hidden;
}
img,
video,
canvas {
    max-width: 100%;
}

/* Botonera: una tarjeta por fila, ancho completo */
.botonera-btn {
    min-width: 0;
}
@media (max-width: 400px) {
    .botonera-grid {
        gap: 10px;
    }
    .botonera-btn {
        flex: 1 1 100%;
        max-width: 100%;
        margin-bottom: 0;
    }
    .botonera-link {
        min-height: 88px;
        padding: 14px 10px;
    }
    .home-greeting {
        padding: 10px 12px;
    }
    .home-promo {
        margin-top: 18px;
    }
    .home-promo-title {
        font-size: 13px;
    }

    /* Barra superior compacta */
    .w3-top .w3-bar-item {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Facturas: menos márgenes y tablas más compactas */
    .w3-main.w3-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    .facturas-header {
        padding: 10px 12px;
    }
    .facturas-header h2 {
        font-size: 18px;
        margin: 0;
    }
    .facturas-card {
        padding: 8px;
    }
    .facturas-card h4 {
        font-size: 13px;
    }
    #tablaFacturas th,
    #tablaFacturas td,
    #tablaFacturasHistorial th,
    #tablaFacturasHistorial td {
        padding: 6px 2px;
        font-size: 11px;
        word-break: break-word;
    }
    #tablaFacturas .col-seleccion {
        width: 28px !important;
    }
    .estado-badge {
        padding: 2px 6px;
        font-size: 10px;
    }
    .acciones-facturas {
        gap: 10px !important;
        padding: 6px 0 !important;
        margin-top: 12px !important;
    }
    #pagarSeleccionadasMP {
        width: 100%;
        min-width: 0 !important;
        padding: 8px 10px;
        font-size: 13px;
    }
    .bill-card {
        margin: 8px;
    }
    .amount {
        font-size: 30px;
    }
    .login-card {
        padding: 16px;
    }
}
@media (max-width: 300px) {
    .estado-badge {
        font-size: 9px;
        padding: 2px 4px;
    }
    #tablaFacturas th,
    #tablaFacturas td,
    #tablaFacturasHistorial th,
    #tablaFacturasHistorial td {
        font-size: 10px;
    }
    .facturas-header h2 {
        font-size: 16px;
    }
}

/* Tablas de facturas en mobile: anchos de columna explícitos para que el
   badge de estado siempre quepa dentro de su celda (layout fijo) */
@media (max-width: 600px) {
    #tablaFacturas .col-seleccion {
        width: 12%;
    }
    #tablaFacturas .col-periodo {
        width: 30%;
    }
    #tablaFacturas .col-total {
        width: 24%;
    }
    #tablaFacturas .col-estado {
        width: 34%;
    }
    #tablaFacturasHistorial .col-periodo {
        width: 22%;
    }
    #tablaFacturasHistorial .col-vencimiento {
        width: 28%;
    }
    #tablaFacturasHistorial .col-total {
        width: 22%;
    }
    #tablaFacturasHistorial .col-estado {
        width: 28%;
    }
    .facturas-table .estado-badge {
        display: inline-block;
        max-width: 100%;
        box-sizing: border-box;
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
        padding: 3px 6px;
        font-size: 10.5px;
    }
}
@media (max-width: 400px) {
    #tablaFacturas .col-seleccion {
        width: 11%;
    }
    .facturas-table .estado-badge {
        font-size: 9.5px;
        padding: 2px 4px;
    }
}

/* Fecha de pago del historial: prolija, centrada y sin cortar letras */
#tablaFacturasHistorial .col-vencimiento {
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
}
