/* repcontrol.css - Estilos principales */
:root {
    --header-height: 40px;
    --nav-width: 250px;
    --body-bg: #f3f2f1; /* NeutralLighter */
    --card-bg: #ffffff;

    /* Fluent UI Overrides for High Density */
    --control-height: 32px;
    --font-size-base: 13px;
    --z-index-dropdown: 9999;
}

/* Animación de rotación de icono de sincronización */
@keyframes spinIcon {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

html {
    height: 100%;
}

body {
    overflow: hidden;
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* Layout Grid - 2 filas: header, wrapper (sin footer flotante) */
.main-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) auto 1fr;
    height: 100vh;
}

.layout-header {
    grid-column: 1;
    grid-row: 1;
    background: white;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
    height: var(--header-height);
}

/* Sidebar removido - menú ahora es horizontal */

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.layout-wrapper {
    grid-column: 1;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-height: 0;
}


.layout-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;    /* scroll */
    overflow-x: visible; /* dropdowns */
    padding: 0.75rem;
}

/* Auth Pages Centering */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--body-bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

/* Utility Classes */
.gap-2 { gap: 0.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-muted { color: #595959; }

/* App Surface - Reemplazo estándar para FluentCard */
.app-surface {
    background-color: #ffffff;
    border: 1px solid #edebe9;
    border-radius: 6px;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    position: relative;
    overflow: visible;
}

/* ============================================
   FIX PARA FLUENT SELECT EN DATAGRID
   ============================================ */

/* Permitir que las celdas muestren el dropdown fuera de sus límites */
.fluent-data-grid-cell {
    overflow: visible !important;
}

/* Dar prioridad al dropdown y mejorar su apariencia */
fluent-select::part(listbox) {
    z-index: var(--z-index-dropdown) !important;
    background: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-radius: 4px !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}

/* Mejorar las opciones del dropdown */
fluent-option::part(content) {
    padding: 8px 12px !important;
    white-space: nowrap;
    font-size: var(--font-size-base);
}

fluent-option:hover::part(content) {
    background-color: #f3f2f1 !important;
    cursor: pointer;
}

/* Ajustes para cuando el dropdown se abre arriba/abajo */
fluent-select[position="below"]::part(listbox) {
    margin-top: 2px !important;
}

fluent-select[position="above"]::part(listbox) {
    margin-bottom: 2px !important;
}

/* Mantén tus estilos existentes */
.checkbox-group-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Estilos para Biblioteca de Productos Industrial */
.industrial-grid {
    --data-grid-cell-padding: 4px 8px;
    font-size: 0.85rem;
}

.action-buttons-group {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.action-buttons-group fluent-button {
    height: 24px;
    min-width: 18px;
    --control-corner-radius: 2px;
    font-size: 0.75rem;
}

.action-buttons-group fluent-button::part(control) {
    padding: 0 8px;
    color: white;
}

/* REQ-DASH-GRID-02: Clase para grids de alta densidad industrial */
.dashboard-breakdown-grid fluent-data-grid-row {
    height: 20px !important;
    min-height: 20px !important;
}

.dashboard-breakdown-grid .col-title-text {
    font-size: 0.7rem !important;
}

/* REQ-DASH-FILTER-03: Hide ApexCharts toolbar only when popover is open */
.popover-open .apexcharts-toolbar {
    display: none !important;
}

/* ======================================================
   VERSIÓN PREVIEW GRID - Estilos globales
   ====================================================== */

/* Permitir scroll horizontal en el body del dialog */
.fluent-dialog-body {
    overflow-x: auto !important;
}

/* Contenedor con scroll horizontal */
.version-preview-grid {
    overflow-x: auto;
    width: 100%;
}

/* Tabla principal */
.version-preview-grid table.fluent-data-grid {
    border: 1px solid #dcdcdc;
    font-size: 9px;
    background: white;
    border-collapse: collapse;
    grid-template-columns:
        65px                 /* 1: Cantidad       */
        minmax(95px, 1fr)    /* 2: Componente     */
        minmax(85px, 1fr)    /* 3: Tipo Envase    */
        minmax(130px, 1fr)   /* 4: Cat. Normativa */
        minmax(145px, 1fr)   /* 5: Subcat. Norm.  */
        minmax(145px, 1fr)   /* 6: Carac. Norm.   */
        minmax(95px, 1fr)    /* 7: Clase Norm.    */
        minmax(95px, 1fr)    /* 8: Descripción    */
        65px                 /* 9: División       */
        minmax(105px, 1fr)   /* 10: Peso Unit.    */
        minmax(80px, 1fr)    /* 11: Porcentaje %  */
        minmax(135px, 1fr)   /* 12: % Reciclado   */
        minmax(85px, 1fr)    /* 13: Reutilizable  */
        !important;
}

/* Filas: sobreescribir inline height: 32px */
.version-preview-grid tr.fluent-data-grid-row {
    height: 20px !important;
    min-height: 20px !important;
    border-bottom: 1px solid #efefef;
    background: white;
}

.version-preview-grid tr.fluent-data-grid-row:hover {
    background-color: #f2f8ff !important;
}

/* Cabeceras: sobreescribir inline height/min-width */
.version-preview-grid th {
    height: 20px !important;
    min-height: 20px !important;
    min-width: 0 !important;
    padding: 0 3px !important;
    margin: 0 !important;
    vertical-align: middle !important;
    background-color: #f3f3f3 !important;
    font-weight: 600 !important;
    font-size: 9px !important;
    border-bottom: 1px solid #d0d0d0;
    overflow: hidden;
}

/* Texto del título: sin ellipsis, sin overflow oculto */
.version-preview-grid .col-title-text {
    font-size: 9px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: block;
}

/* Celdas de datos */
.version-preview-grid td {
    height: 20px !important;
    min-width: 0 !important;
    padding: 0 3px !important;
    margin: 0 !important;
    vertical-align: middle !important;
    font-size: 9px !important;
    font-weight: normal !important;
}

/* Spans dentro de celdas */
.version-preview-grid td span,
.version-preview-grid td .excel-text-cell {
    font-size: 9px;
    line-height: 20px;
}

/* Diff: fila nueva (verde pastel) */
.diff-row-new {
    background-color: #e6ffed !important;
}

/* Diff: valor modificado - resalta toda la celda */
.version-preview-grid td:has(.diff-value-mod) {
    background-color: #fffacd !important;
}

.diff-value-mod {
    display: block;
    width: 100%;
    font-size: 9px;
    font-weight: normal !important;
}

.break {
    grid-column: 1 / -1;
}

/* FIX: Permite que los dropdowns se muestren fuera de las celdas. */
::deep .fluent-data-grid-cell {
    overflow: visible !important;
}

/* Responsive Design */
/* Tablet */
@media (max-width: 1024px) {
    :root {
        --header-height: 50px;
    }

    .layout-header {
        padding: 0.25rem 0.5rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
    }

    .header-left {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        min-height: 24px;
    }

    .header-right {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        justify-content: flex-end;
        min-height: 24px;
    }

    .layout-content {
        padding: 0.5rem;
    }

    .header-org-select {
        width: 160px !important;
        font-size: 0.9rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .layout-header {
        padding: 0.25rem 0.5rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .header-left {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        min-height: 28px;
    }

    .header-right {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        justify-content: flex-end;
        min-height: 28px;
    }

    .layout-content {
        padding: 0.25rem;
    }

    .header-org-select {
        width: 140px !important;
        max-width: 140px !important;
        flex: 0;
        min-width: auto;
        font-size: 0.85rem;
    }
}