/* ============================================================
   POLYGON FRAMEWORK
   PRO PREMIUM DESIGN TEMPLATE NAVIGATION (MODERN UI UPGRADE)
   ============================================================ */

.pf-global-template-nav {
    --pf-nav-primary: var(--primary-color, #6366f1);
    --pf-nav-primary-hover: var(--primary-color-hover, #4f46e5);
    --pf-nav-primary-glow: rgba(99, 102, 241, 0.25);
    --pf-nav-text: #0f172a;
    --pf-nav-muted: #64748b;
    --pf-nav-border: rgba(226, 232, 240, 0.8);
    --pf-nav-soft-bg: rgba(248, 250, 252, 0.8);
    --pf-nav-glass: rgba(255, 255, 255, 0.85);
    --pf-nav-radius: 14px;
    --pf-nav-transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);

    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    border-bottom: 1px solid var(--pf-nav-border);
    background: var(--pf-nav-glass);
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05),
                0 2px 6px -1px rgba(15, 23, 42, 0.03);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
}

.pf-tn-container {
    width: min(1280px, calc(100% - 32px));
    margin-inline: auto;
}

/* ============================================================
   DESKTOP BAR UI
   ============================================================ */

.pf-tn-desktop {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pf-tn-item {
    position: relative;
    flex: 0 0 auto;
}

.pf-tn-link,
.pf-tn-item > summary {
    position: relative;
    min-height: 40px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--pf-nav-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    transition: var(--pf-nav-transition);
}

.pf-tn-item > summary {
    list-style: none;
}

.pf-tn-item > summary::-webkit-details-marker {
    display: none;
}

.pf-tn-link > i:first-child,
.pf-tn-item > summary > i:first-child:not(.pf-tn-chevron) {
    color: var(--pf-nav-muted);
    font-size: 14px;
    transition: var(--pf-nav-transition);
}

.pf-tn-link:hover,
.pf-tn-item > summary:hover {
    color: var(--pf-nav-primary);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-1px);
}

.pf-tn-link:hover > i:first-child,
.pf-tn-item > summary:hover > i:first-child:not(.pf-tn-chevron) {
    color: var(--pf-nav-primary);
}

.pf-tn-link.is-active,
.pf-tn-item.is-active > summary {
    color: var(--pf-nav-primary);
    border-color: rgba(99, 102, 241, 0.18);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 12px var(--pf-nav-primary-glow);
}

/* ============================================================
   CHEVRON
   ============================================================ */

.pf-tn-chevron {
    margin-left: 2px;
    color: var(--pf-nav-muted);
    font-size: 10px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.pf-tn-item[open] > summary .pf-tn-chevron {
    color: var(--pf-nav-primary);
    transform: rotate(180deg);
}

/* ============================================================
   TOP LEVEL DROPDOWN CARD (PRO GLASSMORPHISM)
   ============================================================ */

.pf-tn-desktop > .pf-tn-item--dropdown > .pf-tn-dropdown {
    position: absolute;
    width: max-content;
    min-width: 260px;
    max-width: 340px;
    left: 0;
    top: calc(100% + 10px);
    padding: 8px;
    display: grid;
    gap: 4px;
    border: 1px solid var(--pf-nav-border);
    border-radius: var(--pf-nav-radius);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.12),
                0 10px 15px -5px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(20px);
    animation: pfNavDropdownIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
}

/* Pointer Arrow */
.pf-tn-desktop > .pf-tn-item--dropdown > .pf-tn-dropdown::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 24px;
    width: 10px;
    height: 10px;
    border-top: 1px solid var(--pf-nav-border);
    border-left: 1px solid var(--pf-nav-border);
    background: rgba(255, 255, 255, 0.95);
    transform: rotate(45deg);
}

/* ============================================================
   DROPDOWN ROW TILES
   ============================================================ */

.pf-tn-dropdown .pf-tn-link,
.pf-tn-dropdown .pf-tn-item > summary {
    width: 100%;
    min-height: 44px;
    padding: 6px 12px;
    justify-content: flex-start;
    border-radius: 10px;
    color: #334155;
    font-size: 12.5px;
    font-weight: 500;
}

.pf-tn-dropdown .pf-tn-link > i:first-child,
.pf-tn-dropdown .pf-tn-item > summary > i:first-child:not(.pf-tn-chevron) {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 28px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--pf-nav-primary);
    font-size: 12px;
    transition: var(--pf-nav-transition);
}

.pf-tn-dropdown .pf-tn-link:hover,
.pf-tn-dropdown .pf-tn-item > summary:hover {
    background: rgba(99, 102, 241, 0.06);
    color: var(--pf-nav-primary);
    transform: translateX(3px);
}

