/* ==========================================================================
   SISTEMA METROLÓGICO Y MSA - CLARIOS
   Diseño Corporativo Sobrio y Moderno (Desktop 1920x1080 Prioritario)
   ========================================================================== */

:root {
    --msa-primary: #002d62;       /* Azul Marino Clarios */
    --msa-primary-dark: #001f44;
    --msa-primary-light: #0d4b8f;
    --msa-accent: #0082c8;        /* Azul Acento */
    --msa-bg: #f4f6f9;            /* Fondo Claro Limpio */
    --msa-surface: #ffffff;
    --msa-border: #e2e8f0;
    --msa-text-main: #1e293b;
    --msa-text-muted: #64748b;
    --msa-sidebar-width: 270px;
    --msa-sidebar-collapsed-width: 70px;
    --msa-topbar-height: 70px;
    
    /* Estados Metrológicos */
    --msa-vigente: #15803d;
    --msa-proximo: #b45309;
    --msa-vencido: #b91c1c;
    --msa-noaplica: #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--msa-bg);
    color: var(--msa-text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Iconos SVG Globales */
svg.icon {
    width: 1.125rem;
    height: 1.125rem;
    vertical-align: -0.15em;
    display: inline-block;
    flex-shrink: 0;
}
svg.icon-lg {
    width: 2rem;
    height: 2rem;
}
svg.icon-sm {
    width: 0.875rem;
    height: 0.875rem;
}

/* ==========================================================================
   ESTANDARIZACIÓN DE BOTONES DE ACCIÓN PRINCIPALES
   ========================================================================== */
.btn-action-primary {
    height: 38px !important;
    padding: 0 1.25rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    transition: all 0.15s ease-in-out !important;
}
.btn-action-primary svg.icon {
    width: 1rem !important;
    height: 1rem !important;
    margin-right: 0 !important;
}

.btn-action-secondary {
    height: 38px !important;
    padding: 0 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    transition: all 0.15s ease-in-out !important;
}
.btn-action-secondary svg.icon {
    width: 1rem !important;
    height: 1rem !important;
    margin-right: 0 !important;
}

/* ==========================================================================
   LAYOUT: SIDEBAR & TOPBAR
   ========================================================================== */

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

.app-sidebar {
    width: var(--msa-sidebar-width);
    background-color: #ffffff;
    border-right: 1px solid var(--msa-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 2px 0 6px rgba(0,0,0,0.02);
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    height: var(--msa-topbar-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--msa-border);
    background-color: #ffffff;
    text-decoration: none;
    gap: 0.25rem;
}

.sidebar-brand img {
    height: 28px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    transition: max-width 0.2s ease;
}

.sidebar-brand .brand-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--msa-primary);
    line-height: 1.1;
    letter-spacing: 0.5px;
    text-align: center;
}


.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    letter-spacing: 0.6px;
    text-align: left;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    text-align: left;
}

.sidebar-nav .nav-link:hover {
    background-color: #f1f5f9;
    color: var(--msa-primary);
}

.sidebar-nav .nav-link.active {
    background-color: #e0f2fe;
    color: var(--msa-primary);
    font-weight: 600;
}

.sidebar-nav .nav-link .icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-right: 0;
    color: #64748b;
    flex-shrink: 0;
}

.sidebar-nav .nav-link.active .icon {
    color: var(--msa-primary);
}

.sidebar-nav .nav-link .nav-text {
    flex: 1 1 auto;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav .nav-link .nav-badge,
.sidebar-nav .nav-link .badge {
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--msa-border);
    font-size: 0.72rem;
    color: var(--msa-text-muted);
    background-color: #f8fafc;
    text-align: center;
}

/* APP MAIN AREA */
.app-main {
    flex: 1;
    margin-left: var(--msa-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   SIDEBAR COLAPSADO (MODO COMPACTO)
   ========================================================================== */
html.sidebar-collapsed .app-sidebar,
body.sidebar-collapsed .app-sidebar {
    width: var(--msa-sidebar-collapsed-width);
}

html.sidebar-collapsed .app-main,
body.sidebar-collapsed .app-main {
    margin-left: var(--msa-sidebar-collapsed-width);
}

html.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-brand {
    padding: 0.5rem 0.25rem;
}

html.sidebar-collapsed .sidebar-brand img,
body.sidebar-collapsed .sidebar-brand img {
    max-width: 36px;
    height: auto;
}

html.sidebar-collapsed .sidebar-brand .brand-title,
body.sidebar-collapsed .sidebar-brand .brand-title {
    display: none;
}

html.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-section-title {
    display: none;
}

html.sidebar-collapsed .sidebar-nav,
body.sidebar-collapsed .sidebar-nav {
    padding: 0.75rem 0.35rem;
}

html.sidebar-collapsed .sidebar-nav .nav-link,
body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 0.65rem 0;
    text-align: center;
    border-radius: 8px;
    gap: 0;
}

html.sidebar-collapsed .sidebar-nav .nav-link .icon,
body.sidebar-collapsed .sidebar-nav .nav-link .icon {
    margin-right: 0 !important;
    width: 20px;
    height: 20px;
}

html.sidebar-collapsed .sidebar-nav .nav-link .nav-text,
body.sidebar-collapsed .sidebar-nav .nav-link .nav-text,
html.sidebar-collapsed .sidebar-nav .nav-link .badge,
body.sidebar-collapsed .sidebar-nav .nav-link .badge,
html.sidebar-collapsed .sidebar-nav .nav-link .nav-badge,
body.sidebar-collapsed .sidebar-nav .nav-link .nav-badge {
    display: none !important;
}

html.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-footer {
    display: none;
}

/* ==========================================================================
   MENÚ SECUNDARIO DE NAVEGACIÓN EN CENTRO DE AYUDA
   ========================================================================== */
.ayuda-nav-card {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--msa-border);
}
.ayuda-nav-card .card-header {
    background-color: #f8fafc;
    border-bottom: 1px solid var(--msa-border);
    padding: 0.65rem 0.85rem;
}
.ayuda-nav-card .list-group-item {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 0.55rem 0.85rem;
    color: #334155;
    font-size: 0.825rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s ease-in-out;
}
.ayuda-nav-card .list-group-item:hover {
    background-color: #f1f5f9;
    color: var(--msa-primary);
}
.ayuda-nav-card .list-group-item.active {
    background-color: #f0f7ff;
    color: var(--msa-primary);
    border-left-color: var(--msa-accent);
    border-top: none;
    border-right: none;
    font-weight: 600;
}

