/**
 * Responsive Navigation CSS
 * Consolidated file for all navigation-related styles with responsive behavior
 * Designed to complement core.css without duplicating styles
 */

/* ===== NAVIGATION VARIABLES ===== */
:root {
    /* Navigation sizing - use existing breakpoints from core.css */
    --nav-height: 3.5rem;
    --mobile-nav-width: 80%;
    --mobile-touch-target: 44px;

    /* Navigation colors - using existing color variables from core.css */
    --nav-bg: var(--blue-40);
    --nav-dropdown-bg: var(--blue-60);
    --nav-active: var(--blue-50);
    --nav-hover: rgba(255, 255, 255, 0.1);
    --nav-text: #fff;
    --nav-text-muted: var(--blue-15);
}

/* ===== DEVICE CAPABILITY CLASSES ===== */
/* Applied via JavaScript based on device capabilities */
body.has-touch .hover-only {
    display: none !important;
}

body.no-touch .touch-only {
    display: none !important;
}

/* ===== BASE NAVIGATION STRUCTURE ===== */

#global-masthead {
    background: var(--nav-bg);
    color: var(--nav-text);
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    z-index: 100;
}

#global-navigation-horizontal {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
}

#global-navigation-horizontal > li {
    position: relative;
}

.global-navigation-horizontal-spacer {
    flex-grow: 1;
}

.global-nav-trigger a,
.global-nav-app-title {
    color: var(--nav-text);
    padding: 1rem;
    text-decoration: none;
    display: block;
    white-space: nowrap;
    transition: background-color 0.2s;
    min-height: var(--nav-height);
    display: flex;
    align-items: center;
}

.non-clickable .global-nav-app-title {
    opacity: 0.5;
}

.global-nav-trigger a:hover,
.global-nav-app-title:hover {
    background-color: var(--nav-hover);
}

/* ===== DROPDOWN MENUS ===== */

.global-nav-app-trigger {
    position: relative;
}

.global-nav-child-list {
    position: absolute;
    display: none;
    opacity: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    top: 100%;
    left: 0;
    z-index: 9;
    background: var(--nav-dropdown-bg);
    min-width: 200px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: opacity 0.2s, transform 0.2s;
}

.global-nav-child-item {
    background: var(--nav-dropdown-bg);
    border-top: 1px solid var(--blue-30);
}

.global-nav-child-item .global-nav-app-title {
    padding: 0.75rem 1rem;
}

/* Dropdown toggle for touch devices */
.dropdown-toggle {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    width: var(--mobile-touch-target);
    height: 100%;
    align-items: center;
    justify-content: center;
    background-color: rgba(0,0,0,0.1);
    cursor: pointer;
    z-index: 5;
}

.dropdown-toggle i {
    transition: transform 0.3s;
}

.dropdown-toggle.active i {
    transform: rotate(180deg);
}

/* ===== ORGANIZATION CONTEXT ===== */

/* Organization Selector */
.org-selector-container {
    position: relative;
    margin: 0 0.5rem;
}

#org-selector {
    max-width: 250px;
    cursor: pointer;
}

/* Organization Context Indicator */
.org-context-indicator-container {
    display: flex;
    align-items: center;
    margin: 0.5rem 0;
}

.org-context-indicator {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    min-height: 2.5rem;
}

