/* ============================================================
   HEADER — Forjando Perú
   ============================================================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--color-primary);
    box-shadow: 0 2px 12px rgba(0, 60, 90, 0.25);
    height: var(--header-height);
}

.site-header.scrolled {
    box-shadow: 0 4px 24px rgba(0, 60, 90, 0.35);
}

.site-header .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
}

/* ---- Logo ---- */
.header-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.header-logo img,
.header-logo__img {
    max-height: 44px;
    width: auto;
    height: auto;
    display: block;
}

.header-site-name {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* ---- Nav menú ---- */
.header-nav {
    flex: 1;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li a {
    display: block;
    padding: 6px 14px;
    color: rgba(255, 255, 255, 0.90);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-menu li a:hover,
.nav-menu li.current-menu-item > a {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.nav-menu li.current-menu-item > a {
    font-weight: 700;
    border-bottom: 2px solid var(--color-secondary);
    border-radius: 0;
    background: transparent;
}

/* ---- Acciones del header ---- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ---- Contenedor botones visitante ---- */
.header-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Botones login/registro ---- */
.btn-header {
    padding: 8px 18px;
    border-radius: var(--radius-btn);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-header--login {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.60);
    color: #fff;
}

.btn-header--login:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.90);
    color: #fff;
}

.btn-header--register {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
    border: 2px solid transparent;
    color: #fff;
    box-shadow: 0 3px 10px rgba(171, 193, 62, 0.35);
}

.btn-header--register:hover {
    background: linear-gradient(135deg, var(--color-secondary-dark), var(--color-secondary));
    box-shadow: 0 5px 16px rgba(86, 192, 42, 0.45);
    transform: translateY(-1px);
    color: #fff;
}

/* ---- Usuario logueado ---- */
.header-user {
    position: relative;
}

.site-header .header-user__toggle,
#site-header .header-user__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 40px !important;
    padding: 5px 12px 5px 5px !important;
    cursor: pointer !important;
    color: #fff !important;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    box-shadow: none !important;
}

.site-header .header-user__toggle:hover,
.site-header .header-user__toggle:focus,
.site-header .header-user__toggle:active,
#site-header .header-user__toggle:hover,
#site-header .header-user__toggle:focus,
#site-header .header-user__toggle:active {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    box-shadow: none !important;
    outline: none !important;
}

.header-user__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.40);
    flex-shrink: 0;
}

.header-user__name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-user__chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
    opacity: 0.8;
}

.header-user__toggle[aria-expanded="true"] .header-user__chevron {
    transform: rotate(180deg);
}

/* ---- Dropdown usuario ---- */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border-radius: var(--radius-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--color-gray-mid);
    overflow: hidden;
    z-index: 100;
}

.user-dropdown.is-open {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--color-gray);
    border-bottom: 1px solid var(--color-gray-mid);
}

.user-dropdown__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-dropdown__name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-dark);
    line-height: 1.2;
}

.user-dropdown__email {
    font-size: 0.78rem;
    color: var(--color-text-light);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.user-dropdown__menu {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.user-dropdown__menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--color-text);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}

.user-dropdown__menu li a:hover {
    background: rgba(0, 60, 90, 0.06);
    color: var(--color-primary);
}

.user-dropdown__menu li a svg {
    opacity: 0.6;
    flex-shrink: 0;
}

.user-dropdown__separator {
    height: 1px;
    background: var(--color-gray-mid);
    margin: 6px 0;
}

.user-dropdown__logout {
    color: #e53935 !important;
}

.user-dropdown__logout:hover {
    background: rgba(229, 57, 53, 0.06) !important;
    color: #e53935 !important;
}

/* ---- Hamburger (mobile) ---- */
.header-hamburger,
#site-header .header-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    padding: 8px !important;
    transition: var(--transition);
    box-shadow: none !important;
    color: #fff !important;
}

#site-header .header-hamburger:hover,
#site-header .header-hamburger:focus,
#site-header .header-hamburger:active {
    background: rgba(255, 255, 255, 0.22) !important;
    border-color: rgba(255, 255, 255, 0.40) !important;
    box-shadow: none !important;
    outline: none !important;
}

.header-hamburger span,
#site-header .header-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff !important;
    border-radius: 2px;
    transition: var(--transition);
}

.header-hamburger.is-active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.header-hamburger.is-active span:nth-child(2) {
    opacity: 0;
}
.header-hamburger.is-active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ---- Overlay móvil ---- */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}

.nav-overlay.is-visible {
    display: block;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--color-dark);
    color: rgba(255, 255, 255, 0.80);
    padding: 48px 0 0;
    margin-top: 64px;
}

.footer-inner {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px 40px;
}

.footer-brand {
    flex: 1;
    min-width: 200px;
}

.footer-logo img {
    max-height: 40px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.footer-logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
}

.footer-tagline {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 8px;
}

.footer-links {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
}

.footer-col h4 {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 16px;
}

.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-col ul li a {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.88rem;
    text-decoration: none;
    transition: var(--transition);
}

.footer-col ul li a:hover {
    color: var(--color-secondary);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    padding: 16px 24px;
    text-align: center;
}

.footer-bottom p {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.40);
    margin: 0;
}

/* ============================================================
   BACK TO TOP
   ============================================================ */
.cg-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 60, 90, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, visibility 0s linear 0.25s;
}

.cg-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, visibility 0s;
}

.cg-back-to-top:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
}

@media (max-width: 480px) {
    .cg-back-to-top {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .header-hamburger,
    #site-header .header-hamburger {
        display: flex !important;
    }

    .header-nav {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--color-primary);
        z-index: 1000;
        padding: 24px;
        overflow-y: auto;
    }

    .header-nav.is-open {
        display: block;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu li a {
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .header-auth {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-top: 0;
    }

    .btn-header {
        text-align: center;
        padding: 12px;
    }

    .header-user__name {
        display: none;
    }

    .user-dropdown {
        right: -12px;
    }

    .footer-inner {
        flex-direction: column;
        gap: 32px;
    }
}

@media (max-width: 480px) {
    .site-header .header-inner {
        padding: 0 16px;
    }

    .header-user__name {
        display: none;
    }

    /* JS para .scrolled se inyecta desde footer.php */
}
