/* ============================================================================
   Dropdown Component Styles
   Unified dropdown menu styles for consistent behavior across the application
   ============================================================================ */

/* Base Dropdown Styles
   ========================================================================== */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Standard Dropdown Menu */
.dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 200px;
    margin-top: 0;  /* Removed gap to prevent hover loss */
    padding-top: 0.25rem;  /* Add padding inside instead */
    top: 100%;
    left: 0;
}

/* Hover-based dropdown with pseudo-element bridge */
.dropdown:hover .dropdown-menu,
.dropdown .dropdown-menu:hover {
    display: block;
}

/* Create invisible bridge to prevent hover loss */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;  /* Increased from 0.5rem for better coverage */
    left: -10px;  /* Extended sides for diagonal mouse movement */
    right: -10px;
    height: 15px;  /* Increased height for more forgiveness */
    background: transparent;
    pointer-events: auto;  /* Ensure it captures hover */
}

/* Dropdown Items */
.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
    font-size: 0.875rem;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-primary-dark);
}

.dropdown-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--color-border);
}

/* Action Dropdown (Three-dot menu)
   ========================================================================== */
.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text-muted);
}

.action-dropdown-toggle:hover {
    background: var(--color-gray-100);
    border-color: var(--color-border);
}

.action-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 2px);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 160px;
    padding: 0.25rem 0;
}

/* Show dropdown when active class is present */
.action-dropdown.active .action-dropdown-menu {
    display: block;
}

.action-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
}

.action-dropdown-item:hover {
    background: var(--color-gray-50);
}

.action-dropdown-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.action-dropdown-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--color-border);
}

/* CLD Dropdown (for phone numbers with HLR lookup)
   ========================================================================== */
.cld-dropdown {
    position: relative;
    display: inline-block;
}

.cld-dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 200px;
    margin-top: 0.25rem;
    top: 100%;
    left: 0;
}

.cld-dropdown:hover .cld-dropdown-menu {
    display: block;
}

.cld-dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
    font-size: 0.875rem;
}

.cld-dropdown-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-primary-dark);
}

/* Dropdown Toggle Arrow Override (for Bootstrap compatibility)
   ========================================================================== */
.dropdown-toggle::after {
    display: none !important;
}

/* Disable Bootstrap dropdown styles that may interfere */
.dropdown-menu.show {
    display: none !important;
}

/* Dropdown Positioning Variants
   ========================================================================== */
.dropdown-menu.dropdown-menu-right {
    right: 0;
    left: auto;
}

.dropdown-menu.dropdown-menu-left {
    left: 0;
    right: auto;
}

/* Navigation Bar Dropdown Fixes
   ========================================================================== */
.nav-item.dropdown {
    position: relative;
}

.nav-item.dropdown .dropdown-menu {
    margin-top: -5px;  /* Slight overlap to maintain hover */
    padding-top: 10px;  /* Compensate with internal padding */
    top: 100%;
}

/* Keep dropdown visible when hovering over menu items */
.nav-item.dropdown:hover .dropdown-menu,
.nav-item.dropdown .dropdown-menu:hover {
    display: block !important;
}

/* Add delay to prevent accidental closure */
.nav-item.dropdown .dropdown-menu {
    transition: opacity 0.15s, visibility 0.15s;
}

/* Create larger hover bridge for nav dropdowns */
.nav-item.dropdown::after {
    content: '';
    position: absolute;
    bottom: -10px;  /* Extend below the nav item */
    left: -10px;
    right: -10px;
    height: 20px;  /* Larger bridge area */
    background: transparent;
    z-index: 1001;
    pointer-events: none;  /* Don't block clicks */
}

/* Extend hover area for dropdown menu */
.nav-item.dropdown .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -15px;  /* Large overlap area */
    left: -15px;
    right: -15px;
    height: 20px;
    background: transparent;
    pointer-events: auto;
}

/* Responsive Behavior
   ========================================================================== */
@media (max-width: 768px) {
    .dropdown-menu,
    .action-dropdown-menu,
    .cld-dropdown-menu {
        min-width: 150px;
        font-size: 0.8125rem;
    }

    .dropdown-item,
    .action-dropdown-item,
    .cld-dropdown-item {
        padding: 0.375rem 0.75rem;
    }
}