/* =========================================
   🌍 VARIABLES THEME
========================================= */

body.light-mode {
    --bg-main: #F2F4F7;
    --bg-card: #FFFFFF;
    --text-main: #1A1A1A;
    --text-secondary: #6b7280;
    --border-color: #E5E5E5;
    --input-bg: #FFFFFF;
}

body.dark-mode {
    --bg-main: #020617;
    --bg-card: #0f172a;
    --text-main: #ffffff;
    --text-secondary: #94a3b8;
    --border-color: #1e293b;
    --input-bg: #020617;
}

/* =========================================
   🌍 BASE GLOBAL
========================================= */

body {
    background: var(--bg-main);
    color: var(--text-main);
}

/* =========================================
   📦 LAYOUT
========================================= */

.main {
    padding: 20px 30px;
}

/* =========================================
   📚 SIDEBAR
========================================= */

.sidebar {
    width: 250px;
    background: linear-gradient(180deg,#0b111c,#020617);
    color: white;
}

body.light-mode .sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border-color);
}

    body.light-mode .sidebar a {
        color: #1a1a1a;
    }

.sidebar .active {
    background: linear-gradient(135deg,#D81E24,#7a0d0f);
    border-radius: 10px;
}

body.light-mode .sidebar .active {
    background: rgba(216,30,36,0.15);
    color: #D81E24;
    border-left: 4px solid #D81E24;
}

/* =========================================
   🔝 HEADER
========================================= */

.top-row {
    background: linear-gradient(145deg,#0f172a,#020617);
    border-radius: 16px;
    padding: 15px 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

body.light-mode .top-row {
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* TEXTO HEADER */

.top-row .logo,
.top-row .title,
.top-row strong {
    color: var(--text-main);
}

.top-row small {
    color: var(--text-secondary);
}

.top-row .user-role {
    color: #D81E24;
}

/* =========================================
   🎛️ FILTROS
========================================= */

.filter-luxe {
    border-radius: 14px;
    padding: 20px;
}

body.dark-mode .filter-luxe {
    background: linear-gradient(145deg,#0f172a,#020617);
    border: 1px solid rgba(255,255,255,0.05);
}

body.light-mode .filter-luxe {
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
}

.input-orsan-box {
    border-radius: 10px;
    padding: 10px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

/* =========================================
   📊 METRIC CARDS
========================================= */

.metric-card.dark {
    background: linear-gradient(145deg,#0c0f14,#0f131a);
    border-radius: 18px;
    padding: 28px 20px;
    text-align: center;
    position: relative;
}

    .metric-card.dark::before {
        content: "";
        position: absolute;
        top: 0;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg,#D81E24,#400000);
    }

.metric-icon i {
    color: #D81E24;
}

body.light-mode .metric-card.dark {
    background: #ffffff;
    color: #1a1a1a;
}

/* =========================================
   📋 TABLA
========================================= */

.table-wrapper {
    border-radius: 18px;
    overflow: hidden;
}

body.dark-mode .table-wrapper {
    background: linear-gradient(145deg,#0f172a,#020617);
}

body.light-mode .table-wrapper {
    background: #ffffff;
}

.thead-orsan {
    border-bottom: 2px solid #D81E24;
}

.table td,
.table th {
    padding: 16px 14px;
}

body.dark-mode .table td,
body.dark-mode .table th {
    color: rgba(255,255,255,0.85);
}

body.light-mode .table td {
    color: #2a2a2a;
}

body.light-mode .table th {
    color: #111;
}

/* =========================================
   🔘 BOTONES
========================================= */

.btn-orsan-primary {
    background: linear-gradient(135deg,#D81E24,#B71C1C);
    color: white;
    border-radius: 10px;
    padding: 10px 18px;
    border: none;
}

.btn-orsan-secondary {
    background: #111;
    color: white;
    border-radius: 10px;
    padding: 10px 18px;
}

/* =========================================
   🔘 BOTONES ACCION
========================================= */

.btn-action-luxe {
    border-radius: 8px;
    padding: 6px 10px;
    transition: 0.2s;
}

body.dark-mode .btn-action-luxe {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
}

body.light-mode .btn-action-luxe {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #333;
}

/* =========================================
   🔴 BADGES
========================================= */

.badge-orsan {
    min-width: 90px;
    text-align: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-nuevo {
    background: #D81E24;
    color: white;
}

.badge-activo {
    background: #000;
    color: white;
}

.badge-cerrado {
    background: #9E9E9E;
    color: white;
}

.badge-resuelto {
    background: #6b7280;
    color: white;
}

/* =========================================
   🔘 BOTON LOGOUT
========================================= */

.btn-logout {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s ease;
    border: none;
}

body.dark-mode .btn-logout {
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}

body.light-mode .btn-logout {
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #e5e5e5;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* =========================================
   💬 COMMENTS SCROLL
========================================= */

.comments-body {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

    .comments-body::-webkit-scrollbar {
        width: 6px;
    }

    .comments-body::-webkit-scrollbar-thumb {
        background: #D81E24;
        border-radius: 10px;
    }

/* =========================================
   🎫 FORMULARIO TICKET
========================================= */

.ticket-form-wrapper {
    background: linear-gradient(145deg,#0f172a,#020617);
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.05);
    padding: 30px;
}

.ticket-form-body {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.ticket-form-actions {
    margin-top: 25px;
    display: flex;
    gap: 14px;
}

.section-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
}

.section-divider {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 20px;
}

body.light-mode .section-divider {
    border-bottom: 1px solid #e5e7eb;
}

/* =========================================
   🎫 FORMULARIO TICKET
========================================= */

.ticket-form-body {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* más estilos... */

/* =========================================
   🔧 FIX CONTRASTE DARK MODE
========================================= */

body.dark-mode .ticket-form-body label,
body.dark-mode .section-title,
body.dark-mode .form-check-label {
    color: rgba(255,255,255,0.85);
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
}

    body.dark-mode input::placeholder,
    body.dark-mode textarea::placeholder {
        color: rgba(255,255,255,0.45);
    }

/* LIGHT MODE */

body.light-mode .ticket-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

/* DARK MODE */

body.dark-mode .ticket-card {
    background: linear-gradient(145deg,#0f172a,#020617);
}

/* =========================================================
   SIN EFECTO HOVER (Observaciones Portal Afiliados)
   Los componentes se quedan fijos al pasar el mouse.
   Estas reglas igualan el estado hover de Bootstrap a su
   estado normal; no se modifica bootstrap.min.css.
   Se conservan el cursor de manita y el contorno de foco
   (teclado) para no perder accesibilidad.
   ========================================================= */

:root,
[data-bs-theme] {
    --bs-link-hover-color: var(--bs-link-color);
    --bs-link-hover-color-rgb: var(--bs-link-color-rgb);
}

.btn:hover {
    color: var(--bs-btn-color);
    background-color: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
}

.btn-close:hover {
    opacity: var(--bs-btn-close-opacity);
}

.dropdown-item:hover {
    color: var(--bs-dropdown-link-color);
    background-color: transparent;
}

.nav-link:hover {
    color: var(--bs-nav-link-color);
}

.page-link:hover {
    color: var(--bs-pagination-color);
    background-color: var(--bs-pagination-bg);
    border-color: var(--bs-pagination-border-color);
}

.list-group-item-action:hover {
    color: var(--bs-list-group-action-color);
    background-color: var(--bs-list-group-bg);
}

/* =========================================================
   REPORTES Y COMPROBANTES — DISEÑO ÚNICO (réplica del legacy)
   Todas las pantallas de Reportes y Comprobantes Fiscales usan
   el mismo panel: título + "Por Estación / Por Grupo" arriba,
   filtros, acciones a la derecha y tabla con encabezado azul
   (mismo azul que el portal anterior y que Inicio).
   ========================================================= */

.ug-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(15,23,42,.06);
}

.ug-panel-encabezado {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.ug-titulo {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
}

.ug-acciones {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .75rem;
}

/* Selector Por Estación / Por Grupo (también "Rango de fechas / Años") */
.ug-segmento {
    display: inline-flex;
    padding: 3px;
    gap: 3px;
    border-radius: 12px;
    background: #e2e8f0;
}

.ug-segmento button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 9px;
    padding: 5px 12px;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.ug-segmento button.activo {
    background: #ffffff;
    color: #1d4ed8;
    box-shadow: 0 2px 6px rgba(15,23,42,.12);
}

.ug-segmento button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.ug-segmento button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Filtros y botones compactos en todos los reportes. Los selectores llevan el prefijo .ug-panel
   para ganarle a los estilos aislados (.razor.css) de cada pantalla, que se cargan después. */
.ug-panel .documentos-toolbar .toolbar-filters,
.ug-panel .reporte-filtros {
    gap: 12px;
}

.ug-panel .documentos-toolbar .filter-group {
    gap: 4px;
}

.ug-panel .documentos-toolbar .filter-group label,
.ug-panel .reporte-filtros .form-label {
    margin-bottom: 0;
    font-size: 13px;
}

.ug-panel .reporte-filtro {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ug-panel .documentos-toolbar .premium-select,
.ug-panel .reporte-filtros .form-control,
.ug-panel .reporte-filtros .form-select {
    height: 36px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 14px;
    border-radius: 9px;
}

.ug-panel .ug-acciones .btn-download,
.ug-panel .ug-acciones .btn-secondary,
.ug-panel .reporte-filtros .btn {
    height: 36px;
    padding: 0 14px;
    gap: 8px;
    font-size: 14px;
    border-radius: 9px;
}

/* EXPORTAR deshabilitado mientras la tabla no tenga información */
.ug-panel .ug-acciones .btn-download:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Fecha en formato de México (dd/MM/yyyy). El input type="date" toma el formato del idioma del navegador,
   así que se captura en un texto y el calendario nativo se abre desde el botón (showPicker). */
.fecha-mx {
    position: relative;
}

    .fecha-mx > input[type="text"] {
        width: 100%;
        padding-right: 38px;
    }

.fecha-mx-calendario {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.fecha-mx-boton {
    position: absolute;
    top: 0;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: .7;
    cursor: pointer;
}

    .fecha-mx-boton:hover {
        opacity: 1;
    }

/* Dentro del panel, las barras y tablas internas ya no son tarjetas aparte */
.ug-panel div.documentos-toolbar {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.ug-panel div.table-wrapper {
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: none;
    background: #ffffff;
}

/* Renglones de las tablas un poco más bajos (antes 16px de alto en premium-table); ug-tabla usa los mismos valores */
.ug-panel table.premium-table tbody td {
    padding-top: 11px;
    padding-bottom: 11px;
}

.ug-panel table.premium-table thead th {
    padding-top: 13px;
    padding-bottom: 13px;
}

/* Renglón de TOTALES: mismo margen lateral que las celdas del cuerpo (16px 18px), para que
   "TOTALES" no quede pegado al borde y las sumas queden alineadas con sus columnas. */
.ug-panel table.premium-table tfoot td {
    padding: 10px 18px;
}

/* Pie de tabla (Mostrando… + paginación) más delgado */
.ug-panel div.table-footer {
    padding: 8px 18px;
}

.ug-panel .table-footer .pagination-orsan {
    margin-top: 0;
}

    .ug-panel .table-footer .pagination-orsan .page-nav,
    .ug-panel .table-footer .pagination-orsan .page-number {
        padding: 3px 10px;
        min-width: 34px;
    }

/* Encabezado de tablas en azul, como el legacy */
.ug-panel table.premium-table thead,
body.light-mode .ug-panel table.premium-table thead {
    background: #0d47a1;
}

.ug-panel table.premium-table thead th,
body.light-mode .ug-panel table.premium-table thead th {
    color: #ffffff;
    border-bottom: 0;
}

.ug-panel thead.table-dark {
    --bs-table-bg: #0d47a1;
    --bs-table-color: #ffffff;
    --bs-table-border-color: #1e40af;
}

/* MODO OSCURO */
body.dark-mode .ug-panel {
    background: linear-gradient(180deg, rgba(8,15,30,.98), rgba(3,8,20,.98));
    border-color: rgba(37,99,235,.15);
}

body.dark-mode .ug-titulo {
    color: #f8fafc;
}

body.dark-mode .ug-segmento {
    background: #1e293b;
}

body.dark-mode .ug-segmento button {
    color: #cbd5e1;
}

body.dark-mode .ug-segmento button.activo {
    background: #0f172a;
    color: #93c5fd;
}

body.dark-mode .ug-panel div.table-wrapper {
    background: transparent;
    border-color: #1e293b;
}

/* Tabla de los reportes de precios y cargas: mismo aspecto que Comprobantes */
.ug-tabla-contenedor {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.ug-tabla {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.ug-tabla thead th {
    position: sticky;
    top: 0;
    padding: 13px 18px;
    background: #0d47a1;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

/* Mismo cuerpo que las tablas de Transacciones / Facturación (premium-table): renglones blancos
   con línea divisoria, letra de 14px; sin renglones alternados en gris. */
.ug-tabla tbody td {
    padding: 11px 18px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
}

.ug-tabla td.ug-tabla-texto,
.ug-tabla th.ug-tabla-texto {
    text-align: left;
}

.ug-sin-datos {
    padding: 2rem 1rem;
    text-align: center;
    color: #64748b;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
}

body.dark-mode .ug-tabla-contenedor {
    border-color: #1e293b;
}

body.dark-mode .ug-tabla tbody td {
    border-top-color: #1e293b;
}

body.dark-mode .ug-sin-datos {
    color: #94a3b8;
    border-color: #334155;
}

/* =========================================================
   DATOS DE SOLO LECTURA (Datos de la Estación, Expediente Digital)
   Se muestran como texto y no como cajas editables: un recuadro
   suave con borde gris claro y la etiqueta en versalitas.
   ========================================================= */

body label:has(+ div.ug-dato) {
    display: block;
    margin-bottom: 6px;
    color: #64748b;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ug-dato {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #0f172a;
    font-size: .98rem;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.ug-dato:empty::before {
    content: "—";
    color: #94a3b8;
    font-weight: 400;
}

body.dark-mode label:has(+ div.ug-dato) {
    color: #94a3b8;
}

body.dark-mode .ug-dato {
    background: rgba(30, 41, 59, .55);
    border-color: #1e293b;
    color: #f1f5f9;
}

body.dark-mode .ug-dato:empty::before {
    color: #64748b;
}

/* =========================================================
   RESPONSIVO GENERAL
   Tableta (≤ 991px), celular (≤ 767px) y celular chico (≤ 575px).
   Las tablas anchas se desplazan dentro de su recuadro; la página
   nunca se desborda a los lados.
   ========================================================= */

html,
body {
    overflow-x: hidden;
}

img,
video {
    max-width: 100%;
    height: auto;
}

.table-wrapper,
.ug-tabla-contenedor,
.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
    .ug-panel {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .ug-titulo {
        font-size: 1.3rem;
    }
}

@media (max-width: 767.98px) {
    .ug-panel {
        padding: 1rem;
        gap: 1rem;
    }

    .ug-panel-encabezado {
        flex-direction: column;
        align-items: stretch;
    }

    .ug-segmento {
        width: 100%;
    }

    .ug-segmento button {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
    }

    .ug-acciones,
    .ug-acciones .dropdown {
        width: 100%;
    }

    .ug-acciones > button,
    .ug-acciones .btn-download,
    .ug-acciones .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    /* Filtros de Reportes y Comprobantes: uno debajo de otro */
    .ug-panel div.documentos-toolbar,
    .ug-panel div.documentos-toolbar .toolbar-left,
    .ug-panel div.documentos-toolbar .toolbar-filters {
        display: grid;
        grid-template-columns: 1fr;
        gap: .75rem;
        width: 100%;
    }

    .ug-panel div.documentos-toolbar .filter-group,
    .ug-panel .premium-select {
        width: 100%;
        min-width: 0;
    }

    .ug-panel .reporte-filtros > * {
        flex: 1 1 100%;
        min-width: 0;
    }

    .ug-panel .reporte-filtros .btn {
        width: 100%;
    }

    /* Tablas: conservan su ancho legible y se desplazan horizontalmente */
    .ug-panel table.premium-table {
        min-width: 680px;
    }

    .ug-tabla {
        min-width: 520px;
    }

    .ug-dato {
        font-size: .95rem;
    }
}

@media (max-width: 575.98px) {
    .ug-panel {
        padding: .85rem;
        border-radius: 14px;
    }

    .ug-titulo {
        font-size: 1.15rem;
    }

    .ug-segmento button {
        font-size: .9rem;
    }
}

/* Cuadrículas de varias columnas sin regla para pantallas chicas
   (Comprobantes, Facturación, Domiciliación y Tickets): una sola columna en celular.
   Se repite la clase para ganarle a los estilos propios de cada pantalla. */
@media (max-width: 767.98px) {
    body .chart-summary.chart-summary,
    body .top-actions.top-actions,
    body .kpi-row.kpi-row,
    body .detalle-grid.detalle-grid,
    body .detail-grid.detail-grid,
    body .contacto-grid.contacto-grid,
    body .edit-grid-main.edit-grid-main,
    body .edit-grid.edit-grid,
    body .firma-body.firma-body {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   TOQUE DE COLOR DEL SISTEMA (rojo UltraGas + azul)
   El rojo de la marca y el azul de las tablas se combinan:
   acento degradado arriba de los paneles, barra junto a los
   títulos y una línea roja bajo el encabezado azul de las tablas.
   ========================================================= */

.ug-panel {
    position: relative;
    overflow: hidden;
}

.ug-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #D81E24, #2563eb);
}

.ug-titulo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.ug-titulo::before {
    content: "";
    width: 5px;
    height: 1.1em;
    border-radius: 3px;
    background: linear-gradient(180deg, #D81E24, #2563eb);
}

.ug-panel table.premium-table thead th,
body.light-mode .ug-panel table.premium-table thead th,
.ug-tabla thead th {
    border-bottom: 3px solid #D81E24;
}

.ug-panel thead.table-dark th {
    border-bottom: 3px solid #D81E24;
}

/* El segmento activo lleva un subrayado rojo discreto */
.ug-segmento button.activo {
    box-shadow: inset 0 -2px 0 #D81E24, 0 2px 6px rgba(15, 23, 42, .12);
}
