/**
 * Custom Dropdown Styles
 * Replaces Bootstrap dropdown functionality
 */

/* Dropdown container */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown toggle button */
.dropdown-toggle {
    position: relative;
    cursor: pointer;
    text-decoration: none;
    outline: none;
}

.dropdown-toggle:focus,
.dropdown-toggle:hover {
    text-decoration: none;
}

/* Caret/arrow indicator */
.caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 2px;
    vertical-align: middle;
    border-top: 4px dashed;
    border-top: 4px solid \9; /* IE8 fallback */
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

/* Dropdown menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    float: left;
    min-width: 160px;
    max-height: calc(100vh - 100px); /* Limit height to viewport minus some padding */
    padding: 5px 0;
    margin: 2px 0 0;
    font-size: 14px;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ccc;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Hide horizontal scrolling */
}

/* Show dropdown menu when open */
.dropdown.open .dropdown-menu {
    display: block;
}

/* Dropdown menu items */
.dropdown-menu > li {
    position: relative;
}

.dropdown-menu > li > a {
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: normal;
    line-height: 1.42857143;
    color: #333;
    white-space: nowrap;
    text-decoration: none;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
    color: #262626;
    text-decoration: none;
    background-color: #f5f5f5;
}

/* Active/selected item */
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
    color: #fff;
    text-decoration: none;
    background-color: #337ab7;
    outline: 0;
}

/* Disabled items */
.dropdown-menu > .disabled > a,
.dropdown-menu > .disabled > a:hover,
.dropdown-menu > .disabled > a:focus {
    color: #777;
    cursor: not-allowed;
    background-color: transparent;
}

/* Dividers */
.dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #e5e5e5;
}

/* Dropdown header */
.dropdown-menu .dropdown-header {
    display: block;
    padding: 3px 20px;
    font-size: 12px;
    line-height: 1.42857143;
    color: #777;
    white-space: nowrap;
}

/* Right-aligned dropdown menu */
.dropdown-menu.pull-right {
    right: 0;
    left: auto;
}

/* Dropdown menu arrow/caret positioning */
.dropdown-menu > li > a .fa-fw,
.dropdown-menu > li > a .k-sprite {
    margin-right: 0.4em;
}

/* Navbar specific dropdown styles */
.navbar .navbar-nav .dropdown-menu {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.navbar .navbar-nav .dropdown-menu > li > a {
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Remove padding specifically for the Settings dropdown */
.navbar .navbar-nav .dropdown:has(a[nnt-testid="admin"]) .dropdown-menu > li > a {
    padding-top: 1px;
    padding-bottom: 1px;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .navbar-nav .dropdown-menu {
        position: static;
        float: none;
        width: auto;
        margin-top: 0;
        background-color: transparent;
        border: 0;
        box-shadow: none;
    }
    
    .navbar-nav .dropdown-menu > li > a {
        padding: 5px 15px 5px 25px;
    }
    
    .navbar-nav .dropdown-menu .divider {
        background-color: #e7e7e7;
    }
}

/* Animation for dropdown open/close */
.dropdown-menu {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Focus styles for accessibility */
.dropdown-toggle:focus {
    outline: thin dotted;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: -2px;
}

.dropdown-menu > li > a:focus {
    outline: thin dotted;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dropdown-menu {
        border: 2px solid;
    }
    
    .dropdown-menu > li > a:hover,
    .dropdown-menu > li > a:focus {
        background-color: Highlight;
        color: HighlightText;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .dropdown-menu {
        transition: none;
    }
}