
:root {
    --nb-bg: #0b1929;
    --nb-border: rgba(40, 114, 196, 0.2);
    --nb-accent: #2872c4;
    --nb-accent2: #3db843;
    --nb-text: #e8edf5;
    --nb-muted: #7a8fa6;
    --nb-danger: #e74c3c;
}

/* TOPBAR */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 72px;
    width: 100%;
    box-sizing: border-box;
    background: rgba(10, 22, 40, 0.98);
    border-bottom: 1px solid rgba(40, 114, 196, 0.25);
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 20px rgba(0, 0, 0, .35);
    font-family: 'Segoe UI', sans-serif;
}
.topbar > .topbar-left-group { justify-self: start; }
.topbar > .topbar-navigation { justify-self: center; }
.topbar > .topbar-right { justify-self: end; }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    text-decoration: none;
}
.topbar-brand:hover { color: #fff; text-decoration: none; opacity: .85; }
.topbar-brand svg { stroke: var(--nb-accent2); }

.topbar-logo {
    height: 56px;
    width: auto;
    max-width: 260px;
    object-fit: contain;
    display: block;
}
.viewer-topbar .topbar-logo {
    height: 48px;
    max-width: 220px;
}
@media (max-width: 640px) {
    .viewer-topbar .topbar-logo { height: 40px; max-width: 160px; }
}

.topbar-docs-link {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,.55);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.12);
    transition: color .15s, border-color .15s, background .15s;
    white-space: nowrap;
}
.topbar-docs-link svg { stroke: currentColor; }
.topbar-docs-link:hover {
    color: #00d4ff;
    border-color: rgba(0,212,255,.4);
    background: rgba(0,212,255,.07);
    text-decoration: none;
}

.topbar-left-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-search {
    flex: 1;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--nb-border);
    border-radius: 8px;
    padding: 0 14px;
    height: 36px;
}
.topbar-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--nb-text);
    font-size: 13px;
    width: 100%;
}
.topbar-search svg {
    width: 16px;
    height: 16px;
    stroke: var(--nb-muted);
    flex-shrink: 0;
}

/* --- NAVEGACIÓN CENTRAL --- */
.topbar-navigation {
    flex: 1;
    display: flex;
    justify-content: center;
}

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

