/* ============================================
   LOHMIA HEADER RESPONSIVE FIX v1.0
   Correcciones de responsividad para el header
   ============================================ */

/* === BASE HEADER FIX === */
.main-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #1e293b) !important;
    border-bottom: 1px solid var(--border-color, #475569);
    min-height: 60px;
    gap: 0.5rem;
    /* CRITICAL: Prevent overflow */
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* === LOGO SECTION === */
.main-header .logo-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
}

/* Force all header children to stay contained */
.main-header * {
    max-width: 100%;
    box-sizing: border-box;
}

.main-header .logo {
    display: flex;
    align-items: center;
}

.main-header .logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

/* === NAV LINKS === */
.main-header .nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    flex-wrap: nowrap;
}

.main-header .nav-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: none;
    color: var(--text-secondary, #94a3b8);
    border-radius: 6px;
    transition: all 0.2s;
}

.main-header .nav-btn:hover,
.main-header .nav-btn.active {
    color: var(--text-primary, #f1f5f9);
    background: rgba(59, 130, 246, 0.15);
}

/* === HEADER ACTIONS === */
.main-header .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    max-width: 40%;
}

.main-header .header-actions #adminEmail,
.main-header #adminEmail {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem !important;
    color: var(--text-secondary, #94a3b8) !important;
}

/* === MOBILE MENU TOGGLE === */
.main-header .mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary, #f1f5f9);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    line-height: 1;
}

.main-header .mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

/* TABLET (768px - 1024px) */
@media (max-width: 1024px) {
    .main-header .nav-links {
        gap: 0.125rem;
    }

    .main-header .nav-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }

    .main-header .header-actions #adminEmail,
    .main-header #adminEmail {
        max-width: 120px;
        font-size: 0.75rem !important;
    }
}

/* MOBILE LARGE (600px - 768px) */
@media (max-width: 768px) {
    .main-header {
        padding: 0.5rem 0.75rem;
        min-height: 56px;
    }

    /* Mostrar hamburger, ocultar nav */
    .main-header .mobile-menu-toggle {
        display: flex !important;
        order: -1;
    }

    .main-header .nav-links {
        display: none !important;
    }

    .main-header .logo-section {
        flex: 1;
        justify-content: flex-start;
    }

    .main-header .logo h1 {
        font-size: 1.1rem;
    }

    .main-header .header-actions {
        gap: 0.5rem;
    }

    .main-header .header-actions #adminEmail,
    .main-header #adminEmail {
        max-width: 100px;
        font-size: 0.7rem !important;
    }
}

/* MOBILE SMALL (480px - 600px) */
@media (max-width: 600px) {
    .main-header {
        padding: 0.5rem;
        gap: 0.35rem;
    }

    .main-header .logo h1 {
        font-size: 1rem;
    }

    .main-header .header-actions #adminEmail,
    .main-header #adminEmail {
        max-width: 80px;
        font-size: 0.65rem !important;
    }

    /* Ocultar iconos extra si hay */
    .main-header .notifications,
    .main-header .notification-bell {
        display: none !important;
    }
}

/* MOBILE EXTRA SMALL (<480px) */
@media (max-width: 480px) {
    .main-header {
        padding: 0.4rem 0.5rem;
        min-height: 50px;
    }

    .main-header .mobile-menu-toggle {
        font-size: 1.25rem;
        padding: 0.35rem;
    }

    .main-header .logo h1 {
        font-size: 0.9rem;
    }

    /* En pantallas muy pequenas, ocultar email */
    .main-header .header-actions #adminEmail,
    .main-header #adminEmail {
        display: none !important;
    }

    /* Solo mostrar icono de usuario */
    .main-header .user-info {
        padding: 0.35rem;
    }

    .main-header .user-info i {
        margin-right: 0 !important;
    }
}

/* =============================================
   USER INFO COMPONENT
   ============================================= */

.main-header .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 0;
}

.main-header .user-info:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-header .user-info i {
    color: var(--accent-blue, #3b82f6);
    flex-shrink: 0;
}

/* =============================================
   NOTIFICATION BELL
   ============================================= */

.main-header .notification-bell {
    position: relative;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.main-header .notification-bell:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-header .notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.main-header .notification-badge:empty,
.main-header .notification-badge[data-count="0"] {
    display: none;
}

/* =============================================
   SEARCH BAR (dentro del header)
   ============================================= */

.main-header .search-bar {
    display: none; /* Ocultar por defecto en header, mover a contenido */
}

/* En desktop grande, mostrar search inline */
@media (min-width: 1200px) {
    .main-header .search-bar {
        display: flex;
        flex: 0 1 300px;
        margin: 0 1rem;
    }

    .main-header .search-bar input {
        width: 100%;
        padding: 0.5rem 1rem;
        background: var(--bg-tertiary, #334155);
        border: 1px solid var(--border-color, #475569);
        border-radius: 8px;
        color: var(--text-primary, #f1f5f9);
        font-size: 0.85rem;
    }

    .main-header .search-bar input::placeholder {
        color: var(--text-muted, #64748b);
    }
}

/* =============================================
   FIXES FOR SPECIFIC PAGES
   ============================================= */

/* SaaS Page - inner header fix */
.main-content > header {
    display: none !important; /* Ocultar header duplicado dentro de main-content */
}

/* Dashboard/Other pages - ensure main-header is always on top */
body > .main-header,
.dashboard > .main-header,
#app > .main-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
}

/* Content padding to account for fixed header */
.main-content,
.app-content,
.dashboard-content,
.page-content {
    padding-top: 70px !important;
}

@media (max-width: 768px) {
    .main-content,
    .app-content,
    .dashboard-content,
    .page-content {
        padding-top: 60px !important;
    }
}

@media (max-width: 480px) {
    .main-content,
    .app-content,
    .dashboard-content,
    .page-content {
        padding-top: 54px !important;
    }
}

/* =============================================
   LANDSCAPE ORIENTATION FIX
   ============================================= */

@media (max-height: 500px) and (orientation: landscape) {
    .main-header {
        min-height: 44px;
        padding: 0.35rem 0.75rem;
    }

    .main-header .logo h1 {
        font-size: 0.9rem;
    }

    .main-header .nav-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* FIX: Hamburger menu always visible and clickable */
.mobile-menu-toggle {
    position: relative !important;
    z-index: 1001 !important;
}

.main-header {
    z-index: 1000 !important;
}

.mobile-nav-overlay:not(.active) {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

.mobile-nav-overlay.active {
    display: block !important;
    pointer-events: auto !important;
    z-index: 999 !important;
}

.mobile-nav.active {
    display: flex !important;
    z-index: 1000 !important;
}

@media (max-width: 768px) {
    .logo-section {
        flex-direction: row !important;
    }
    
    .mobile-menu-toggle {
        order: -1 !important;
        margin-right: 10px !important;
        display: flex !important;
    }
}

/* Ensure mobile-nav is hidden by default */
.mobile-nav {
    display: none !important;
    left: -100% !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.mobile-nav.active {
    display: flex !important;
    left: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}
