/* =================================================================
   OBRAhub Portal Header — Sistema de cabeceras estandarizado
   Versión: 1.0 - Marzo 2026
   ================================================================= */

/* ═══════════════════════════════════════════════════
   VARIABLES GLOBALES
   ═══════════════════════════════════════════════════ */
:root {
    /* Brand */
    --oh-primary: #2c3e50;
    --oh-primary-light: #34495e;
    --oh-primary-dark: #1a252f;
    --oh-secondary: #3498db;
    --oh-accent: #1F4E79;

    /* Semantic */
    --oh-success: #27ae60;
    --oh-warning: #f39c12;
    --oh-danger: #e74c3c;
    --oh-info: #17a2b8;

    /* Neutrals */
    --oh-white: #ffffff;
    --oh-gray-50: #f8f9fa;
    --oh-gray-100: #f1f3f5;
    --oh-gray-200: #e9ecef;
    --oh-gray-300: #dee2e6;
    --oh-gray-500: #adb5bd;
    --oh-gray-600: #6c757d;
    --oh-gray-700: #495057;
    --oh-gray-800: #343a40;

    /* Elevation */
    --oh-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --oh-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --oh-shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --oh-shadow-header: 0 2px 12px rgba(0,0,0,0.18);

    /* Shape */
    --oh-radius: 8px;
    --oh-radius-sm: 4px;
    --oh-radius-lg: 12px;

    /* Motion */
    --oh-transition: all 0.2s ease;
    --oh-transition-fast: all 0.15s ease;

    /* Header */
    --oh-header-gradient: linear-gradient(135deg, var(--oh-primary) 0%, var(--oh-primary-light) 100%);

    /* Breadcrumb on dark */
    --oh-breadcrumb-link: rgba(255,255,255,0.6);
    --oh-breadcrumb-link-hover: rgba(255,255,255,0.9);
    --oh-breadcrumb-active: #ffffff;
    --oh-breadcrumb-divider: rgba(255,255,255,0.4);

    /* KPI glass effect */
    --oh-kpi-bg: rgba(255,255,255,0.12);
    --oh-kpi-bg-hover: rgba(255,255,255,0.22);
    --oh-kpi-bg-highlight: rgba(255,255,255,0.92);
}

/* ═══════════════════════════════════════════════════
   BASE HEADER
   ═══════════════════════════════════════════════════ */
.oh-header {
    background: var(--oh-header-gradient);
    color: var(--oh-white);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--oh-shadow-header);
}

.oh-header a { color: var(--oh-white); }
.oh-header a:hover { color: var(--oh-white); opacity: 0.9; }

.oh-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ═══════════════════════════════════════════════════
   BREADCRUMB (en dark bg)
   ═══════════════════════════════════════════════════ */
.oh-header .breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 4px;
    font-size: 0.8rem;
    --bs-breadcrumb-divider-color: var(--oh-breadcrumb-divider);
}
.oh-header .breadcrumb-item a {
    color: var(--oh-breadcrumb-link);
    text-decoration: none;
    transition: color 0.15s;
}
.oh-header .breadcrumb-item a:hover {
    color: var(--oh-breadcrumb-link-hover);
    text-decoration: none;
}
.oh-header .breadcrumb-item.active {
    color: var(--oh-breadcrumb-active);
}
.oh-header .breadcrumb-item + .breadcrumb-item::before {
    color: var(--oh-breadcrumb-divider);
}

/* ═══════════════════════════════════════════════════
   TÍTULO Y SUBTÍTULO
   ═══════════════════════════════════════════════════ */
.oh-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--oh-white);
}
.oh-header-title i {
    font-size: 1.1rem;
    opacity: 0.85;
}

.oh-header-subtitle {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   ENTITY METADATA
   ═══════════════════════════════════════════════════ */
.oh-entity-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    opacity: 0.75;
    margin-top: 3px;
    flex-wrap: wrap;
}
.oh-entity-meta .meta-separator {
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════
   STATUS BADGE
   ═══════════════════════════════════════════════════ */
.oh-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: rgba(255,255,255,0.9);
    color: var(--oh-primary);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}