.nav-link-item {
    color: var(--nb-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 25px 0;
    cursor: pointer;
    transition: color .2s;
}

.nav-link-item:hover { color: var(--nb-accent2); text-decoration: none; }

.nav-chevron {
    width: 5px; height: 5px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-bottom: 2px;
    transition: transform .3s;
}

/* --- MEGA MENU PANEL BASE --- */
.nav-item-has-menu { position: relative; }

.mega-menu-panel {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(15px);

    /* 👇 AQUÍ ESTÁ LA SOLUCIÓN DEFINITIVA 👇 */
    width: max-content;

    min-width: 200px;
    background: #0d1b2a;
    border: 1px solid var(--nb-border);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    opacity: 0;
    visibility: hidden;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
}

.nav-item-has-menu:hover .mega-menu-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-item-has-menu:hover .nav-chevron { transform: rotate(225deg); }

/* Grillas Dinámicas Elásticas */
.mega-grid {
    padding: 30px;
    display: flex;
    gap: 40px;
    flex-wrap: nowrap;
}

.mega-col h4 {
    color: var(--nb-accent2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 15px;
    font-weight: 800;
}

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

.mega-col a {
    color: var(--nb-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}

.mega-col a:hover { color: white; transform: translateX(5px); text-decoration: none; }

/* Sección Destacada */
.mega-featured {
    width: 240px;
    background: rgba(255,255,255,0.03);
    padding: 30px;
    border-left: 1px solid var(--nb-border);
    display: flex;
    flex-direction: column;
}

.mega-feat-img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--nb-border);
    display: block;
}
.mega-featured h5 { color: white; font-size: 15px; margin-bottom: 8px; }
.mega-featured p { color: var(--nb-muted); font-size: 12px; line-height: 1.5; margin-bottom: 15px; }
.mega-feat-link { color: var(--nb-accent2); font-size: 12px; font-weight: 700; text-decoration: none; margin-top: auto; }

/* NOTIFICATIONS */
.topbar-notif {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--nb-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.topbar-notif:hover {
    background: rgba(0, 212, 255, .08);
    border-color: rgba(0, 212, 255, .3);
}
.topbar-notif svg {
    width: 20px;
    height: 20px;
    stroke: var(--nb-text);
    fill: none;
}
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff9800;
    color: #000;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #0a1628;
    box-sizing: border-box;
}
.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #0d1b2a;
    border: 1px solid rgba(0, 212, 255, .2);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
    overflow: hidden;
    z-index: 600;
    flex-direction: column;
}
.notif-dropdown.open { display: flex; }
.notif-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0, 212, 255, .1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin: 0;
}
.notif-view-all {
    font-size: 12px;
    color: var(--nb-accent);
    text-decoration: none;
    font-weight: 600;
}
.notif-view-all:hover { text-decoration: underline; }
.notif-body {
    max-height: 380px;
    overflow-y: auto;
}
.notif-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--nb-muted);
    font-size: 13px;
}
.notif-item {
    display: flex;
    flex-direction: column;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .04);
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
}
.notif-item:hover { background: rgba(0, 212, 255, .05); }
.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}
.notif-item-body {
    font-size: 12px;
    color: #c8d8e8;
    line-height: 1.4;
    margin-bottom: 6px;
}
.notif-item-meta {
    font-size: 11px;
    color: var(--nb-muted);
    display: flex;
    justify-content: space-between;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.project-count {
    font-size: 12px;
    color: var(--nb-muted);
    white-space: nowrap;
}

.btn-new {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--nb-accent);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .5px;
    white-space: nowrap;
    transition: background .2s, transform .15s;
}
.btn-new:hover {
    background: #fff;
    transform: translateY(-1px);
}
.btn-new svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* USER DROPDOWN */
.user-menu { position: relative; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--nb-border);
    border-radius: 8px;
    padding: 5px 12px 5px 6px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.user-btn:hover {
    background: rgba(0, 212, 255, .08);
    border-color: rgba(0, 212, 255, .3);
}
.user-btn img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 212, 255, .25);
    flex-shrink: 0;
}
.user-btn-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--nb-text);
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-btn-arrow {
    font-size: 9px;
    color: var(--nb-muted);
    margin-left: 2px;
}
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: #0d1b2a;
    border: 1px solid rgba(0, 212, 255, .2);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .6);
    overflow: hidden;
    z-index: 500;
}
.user-dropdown.open { display: block; }
.user-dd-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 16px;
    font-size: 13px;
    color: #c8d8e8;
    cursor: pointer;
    transition: background .12s;
    text-decoration: none;
}
.user-dd-item:hover {
    background: rgba(0, 212, 255, .1);
    color: var(--nb-accent);
}
.user-dd-item.danger:hover {
    background: rgba(255, 77, 77, .12);
    color: var(--nb-danger);
}
.user-dd-sep {
    height: 1px;
    background: rgba(0, 212, 255, .08);
    margin: 3px 0;
}

/* AUTH buttons */
.topbar-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-signin {
    padding: 7px 18px;
    background: transparent;
    color: var(--nb-accent);
    border: 1px solid rgba(0, 212, 255, .35);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn-signin:hover { background: rgba(0, 212, 255, .1); }
.btn-signup {
    padding: 7px 18px;
    background: var(--nb-accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.btn-signup:hover { background: #fff; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .topbar { padding: 0 16px; gap: 10px; }
    .topbar-search { max-width: 260px; }
}
@media (max-width: 992px) {
    .topbar-navigation {
        display: none;
    }
}
@media (max-width: 640px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 14px 8px;
        gap: 8px;
    }
    .topbar-brand { font-size: 15px; }
    .topbar-brand svg { width: 22px; height: 22px; }
    .topbar-logo { height: 42px; }
    .topbar-search {
        order: 3;
        flex: 1 1 100%;
        max-width: 100%;
        height: 38px;
        margin: 0;
    }
    .topbar-right {
        margin-left: auto;
        gap: 8px;
        order: 2;
    }
    .project-count { display: none; }
    .btn-new .btn-new-text { display: none; }
    .btn-new { padding: 8px 10px; border-radius: 8px; gap: 0; }
    .user-btn-name { display: none; }
    .notif-dropdown {
        position: fixed;
        top: 55px;
        right: 14px;
        left: 14px;
        width: auto;
        max-width: none;
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .topbar-search { display: none; }
    .btn-signin,
    .btn-signup {
        padding: 6px 12px;
        font-size: 12px;
    }
    .btn-signup {
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 380px) {
    .topbar-brand span { display: none; }
    .btn-new { padding: 8px; }
}