.app-topbar {
    height: var(--msa-topbar-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--msa-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-content {
    flex: 1;
    padding: 1.5rem 1.75rem;
}

/* ==========================================================================
   CARDS & KPI TILES
   ========================================================================== */

.msa-card {
    background-color: #ffffff;
    border: 1px solid var(--msa-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.msa-card-header {
    padding: 1rem 1.25rem;
    background-color: #ffffff;
    border-bottom: 1px solid var(--msa-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.msa-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--msa-text-main);
    margin: 0;
}

.msa-card-body {
    padding: 1.25rem;
}

/* KPI TILES & CORPORATE CARDS */
.kpi-tile {
    background-color: #ffffff;
    border: 1px solid var(--msa-border);
    border-radius: 8px;
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    position: relative;
    border-left: 4px solid var(--msa-primary);
}

.kpi-tile.kpi-primary { border-left-color: var(--msa-primary); }
.kpi-tile.kpi-success { border-left-color: var(--msa-vigente); }
.kpi-tile.kpi-warning { border-left-color: #f59e0b; }
.kpi-tile.kpi-danger  { border-left-color: var(--msa-vencido); }
.kpi-tile.kpi-info    { border-left-color: var(--msa-accent); }
.kpi-tile.kpi-muted   { border-left-color: #94a3b8; }

.kpi-card {
    background-color: #ffffff;
    border: 1px solid var(--msa-border);
    border-radius: 8px;
    padding: 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.kpi-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.kpi-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--msa-text-muted);
}

.kpi-card-value {
    font-size: 2.15rem;
    font-weight: 800;
    line-height: 1;
    color: #0f172a;
    letter-spacing: -0.5px;
    margin-bottom: 0.4rem;
}

.kpi-card-subtext {
    font-size: 0.76rem;
    color: var(--msa-text-muted);
    line-height: 1.25;
}

/* Semáforos Corporativos */
.status-pill-danger {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.70rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-pill-warning {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.70rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-pill-success {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.70rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-pill-neutral {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.70rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--msa-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--msa-text-main);
    line-height: 1;
}

.kpi-subtitle {
    font-size: 0.75rem;
    color: var(--msa-text-muted);
    margin-top: 0.4rem;
}

/* ==========================================================================
   TABLAS Y LISTADOS
   ========================================================================== */

.table-msa {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table-msa thead th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--msa-border);
    padding: 0.75rem 0.85rem;
    white-space: nowrap;
}

.table-msa tbody td {
    padding: 0.75rem 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table-msa tbody tr:hover {
    background-color: #f8fafc;
}

/* BADGES DE ESTATUS METROLÓGICO */
.badge-status {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-vigente {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-proximo {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-vencido {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-noaplica {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.badge-sinhisto {
    background-color: #f8fafc;
    color: #64748b;
    border: 1px dashed #cbd5e1;
}

/* ==========================================================================
   DETALLE DE EQUIPO: TABS Y HEADER
   ========================================================================== */

.equipment-header-card {
    background: #ffffff;
    border: 1px solid var(--msa-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.equipment-clave {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--msa-primary);
    line-height: 1.1;
}

.equipment-desc {
    font-size: 1rem;
    color: #334155;
    margin-top: 0.25rem;
}

.nav-tabs-msa {
    border-bottom: 1px solid var(--msa-border);
    margin-bottom: 1.25rem;
}

.nav-tabs-msa .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    padding: 0.75rem 1.25rem;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    transition: all 0.15s ease-in-out;
}

.nav-tabs-msa .nav-link:hover {
    color: var(--msa-primary);
    border-bottom-color: #cbd5e1;
}

.nav-tabs-msa .nav-link.active {
    color: var(--msa-primary);
    font-weight: 600;
    border-bottom-color: var(--msa-primary);
    background: transparent;
}

/* DEFINICIONES / PARES CLAVE-VALOR EN DETALLE */
.meta-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--msa-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.meta-value {
    font-size: 0.95rem;
    color: #0f172a;
    font-weight: 500;
    margin-bottom: 1rem;
}

/* ==========================================================================
   PRINT STYLES (@media print)
   ========================================================================== */

@media print {
    .app-sidebar,
    .app-topbar,
    .no-print,
    .btn,
    .pagination,
    nav[aria-label='Paginación'] {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .app-content {
        padding: 0 !important;
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt;
    }

    .msa-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    .table-msa {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .table-msa th,
    .table-msa td {
        border: 1px solid #999 !important;
        padding: 4pt 6pt !important;
    }

    .badge-status {
        border: 1px solid #333 !important;
        color: #000 !important;
        background: transparent !important;
    }
}