.pf-tn-dropdown .pf-tn-link:hover > i:first-child,
.pf-tn-dropdown .pf-tn-item > summary:hover > i:first-child:not(.pf-tn-chevron) {
    background: var(--pf-nav-primary);
    color: #ffffff;
    box-shadow: 0 4px 10px var(--pf-nav-primary-glow);
}

/* ============================================================
   NESTED DROPDOWN (LEVEL 2)
   ============================================================ */

.pf-tn-dropdown .pf-tn-item--dropdown {
    width: 100%;
}

.pf-tn-dropdown .pf-tn-item--dropdown > summary {
    justify-content: flex-start;
}

.pf-tn-dropdown .pf-tn-item--dropdown > summary .pf-tn-chevron {
    margin-left: auto;
    transform: rotate(-90deg);
}

.pf-tn-dropdown .pf-tn-item--dropdown[open] > summary .pf-tn-chevron {
    transform: rotate(0deg);
}

.pf-tn-dropdown .pf-tn-item--dropdown > .pf-tn-dropdown {
    position: relative;
    margin: 4px 0 4px 12px;
    padding: 4px 0 4px 10px;
    display: grid;
    gap: 3px;
    border: 0;
    border-left: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: pfNavNestedIn 0.18s ease-out;
}

.pf-tn-dropdown .pf-tn-dropdown .pf-tn-link {
    min-height: 36px;
    padding-left: 8px;
    color: #475569;
    font-size: 11.5px;
}

/* Open State */
.pf-tn-item--dropdown[open] > summary {
    color: var(--pf-nav-primary);
    background: rgba(99, 102, 241, 0.08);
}

/* ============================================================
   RIGHT EDGE VIEWPORT AUTO-ALIGNMENT
   ============================================================ */

.pf-tn-desktop > .pf-tn-item--dropdown:nth-last-child(-n+2) > .pf-tn-dropdown {
    left: auto;
    right: 0;
    transform-origin: top right;
}

.pf-tn-desktop > .pf-tn-item--dropdown:nth-last-child(-n+2) > .pf-tn-dropdown::before {
    left: auto;
    right: 24px;
}

.pf-tn-desktop > .pf-tn-item--dropdown.pf-tn-align-right > .pf-tn-dropdown {
    left: auto;
    right: 0;
    transform-origin: top right;
}

.pf-tn-desktop > .pf-tn-item--dropdown.pf-tn-align-right > .pf-tn-dropdown::before {
    left: auto;
    right: 24px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes pfNavDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* ============================================================
   MOBILE NAVIGATION
   ============================================================ */

.pf-tn-mobile {
    display: none;
}

@media (max-width: 860px) {
    .pf-global-template-nav {
        background: #ffffff;
    }

    .pf-tn-desktop {
        display: none;
    }

    .pf-tn-mobile {
        display: block;
    }

    .pf-tn-mobile > summary {
        min-height: 60px;
        display: inline-flex;
        align-items: center;
        gap: 10px;
        color: #0f172a;
        font-size: 14px;
        font-weight: 700;
        list-style: none;
        cursor: pointer;
    }

    .pf-tn-mobile > summary::-webkit-details-marker {
        display: none;
    }

    .pf-tn-mobile > summary > i {
        width: 36px;
        height: 36px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: rgba(99, 102, 241, 0.1);
        color: var(--pf-nav-primary);
        font-size: 16px;
    }

    .pf-tn-mobile-panel {
        padding: 4px 0 16px;
        display: grid;
        gap: 6px;
    }

    .pf-tn-mobile-panel .pf-tn-link,
    .pf-tn-mobile-panel .pf-tn-item > summary {
        width: 100%;
        min-height: 48px;
        padding: 0 14px;
        justify-content: flex-start;
        border: 1px solid var(--pf-nav-border);
        border-radius: 12px;
        background: #ffffff;
        box-shadow: 0 2px 5px rgba(15, 23, 42, 0.02);
    }

    .pf-tn-mobile-panel .pf-tn-item--dropdown > summary .pf-tn-chevron {
        margin-left: auto;
    }

    .pf-tn-mobile-panel .pf-tn-dropdown {
        position: static;
        min-width: 0;
        max-width: none;
        margin: 4px 0 4px 16px;
        padding: 4px 0 4px 12px;
        display: grid;
        gap: 4px;
        border: 0;
        border-left: 2px solid rgba(99, 102, 241, 0.2);
        background: transparent;
        box-shadow: none;
    }
}

/* ============================================================
   SMALL MOBILE
   ============================================================ */

@media (max-width: 480px) {
    .pf-tn-container {
        width: calc(100% - 24px);
    }

    .pf-tn-mobile-panel .pf-tn-link,
    .pf-tn-mobile-panel .pf-tn-item > summary {
        min-height: 44px;
        font-size: 12px;
    }
}

/* ============================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .pf-tn-dropdown,
    .pf-tn-link,
    .pf-tn-item > summary,
    .pf-tn-chevron {
        animation: none !important;
        transition: none !important;
    }
}
