/* ========== RESET BASE ANTI-SCROLL-HORIZONTAL ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

/* ========== VARIABLES ========== */
:root {
    --primary-color: #E03B41;
    --primary-hover: #c53038;
    --primary-soft: rgba(224, 59, 65, 0.08);
    --text-dark: #1f1f1f;
    --text-gray: #5c5c5c;
    --border-color: #e5e5e5;
    --bg-white: #ffffff;
    --font-heading: 'Poppins', sans-serif;
    --transition: all 0.3s ease;
    --radius-md: 10px;
    --shadow-soft: 0 6px 24px rgba(0, 0, 0, 0.06);
}

/* ========== HEADER PRINCIPAL ========== */
.main-header {
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid rgba(234, 234, 234, 0.9);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.045);
    position: sticky;
    top: 0;
    z-index: 99;
    padding: 10px 0;
    backdrop-filter: blur(10px);
    /* Clave: evita que el header genere scroll horizontal */
    width: 100%;
    overflow: hidden;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;           /* ← reducido de 28px para pantallas intermedias */
    min-height: 64px;
    /* El .container de tu framework ya debería tener padding lateral;
       si no lo tiene, añade: padding-left: 16px; padding-right: 16px; */
}

/* ── LOGO ── */
.logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo img {
    height: 56px;
    width: auto;
    transition: var(--transition);
}

.logo:hover img {
    transform: scale(1.03);
}

/* ── NAVEGACIÓN DESKTOP ── */
.desktop-nav {
    flex: 1;
    display: flex;
    justify-content: center;
    /* Importante: no dejar que sobresalga */
    min-width: 0;
    overflow: visible;   /* el dropdown necesita visible, pero el flujo inline no desborda */
}

.desktop-nav ul {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.desktop-nav li {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.desktop-nav a {
    font-family: var(--font-heading);
    font-size: 0.82rem;  /* ← ligeramente reducido para caber mejor */
    font-weight: 600;
    color: var(--text-dark);
    text-transform: uppercase;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 0 2px;
    white-space: nowrap;
    text-decoration: none;
}

.desktop-nav a::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 3px;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 20px;
    transform: translateX(-50%);
    transition: var(--transition);
}

.desktop-nav a:hover {
    color: var(--primary-color);
}

.desktop-nav a:hover::after,
.desktop-nav a.active::after {
    width: 100%;
}

.desktop-nav a.active {
    color: var(--primary-color);
}

/* ── DROPDOWN DESKTOP ── */
.dropdown-arrow {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 2px;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
    min-width: 210px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    z-index: 200;
    /* Evitar que el dropdown rompa el layout horizontal */
    white-space: nowrap;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--border-color);
}

.dropdown-menu::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #fff;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 0.84rem;
    color: var(--text-dark);
    font-weight: 500;
    text-transform: none;
    min-height: unset;
    transition: background 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
    white-space: nowrap;
    text-decoration: none;
}

.dropdown-menu a::after {
    display: none;
}

.dropdown-menu a:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
    padding-left: 26px;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown:hover .dropdown-arrow,
.dropdown:focus-within .dropdown-arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
}

/* ── ACCIONES DEL HEADER ── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;           /* ← reducido de 22px */
    flex-shrink: 0;
}

.header-actions .btn-primary {
    white-space: nowrap;
    padding: 10px 18px;
    text-align: center;
    font-weight: 700;
    font-size: 0.82rem;
    border-radius: 6px;
    background: var(--primary-color);
    color: #fff;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Quitamos min-width fijo que forzaba ensanchamiento */
    min-height: 46px;
}

.header-actions .btn-primary:hover {
    background: var(--primary-hover);
}

/* ── BOTÓN HAMBURGUESA ── */
.menu-toggle {
    width: 42px;
    height: 42px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.hamburger-line {
    display: block;
    width: 26px;
    height: 2.5px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: var(--transition);
}

.menu-toggle:hover .hamburger-line {
    background-color: var(--primary-hover);
}

.menu-toggle:hover .hamburger-line:first-child {
    transform: translateX(4px);
}

.menu-toggle:hover .hamburger-line:last-child {
    transform: translateX(-4px);
}

/* ========== SIDEBAR ========== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-menu {
    position: fixed;
    top: 0;
    right: 0;
    /* min() garantiza que nunca sobrepase el viewport */
    width: min(380px, 92vw);
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;      /* soporte para mobile browsers con barra de dirección */
    background: var(--bg-white);
    z-index: 1000;
    transform: translateX(105%);
    transition: transform 0.4s ease;
    padding: 30px;
    overflow-y: auto;
    overflow-x: hidden;  /* ← evita scroll interno horizontal en el sidebar */
    box-shadow: -18px 0 45px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
}

.sidebar-menu.active {
    transform: translateX(0);
}

/* Cabecera del sidebar */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 18px;
}

