/* =============================================================================
   components/dropdown.css
   Unified dropdown component.

   Two complementary layers:
     1. Shell  — .custom-dropdown, .dropdown-trigger, .dropdown-content
                 The outer clickable control and its animated panel.
     2. Content — .dropdown-search-container, .dropdown-options-container,
                  .dropdown-option, .optgroup, etc.
                  What lives inside the panel (CRM selector, search, optgroups).
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Shell
   ----------------------------------------------------------------------------- */

.custom-dropdown {
    position: relative;
    width: 100%;
    font-family: var(--font-family);
}

.custom-dropdown-container {
    position: relative;
    width: 100%;
    overflow: visible;
    z-index: var(--z-dropdown);
}

.custom-dropdown.active {
    z-index: calc(var(--z-dropdown) + 2);
}

.custom-dropdown.active .dropdown-content {
    display: block;
}

.custom-dropdown.active .dropdown-trigger::after {
    transform: rotate(180deg);
}

/* Trigger button */
.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-size: var(--font-size-base);
    text-align: left;
    cursor: pointer;
    position: relative;
    z-index: calc(var(--z-dropdown) + 1);
    transition: var(--transition-fast);
}

.dropdown-trigger::after {
    content: '';
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-light);
    margin-left: 10px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.dropdown-trigger:hover {
    border-color: var(--primary);
}

/* Dropdown panel */
.dropdown-content {
    display: none;
    position: static;
    width: 100%;
    margin-top: 2px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    max-height: 350px;
    min-height: 250px;
    overflow-y: auto;
    z-index: calc(var(--z-dropdown) + 2);
    animation: slideDown 0.2s ease;
}

.dropdown-content::-webkit-scrollbar       { width: 6px; }
.dropdown-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.dropdown-content::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }
.dropdown-content::-webkit-scrollbar-track { background: var(--input-bg); border-radius: 10px; }

/* Hidden native select (accessibility) */
.hidden-select {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* overflow escape for parent containers */
.ghlm-form-group {
    position: relative;
    overflow: visible;
    z-index: auto;
    margin-bottom: 1.5rem;
}

/* -----------------------------------------------------------------------------
   Search area (inside panel)
   ----------------------------------------------------------------------------- */

.dropdown-search-container {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: var(--space-3);
    color: var(--text-light);
    font-size: var(--font-size-base);
    pointer-events: none;
    z-index: 1;
}

.system-search-input {
    width: 100%;
    padding: var(--space-2) var(--space-8) var(--space-2) var(--space-8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    background: var(--bg-primary);
    color: var(--text-dark);
    transition: var(--transition-fast);
}

.system-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.system-search-input::placeholder {
    color: var(--text-light);
    font-size: var(--font-size-sm);
}

/* -----------------------------------------------------------------------------
   Options list
   ----------------------------------------------------------------------------- */

.dropdown-options-container {
    max-height: 280px;
    overflow-y: auto;
}

.dropdown-options-container::-webkit-scrollbar       { width: 6px; }
.dropdown-options-container::-webkit-scrollbar-track  { background: var(--gray-100); border-radius: var(--radius-sm); }
.dropdown-options-container::-webkit-scrollbar-thumb  { background: var(--gray-300); border-radius: var(--radius-sm); }
.dropdown-options-container::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.dropdown-option {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--text-dark);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dropdown-option:hover:not(.disabled) {
    background-color: var(--bg-secondary);
    color: var(--primary);
}

.dropdown-option.selected {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: var(--font-weight-medium);
}

.dropdown-option.disabled {
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.dropdown-option.disabled:hover {
    background-color: transparent;
    color: var(--text-light);
}

.dropdown-option.hidden {
    display: none;
}

/* -----------------------------------------------------------------------------
   No-results state
   ----------------------------------------------------------------------------- */

.no-results-message {
    padding: var(--space-5) var(--space-4);
    text-align: center;
}

.no-results-content i {
    font-size: var(--font-size-2xl);
    color: var(--gray-300);
    margin-bottom: var(--space-2);
    display: block;
}

.no-results-content h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 var(--space-2) 0;
}

.no-results-content p {
    font-size: var(--font-size-sm);
    color: var(--text-light);
    margin: 0 0 var(--space-4) 0;
    line-height: var(--line-height-normal);
}

/* -----------------------------------------------------------------------------
   Request section (inside no-results panel)
   ----------------------------------------------------------------------------- */

.request-section {
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-4);
    margin-top: var(--space-4);
}

.request-section h4 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 var(--space-2) 0;
}

.request-description {
    font-size: var(--font-size-xs);
    color: var(--text-light);
    margin: 0 0 var(--space-3) 0;
    line-height: var(--line-height-tight);
}

.request-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: var(--transition-base);
}

.request-btn:hover {
    background: var(--primary-dark);
    color: white;
    text-decoration: none;
}

.request-btn i {
    font-size: var(--font-size-xs);
}

/* -----------------------------------------------------------------------------
   Option groups
   ----------------------------------------------------------------------------- */

.optgroups-container {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    margin-top: var(--space-2);
    display: flex;
    flex-wrap: wrap;
}

.optgroup {
    flex: 1;
    min-width: 180px;
    padding: var(--space-3);
    border-right: 1px solid var(--border-color);
}

.optgroup:last-child {
    border-right: none;
}

.optgroup-label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--primary-light);
}

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .dropdown-content {
        max-height: 350px;
        min-height: 180px;
    }

    .optgroup {
        min-width: 160px;
    }
}

@media (max-width: 480px) {
    .dropdown-content {
        max-height: 300px;
        min-height: 160px;
    }

    .optgroup {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .optgroup:last-child {
        border-bottom: none;
    }

    .optgroups-container {
        flex-direction: column;
    }

    .dropdown-search-container {
        padding: var(--space-2);
    }

    .system-search-input {
        padding: var(--space-2) var(--space-8);
        font-size: var(--font-size-sm);
    }

    .dropdown-option {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
    }
}