.oh-status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.oh-status-badge.status-success { background: #d4edda; color: #155724; }
.oh-status-badge.status-warning { background: #fff3cd; color: #856404; }
.oh-status-badge.status-danger  { background: #f8d7da; color: #721c24; }
.oh-status-badge.status-info    { background: #d1ecf1; color: #0c5460; }

/* ═══════════════════════════════════════════════════
   HEADER ACTIONS & BUTTONS
   ═══════════════════════════════════════════════════ */
.oh-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.oh-header .btn-header {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 14px;
    border-radius: var(--oh-radius-sm);
    font-size: 0.85rem;
    transition: var(--oh-transition-fast);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.oh-header .btn-header:hover {
    background: rgba(255,255,255,0.22);
    color: white;
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════
   VARIANT 1: DASHBOARD HEADER (Level 1)
   ═══════════════════════════════════════════════════ */
.oh-header--dashboard {
    padding: 18px 0 0 0;
}

.oh-header--dashboard .oh-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 14px;
}

/* Nav tabs en header */
.oh-header-nav {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    max-width: 1600px;
    margin: 0 auto;
}

.oh-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: var(--oh-transition-fast);
    margin-bottom: -1px;
}
.oh-nav-tab:hover {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.06);
}
.oh-nav-tab.active {
    color: white;
    border-bottom-color: white;
    font-weight: 600;
}
.oh-nav-tab i { font-size: 0.85rem; }
.oh-nav-tab .badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(239,68,68,0.9);
    color: white;
    margin-left: 4px;
}

/* KPI bar debajo del header (fondo blanco) */
.oh-kpi-bar {
    display: flex;
    gap: 14px;
    padding: 14px 24px;
    background: var(--oh-white);
    border-bottom: 1px solid var(--oh-gray-200);
    flex-wrap: wrap;
    max-width: 1600px;
    margin: 0 auto;
}

.oh-kpi-card {
    padding: 10px 16px;
    border-radius: var(--oh-radius);
    border-left: 3px solid var(--oh-secondary);
    background: var(--oh-gray-50);
    min-width: 130px;
    transition: var(--oh-transition-fast);
}
.oh-kpi-card:hover {
    box-shadow: var(--oh-shadow-sm);
    transform: translateY(-1px);
}
.oh-kpi-card .oh-kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--oh-primary);
    line-height: 1.2;
}
.oh-kpi-card .oh-kpi-label {
    font-size: 0.65rem;
    color: var(--oh-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.oh-kpi-card .oh-kpi-sub {
    font-size: 0.75rem;
    color: var(--oh-gray-500);
    margin-top: 2px;
}
.oh-kpi-card.kpi-success { border-left-color: var(--oh-success); }
.oh-kpi-card.kpi-success .oh-kpi-value { color: var(--oh-success); }
.oh-kpi-card.kpi-warning { border-left-color: var(--oh-warning); }
.oh-kpi-card.kpi-danger  { border-left-color: var(--oh-danger); }
.oh-kpi-card.kpi-danger .oh-kpi-value { color: var(--oh-danger); }
.oh-kpi-card.kpi-info    { border-left-color: var(--oh-info); }

/* ═══════════════════════════════════════════════════
   VARIANT 2: ENTITY HEADER (Level 2)
   ═══════════════════════════════════════════════════ */
.oh-header--entity {
    padding: 14px 0;
}

.oh-header--entity .oh-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.oh-header--entity .oh-header-left {
    flex: 1;
    min-width: 280px;
}

.oh-header--entity .oh-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Mini KPIs en header de entidad */
.oh-header-kpis {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.oh-header-kpi-mini {
    background: var(--oh-kpi-bg);
    border-radius: var(--oh-radius-sm);
    padding: 6px 12px;
    text-align: center;
    min-width: 80px;
    backdrop-filter: blur(4px);
    transition: var(--oh-transition-fast);
}
.oh-header-kpi-mini:hover {
    background: var(--oh-kpi-bg-hover);
}
.oh-header-kpi-mini .kpi-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.85;
}
.oh-header-kpi-mini .kpi-value {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Entity tabs (barra blanca debajo del header) */
.oh-entity-tabs {
    background: var(--oh-white);
    border-bottom: 2px solid var(--oh-gray-200);
    position: sticky;
    top: 82px;
    z-index: 1019;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.oh-entity-tabs .oh-tabs-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.oh-entity-tab,
.oh-entity-tab.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 13px 18px;
    color: var(--oh-gray-600);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    border-radius: 0;
    background: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: var(--oh-transition-fast);
    cursor: pointer;
}
.oh-entity-tab:hover,
.oh-entity-tab.nav-link:hover {
    color: var(--oh-primary);
    background: rgba(44,62,80,0.04);
    text-decoration: none;
    border-bottom-color: var(--oh-gray-300);
}
.oh-entity-tab.active,
.oh-entity-tab.nav-link.active {
    color: var(--oh-primary);
    border-bottom-color: var(--oh-primary);
    font-weight: 600;
    background: none;
}
.oh-entity-tab i { font-size: 0.85rem; }
.oh-entity-tab .badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* ═══════════════════════════════════════════════════
   VARIANT 3: FUNCTION HEADER (Level 3)
   ═══════════════════════════════════════════════════ */
.oh-header--function {
    padding: 10px 0;
}

.oh-header--function .oh-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 2px;
}

.oh-header--function .oh-header-left {
    flex: 0 1 auto;
    min-width: 200px;
}

.oh-header--function .oh-header-title {
    font-size: 1.15rem;
}

.oh-header--function .oh-header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

/* KPIs integrados en header (frosted glass) */
.oh-header-kpi-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.oh-header-kpi-item {
    background: var(--oh-kpi-bg);
    border-radius: var(--oh-radius);
    padding: 6px 14px;
    text-align: center;
    min-width: 100px;
    backdrop-filter: blur(4px);
    transition: var(--oh-transition-fast);
}
.oh-header-kpi-item:hover {
    background: var(--oh-kpi-bg-hover);
    transform: translateY(-1px);
}
.oh-header-kpi-item .kpi-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    opacity: 0.85;
    margin-bottom: 1px;
}
.oh-header-kpi-item .kpi-value {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
}
.oh-header-kpi-item.kpi-highlight {
    background: var(--oh-kpi-bg-highlight);
    color: var(--oh-primary);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 991.98px) {
    .oh-header--dashboard .oh-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .oh-header-nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .oh-kpi-bar {
        gap: 10px;
    }
    .oh-kpi-card {
        min-width: 110px;
        flex: 1 1 110px;
    }
    .oh-header--function .oh-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .oh-header--function .oh-header-right {
        width: 100%;
    }
    .oh-header-kpi-bar {
        justify-content: flex-start;
        width: 100%;
    }
    .oh-header-kpis {
        flex-wrap: wrap;
    }
}

/* Mobile */
@media (max-width: 767.98px) {
    .oh-header-inner {
        padding: 0 16px;
    }
    .oh-header-title {
        font-size: 1.1rem;
    }
    .oh-header--dashboard {
        padding: 14px 0 0 0;
    }
    .oh-nav-tab {
        padding: 10px 14px;
        font-size: 0.8rem;
    }
    .oh-kpi-bar {
        padding: 10px 16px;
        gap: 8px;
    }
    .oh-kpi-card {
        min-width: 100px;
        padding: 8px 12px;
    }
    .oh-kpi-card .oh-kpi-value {
        font-size: 1.1rem;
    }
    .oh-header--entity .oh-header-row {
        flex-direction: column;
    }
    .oh-header--entity .oh-header-right {
        width: 100%;
        justify-content: space-between;
    }
    .oh-entity-tabs .oh-tabs-inner {
        padding: 0 16px;
    }
    .oh-entity-tab {
        padding: 11px 14px;
        font-size: 0.8rem;
    }
    .oh-header-kpi-item {
        min-width: 80px;
        padding: 5px 10px;
    }
    .oh-header-kpi-item .kpi-value {
        font-size: 0.85rem;
    }
    .oh-header-kpi-mini {
        min-width: 70px;
        padding: 5px 8px;
    }
}

/* ═══════════════════════════════════════════════════
   TABLE COLUMN WIDTHS (sistema reutilizable)
   ═══════════════════════════════════════════════════ */
.col-w-50  { width: 50px; }
.col-w-80  { width: 80px; }
.col-w-100 { width: 100px; }
.col-w-110 { width: 110px; }
.col-w-120 { width: 120px; }
.col-w-130 { width: 130px; }
.col-w-140 { width: 140px; }
.col-w-150 { width: 150px; }

@media (max-width: 767.98px) {
    .col-w-50, .col-w-80, .col-w-100, .col-w-110,
    .col-w-120, .col-w-130, .col-w-140, .col-w-150 {
        width: auto;
    }
}

/* ═══════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════ */
@media print {
    .oh-header {
        position: relative !important;
        box-shadow: none !important;
        background: var(--oh-primary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .oh-header-nav,
    .oh-entity-tabs,
    .oh-header .btn-header {
        display: none !important;
    }
}
