/* Critical Header Styles - Load First */
/* Estos estilos aseguran que el header sea visible inmediatamente */

/* ===== AdSense z-index override =====
   Los banners flotantes de AdSense usan z-index muy altos.
   Forzamos los elementos interactivos del sitio por encima. */
.header,
.header * {
    z-index: 2147483640 !important;
}

.category-dropdown-menu,
.country-dropdown-menu,
.user-dropdown-menu,
.auth-modal,
.location-picker-modal,
.breadcrumb-dropdown {
    z-index: 2147483647 !important;
}

/* Header principal - Estilos críticos básicos compatibles con Bootstrap */
.header {
    background: #2563eb;
    position: sticky;
    top: 0;
    z-index: 2147483640 !important;
    width: 100%;
    min-height: 56px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    overflow: visible;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: block;
    width: 100%;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 16px;
    width: 100%;
    min-height: 56px;
}

.logo-search-section {
    display: flex;
    align-items: center;
    gap: 30px;
    flex: 1;
    min-width: 300px;
}

.logo-image {
    height: 45px;
    width: auto;
    display: block;
    max-width: 200px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 12px 50px 12px 18px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #1f2937;
    font-size: 16px;
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.categories-btn,
.btn-auth,
.btn-publish {
    padding: 10px 18px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.categories-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
}

.btn-auth {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
}

.btn-publish {
    background: #FF6600;
    color: white;
    border: none;
}

/* Responsive crítico */
@media (max-width: 768px) {
    .header-top {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
        min-height: 60px;
    }

    .logo-search-section {
        flex-direction: row;
        flex: 1;
        gap: 12px;
        min-width: 0;
    }

    .search-input-wrapper {
        flex: 1;
        max-width: none;
    }

    .header-actions {
        width: auto;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 15px;
    }

    .logo-image {
        height: 35px;
    }

    .search-input {
        font-size: 14px;
        padding: 10px 45px 10px 15px;
    }

    .categories-btn,
    .btn-auth,
    .btn-publish {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* Country indicator - Attractive glassmorphism style */
.country-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    border: none;
    transition: background 0.2s ease;
    cursor: pointer;
}

.country-indicator:hover {
    background: rgba(255, 255, 255, 0.25);
}

.country-flag {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.country-name {
    font-size: 12px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

@keyframes slideInFlag {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Hide country indicator on mobile to save space */
@media (max-width: 768px) {
    .country-indicator {
        display: none !important;
    }
}

/* User dropdown button */
.user-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Logo styling */
.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

/* Dropdown menus - essential for functionality */
.category-dropdown-menu,
.country-dropdown-menu,
.user-dropdown-menu {
    position: absolute;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 10000;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.category-dropdown-menu.show,
.country-dropdown-menu.show,
.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* User dropdown button hover */
.user-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Categories button hover */
.categories-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Auth modal - essential for functionality */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.auth-modal-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.auth-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.auth-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

/* Ensure modal can be shown by JavaScript */
.auth-modal[style*="display: flex"],
.auth-modal[style*="display:flex"],
.auth-modal.show {
    display: flex;
}

/* Button hover effects */
.btn-auth:hover {
    background: rgba(255, 255, 255, 0.25);
}

.btn-publish:hover {
    background: #E55A00;
}

/* ===== CLS (Cumulative Layout Shift) prevention for AdSense =====
   Reserva espacio antes de que los iframes de AdSense se inyecten,
   evitando que el contenido baje cuando se carga el anuncio.
   La anchura real siempre la controlará AdSense; solo definimos min-height. */
ins.adsbygoogle {
    display: block; /* ya lo pone AdSense, pero lo forzamos por si hay FOUC */
}

/* Horizontal/responsive banner (leaderboard, banner) — about 90px tall */
ins.adsbygoogle[data-ad-format="horizontal"],
ins.adsbygoogle[data-ad-format="auto"],
ins.adsbygoogle[data-full-width-responsive="true"] {
    min-height: 90px;
}

/* Vertical/rectangle ads */
ins.adsbygoogle[data-ad-format="vertical"],
ins.adsbygoogle[data-ad-format="rectangle"] {
    min-height: 250px;
}

@media (max-width: 768px) {
    /* On mobile, horizontal banners are typically 50–60px tall */
    ins.adsbygoogle[data-ad-format="horizontal"],
    ins.adsbygoogle[data-ad-format="auto"],
    ins.adsbygoogle[data-full-width-responsive="true"] {
        min-height: 60px;
    }
}