.sidebar-header img {
    height: 35px;
    width: auto;
    max-width: calc(100% - 60px); /* que no choque con el botón cerrar */
}

.close-sidebar {
    width: 42px;
    height: 42px;
    background: var(--primary-soft);
    border: none;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.close-sidebar:hover {
    background: var(--primary-color);
    color: #fff;
    transform: rotate(90deg);
}

/* ── SIDEBAR NAV ── */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 28px;
}

.sidebar-nav > a {
    display: block;
    padding: 14px 16px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
    text-transform: uppercase;
    border-radius: 6px;
    transition: all 0.25s ease;
    text-decoration: none;
    /* Evitar desborde de texto largo */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav > a:hover,
.sidebar-nav > a.active {
    background: var(--primary-soft);
    color: var(--primary-color);
    padding-left: 22px;
}

/* ── DROPDOWN DEL SIDEBAR ── */
.sidebar-dropdown {
    position: relative;
}

.sidebar-dropdown-toggle {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-arrow {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
    color: var(--text-gray);
    flex-shrink: 0;
    margin-left: 8px;
}

.sidebar-dropdown.open .sidebar-arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.sidebar-dropdown-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
    background: #fafafa;
    border-radius: 0 0 6px 6px;
    margin: 0 8px;
}

.sidebar-dropdown.open .sidebar-dropdown-menu {
    max-height: 800px;
}

.sidebar-dropdown-menu a {
    display: block;
    padding: 11px 20px 11px 28px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-dark);
    text-transform: uppercase;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
    /* Permite wrap para textos largos en pantallas muy pequeñas */
    white-space: normal;
    word-break: break-word;
}

.sidebar-dropdown-menu a:hover,
.sidebar-dropdown-menu a.active {
    background: var(--primary-soft);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

/* ── BOTÓN CONTACTO SIDEBAR ── */
.btn-sidebar-contacto {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--primary-color);
    color: #fff;
    padding: 14px 0;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 12px 0 18px;
    transition: background 0.3s, transform 0.3s;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-sidebar-contacto:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* ── CONTENIDO ADICIONAL DEL SIDEBAR ── */
.sidebar-content {
    /* Evitar que el contenido del sidebar desborde */
    overflow-wrap: break-word;
    word-break: break-word;
}

.sidebar-content p {
    font-size: 0.9rem;
    margin-bottom: 22px;
    color: var(--text-gray);
    line-height: 1.7;
}

.sidebar-content h3 {
    font-size: 1rem;
    margin-bottom: 14px;
    color: var(--text-dark);
    font-family: var(--font-heading);
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    transition: var(--transition);
    /* Evitar overflow del contenedor */
    min-width: 0;
}

.contact-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
    border-color: rgba(224, 59, 65, 0.25);
}

.contact-item i {
    background: var(--primary-color);
    color: #fff;
    width: 40px;
    height: 40px;
    min-width: 40px;     /* ← evita que el ícono se comprima */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: 0 8px 18px rgba(224, 59, 65, 0.22);
}

.contact-item > div {
    min-width: 0;        /* ← clave para que el texto no desborde */
    overflow: hidden;
}

.contact-item strong {
    display: block;
    color: var(--text-dark);
    font-family: var(--font-heading);
    margin-bottom: 2px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-item span {
    display: block;
    font-size: 0.85rem;
    color: var(--text-gray);
    line-height: 1.5;
    word-break: break-word;
}

.social-links-sidebar {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.social-links-sidebar a {
    display: inline-flex;
    width: 38px;
    height: 38px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1rem;
    box-shadow: 0 8px 18px rgba(224, 59, 65, 0.22);
    flex-shrink: 0;
}

.social-links-sidebar a:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-3px);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
    .desktop-nav ul {
        gap: 14px;
    }

    .desktop-nav a {
        font-size: 0.78rem;
    }

    .header-actions {
        gap: 12px;
    }

    .header-actions .btn-primary {
        font-size: 0.78rem;
        padding: 10px 14px;
    }
}

@media (max-width: 992px) {
    .main-header {
        padding: 10px 0;
    }

    .desktop-nav {
        display: none;
    }

    .d-none-mobile {
        display: none !important;
    }

    .header-container {
        min-height: 52px;
        gap: 10px;
    }
}

@media (max-width: 576px) {
    .logo img {
        height: 44px;
    }

    .menu-toggle {
        width: 38px;
        height: 38px;
    }

    .sidebar-menu {
        padding: 20px 16px;
        width: min(360px, 96vw);
    }

    .sidebar-dropdown-menu a {
        padding-left: 18px;
        font-size: 0.78rem;
    }

    .contact-item {
        padding: 12px;
        gap: 12px;
    }

    .contact-item i {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }
}

@media (max-width: 360px) {
    .logo img {
        height: 38px;
    }

    .sidebar-menu {
        padding: 16px 12px;
    }

    .sidebar-nav > a {
        font-size: 0.82rem;
        padding: 12px 14px;
    }
}