.org-context-original {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.org-context-switched {
    background-color: var(--cta-yellow-mid);
    color: var(--blue-50);
    border: 1px solid var(--blue-40);
}

.org-context-name {
    font-weight: bold;
    margin: 0 0.3125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.return-to-original-link {
    margin-left: 0.625rem;
    font-size: 0.85em;
    color: var(--blue-50);
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.return-to-original-link i {
    margin-right: 0.25rem;
}

/* Organization Breadcrumb */
.org-breadcrumb {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background-color: #fff;
    font-size: 0.75rem;
    flex-wrap: wrap;
    column-gap: 0.25em;
}

.org-breadcrumb-item {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.org-breadcrumb-item i {
    margin-right: 0.3rem;
}

.org-breadcrumb-item.active {
    font-weight: bold;
}

.org-breadcrumb-item.separator {
    margin: 0 0.25rem;
}

.org-breadcrumb-item a {
    color: #888;
    padding: 0.25rem;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.org-breadcrumb-item a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

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

#mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.5rem;
    margin: 0 0.5rem;
    z-index: 102;
}

/* Mobile menu states */
.mobile-expanded {
    left: 0 !important; /* Override any other styles */
}

/* Backdrop states */
.mobile-nav-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-nav-backdrop.show {
    display: block;
}

.mobile-nav-backdrop.active {
    opacity: 1;
}

/* ===== TOUCH INTERACTION ENHANCEMENT ===== */

/* Touch ripple effect */
.touch-ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple-animation 0.6s linear;
    pointer-events: none;
    z-index: 5;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Active indicators */
.nav-item-active {
    background-color: var(--nav-active);
    position: relative;
}

.nav-item-active::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background-color: var(--cta-blue-mid);
}

/* Loading transitions */
.page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

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

.page-loading-spinner {
    width: 5rem;
    height: 5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Mobile styles (up to 767px) */
@media screen and (max-width: 767px) {
    /* Mobile navigation toggle */
    #mobile-nav-toggle {
        display: flex;
    }

    /* Mobile navigation backdrop */
    .mobile-nav-backdrop.show {
        display: block;
    }

    /* Mobile navigation structure */
    #global-navigation-horizontal {
        position: fixed;
        top: 0;
        left: -80%; /* Start off-screen */
        width: var(--mobile-nav-width);
        max-width: 320px;
        height: 100%;
        background: var(--nav-bg);
        flex-direction: column;
        align-items: stretch;
        padding: 3.5rem 0 1rem 0;
        z-index: 101;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    /* Mobile navigation expanded state */
    #global-navigation-horizontal.mobile-expanded {
        left: 0 !important;
    }

    /* Full width menu items on mobile */
    #global-navigation-horizontal > li {
        width: 100%;
        border-bottom: 1px solid var(--blue-30);
    }

    /* Hide spacers on mobile */
    .global-navigation-horizontal-spacer {
        display: none;
    }

    /* Mobile dropdown toggle */
    .dropdown-toggle {
        display: flex;
    }

    /* Mobile dropdown behavior */
    .global-nav-child-list {
        position: static;
        width: 100%;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        display: block;
        opacity: 1;
    }

    /* Mobile dropdown expanded state */
    .global-nav-child-list.mobile-expanded {
        max-height: 500px; /* Arbitrary large height to allow animation */
    }

    /* Child menu items */
    .global-nav-child-item {
        background: var(--blue-50);
    }

    .global-nav-child-item .global-nav-app-title {
        padding-left: 2rem;
    }

    /* Organization selector for mobile */
    #org-selector {
        max-width: 100%;
        margin: 0.5rem 1rem;
        width: calc(100% - 2rem);
        height: 3rem; /* Larger touch target */
        font-size: 1rem;
    }

    /* Organization context indicator */
    .org-context-indicator-container {
        margin: 0.5rem 1rem;
        width: calc(100% - 2rem);
    }

    .org-context-indicator {
        width: 100%;
        flex-wrap: wrap;
    }

    .org-context-name {
        max-width: 80%;
    }

    .return-to-original-link {
        margin-left: 0;
        margin-top: 0.25rem;
    }

    /* Breadcrumb for mobile */
    .org-breadcrumb {
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
        padding-bottom: 4px;
    }

    .org-breadcrumb::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
}

/* Tablet styles (768px to 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .global-nav-app-title {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* More compact organization elements */
    #org-selector {
        max-width: 200px;
    }

    .org-breadcrumb {
        font-size: 0.8rem;
    }

    /* Adjust navigation to wrap better */
    #global-navigation-horizontal {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Desktop styles (1024px and up) */
@media screen and (min-width: 1024px) {
    /* Dropdown on hover for desktop with mouse */
    body.has-mouse .global-nav-app-trigger:hover .global-nav-child-list {
        display: block;
        opacity: 1;
    }

    /* Hide dropdown toggles on desktop */
    .dropdown-toggle {
        display: none;
    }

    /* Restore spacers */
    .global-navigation-horizontal-spacer {
        display: block;
    }
}

/* ANIMATIONS & TRANSITIONS */

/* Menu transition */
@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes slideOut {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

/* Fade transitions */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}