/* ============================================
   Header / Navbar Module — Modern & Enterprise
   ============================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav, 100);
    min-height: var(--header-height, 76px);
    display: flex;
    align-items: center;
    padding: var(--space-3) 0;
    transition: all var(--transition-base, 0.25s ease);
    background: rgba(11, 15, 25, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.75);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.header.scrolled {
    padding: var(--space-2) 0;
    min-height: calc(var(--header-height, 76px) - 8px);
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .header.scrolled {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    width: 100%;
}

/* --- Logo --- */
.header__logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: var(--weight-bold);
    font-size: var(--text-xl);
    text-decoration: none;
    flex-shrink: 0;
}

.header__logo:hover { color: var(--text-primary); }

.header__logo-img {
    height: 36px;
    width: auto;
    transition: transform var(--transition-base, 0.25s ease);
}

.header__logo:hover .header__logo-img {
    transform: rotate(-5deg) scale(1.08);
}

.header__logo-text {
    font-weight: var(--weight-extrabold);
    letter-spacing: -0.02em;
}

/* --- Desktop Nav --- */
.header__nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header__nav-item {
    position: relative;
    display: flex;
    align-items: center;
}

.header__nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast, 0.15s ease);
    text-decoration: none;
    white-space: nowrap;
}

.header__nav-link:hover,
.header__nav-link.active {
    color: var(--text-primary);
    background: var(--accent-light);
}

.header__nav-link.active {
    color: var(--accent);
    font-weight: var(--weight-semibold);
}

/* Chevron */
.header__chevron {
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
    flex-shrink: 0;
}

.header__nav-item--dropdown:hover .header__chevron,
.header__nav-item--dropdown.is-open .header__chevron {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--accent);
}

/* --- Dropdown Menu Floating Box --- */
.header__dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
    z-index: 1000;
}

/* Invisible hover bridge */
.header__dropdown-menu::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 14px;
}

.header__nav-item--dropdown:hover .header__dropdown-menu,
.header__nav-item--dropdown.is-open .header__dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.header__dropdown-menu--soluciones {
    width: 680px;
}

.header__dropdown-menu--comparativas {
    width: 580px;
}

.header__dropdown-inner {
    background: rgba(13, 17, 28, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
}

[data-theme="light"] .header__dropdown-inner {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.09);
    box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.header__dropdown-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

[data-theme="light"] .header__dropdown-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.header__dropdown-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.header__dropdown-subheading {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header__dropdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* --- Dropdown Card (Stripe / Supabase style) --- */
.dropdown-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.18s ease;
    background: transparent;
    border: 1px solid transparent;
}

.dropdown-card:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

[data-theme="light"] .dropdown-card:hover {
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(79, 70, 229, 0.15);
}

.dropdown-card.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
}

.dropdown-card__icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    margin-top: 1px;
}

.dropdown-card:hover .dropdown-card__icon-wrap {
    transform: scale(1.08);
    background: var(--accent);
    color: #ffffff;
}

.dropdown-card__content {
    flex: 1;
    min-width: 0;
}

.dropdown-card__title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.dropdown-card__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.18s ease;
    line-height: 1.3;
}

.dropdown-card:hover .dropdown-card__title {
    color: var(--accent);
}

.dropdown-card__badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.16);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1;
}

.dropdown-card__desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.35;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Featured Footer inside Dropdown --- */
.header__dropdown-featured {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

[data-theme="light"] .header__dropdown-featured {
    background: rgba(79, 70, 229, 0.04);
    border-color: rgba(79, 70, 229, 0.2);
}

.dropdown-featured__info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.775rem;
}

.dropdown-featured__tag {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.14);
    padding: 2px 6px;
    border-radius: 4px;
}

.dropdown-featured__title {
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-featured__desc {
    color: var(--text-secondary);
}

.dropdown-featured__btn {
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.15s ease;
}

.dropdown-featured__btn:hover {
    transform: translateX(2px);
    text-decoration: underline;
}

/* --- Actions --- */
.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* --- Theme Toggle --- */
.header__theme-toggle {
    position: relative;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.header__theme-toggle:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.icon-sun, .icon-moon {
    position: absolute;
    transition: all var(--transition-base);
}

.icon-sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
.icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

[data-theme="dark"] .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="dark"] .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }

/* --- Hamburger --- */
.header__hamburger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 9px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.header__hamburger:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.header__hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-base);
    transform-origin: center;
}

/* ============================================
   Mobile Sidebar & Accordions
   ============================================ */

/* Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* Sidebar panel */
.sidebar {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    right: -380px;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    width: 350px;
    max-width: calc(90vw - 16px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    box-shadow: -10px 0 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.sidebar.open {
    right: 8px;
}

/* Sidebar header */
.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar__logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-lg);
}

.sidebar__logo-img {
    height: 32px;
    width: auto;
}

.sidebar__logo-text {
    font-weight: var(--weight-extrabold);
    letter-spacing: -0.02em;
}

.sidebar__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--text-lg);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sidebar__close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Sidebar nav */
.sidebar__nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-3) var(--space-3);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar__nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 44px;
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sidebar__nav-link:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.sidebar__nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: var(--weight-semibold);
}

/* --- Mobile Accordion --- */
.sidebar__accordion {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid transparent;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.sidebar__accordion.is-open {
    border-color: var(--border);
    background: var(--bg-secondary);
}

.sidebar__accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background: none;
    border: none;
    font-size: var(--text-sm);
    font-family: inherit;
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sidebar__accordion-header:hover,
.sidebar__accordion-header.active {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.sidebar__accordion.is-open .sidebar__accordion-header {
    color: var(--accent);
    font-weight: var(--weight-semibold);
}

.sidebar__accordion-chevron {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar__accordion.is-open .sidebar__accordion-chevron {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--accent);
}

.sidebar__accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar__accordion-content {
    padding: 4px 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__sub-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sidebar__sub-link:hover,
.sidebar__sub-link.active {
    background: var(--accent-light);
    color: var(--text-primary);
}

.sidebar__sub-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.sidebar__sub-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.sidebar__sub-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sidebar__sub-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar__sub-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    text-transform: uppercase;
}

.sidebar__sub-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.25;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sidebar footer */
.sidebar__footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex-shrink: 0;
}

.sidebar__btn {
    width: 100%;
    text-align: center;
    text-decoration: none;
    padding: 10px 14px;
    font-size: var(--text-sm);
}

/* Theme toggle in sidebar */
.sidebar__theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
    margin-top: var(--space-1);
}

.sidebar__theme > span {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: var(--weight-medium);
}

.sidebar__theme-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    transition: all var(--transition-fast);
    position: relative;
}

.sidebar__theme-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar__theme-btn .icon-sun,
.sidebar__theme-btn .icon-moon {
    position: relative;
}

.sidebar__theme-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ============================================
   Responsive Breakpoints
   ============================================ */
@media (max-width: 1024px) {
    .header__hamburger { display: flex; }
    .header__nav { display: none; }
    .header__cta-desktop { display: none; }
}
