/* ==========================================================================
   SYIFA GOLD - Unified Premium Dropdown & Custom Select Component
   Shared single source of truth across Admin Portal, User Portal, Public Pages,
   and Standalone Print Pages.
   1. Fixes Bootstrap action dropdowns clipped by .table-responsive / overflow:hidden cards
   2. Upgrades native <select> elements into a luxury custom dropdown UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Luxury Floating Action Dropdowns (Bootstrap .dropdown-menu & Portal)
   -------------------------------------------------------------------------- */
.dropdown-menu {
    z-index: 2050 !important;
    background: #ffffff !important;
    border: 1px solid rgba(212, 175, 55, 0.28) !important;
    border-radius: 14px !important;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(96, 0, 16, 0.08) !important;
    padding: 0.45rem !important;
    min-width: 220px;
}

.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem !important;
    border-radius: 10px !important;
    font-size: 0.88rem;
    font-weight: 500;
    color: #1e293b;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
}

.dropdown-menu .dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: linear-gradient(135deg, rgba(96, 0, 16, 0.06) 0%, rgba(212, 175, 55, 0.14) 100%) !important;
    color: #600010 !important;
    transform: translateX(2px);
}

.dropdown-menu .dropdown-item.text-danger:hover,
.dropdown-menu .dropdown-item.text-danger:focus {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}

.dropdown-menu .dropdown-item.logout-btn {
    color: #dc2626 !important;
    background: #fef2f2 !important;
    font-weight: 600;
}

.dropdown-menu .dropdown-item.logout-btn:hover,
.dropdown-menu .dropdown-item.logout-btn:focus {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

.dropdown-menu .dropdown-item.active,
.dropdown-menu .dropdown-item:active {
    background: linear-gradient(135deg, #600010 0%, #870018 100%) !important;
    color: #ffd700 !important;
}

.dropdown-menu .dropdown-item.active i,
.dropdown-menu .dropdown-item:active i {
    color: #ffd700 !important;
}

.dropdown-menu .dropdown-divider {
    margin: 0.35rem 0.25rem !important;
    border-color: rgba(226, 232, 240, 0.85) !important;
}

/* Public mobile navbar collapsed dropdowns remain flat inline inside mobile drawer */
@media (max-width: 991.98px) {
    .navbar .navbar-collapse .dropdown-menu {
        border: none !important;
        box-shadow: none !important;
        background: #fbf7f7 !important;
        border-radius: 10px !important;
        margin: 0.25rem 0 0.5rem !important;
        padding: 0.35rem !important;
        min-width: 0;
    }
}

/* Floating portal state for content-area Bootstrap dropdowns (tables, cards, hero banners) */
.dropdown-menu.sg-floating-dropdown-portal {
    position: fixed !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 2100 !important;
    max-height: min(380px, calc(100vh - 24px));
    overflow-y: auto;
}

/* --------------------------------------------------------------------------
   2. Premium Custom <select> Component (.sg-select-wrapper)
   -------------------------------------------------------------------------- */
.sg-select-native-hidden {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

.sg-select-wrapper {
    position: relative;
    display: block;
    width: 100%;
    font-family: 'Sarabun', 'Prompt', sans-serif;
}

.sg-select-wrapper.sg-select-inline {
    display: inline-block;
    width: auto;
    min-width: 165px;
}

/* Support inside Bootstrap .input-group */
.input-group > .sg-select-wrapper {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group > .sg-select-wrapper:not(:first-child) .sg-select-trigger {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.input-group > .sg-select-wrapper:not(:last-child) .sg-select-trigger {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* Trigger Button */
.sg-select-trigger {
    width: 100%;
    min-height: 42px;
    padding: 0.52rem 2.35rem 0.52rem 0.95rem;
    background: #ffffff;
    border: 1px solid #dce3ec;
    border-radius: 12px;
    color: #1e293b;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
    user-select: none;
}

.sg-select-wrapper.sg-select-sm .sg-select-trigger,
.input-group-sm > .sg-select-wrapper .sg-select-trigger {
    min-height: 35px;
    padding: 0.32rem 2.05rem 0.32rem 0.72rem;
    font-size: 0.84rem;
    border-radius: 10px;
}

.input-group-sm > .sg-select-wrapper .sg-select-arrow {
    right: 0.45rem;
    width: 19px;
    height: 19px;
    font-size: 0.65rem;
}

.sg-select-wrapper.sg-select-lg .sg-select-trigger,
.input-group-lg > .sg-select-wrapper .sg-select-trigger {
    min-height: 48px;
    padding: 0.68rem 2.5rem 0.68rem 1.1rem;
    font-size: 1rem;
    border-radius: 14px;
}

/* Pill variant (e.g. Public products filter bar) */
.sg-select-wrapper.sg-select-pill .sg-select-trigger {
    border-radius: 50px;
    padding-left: 1.2rem;
    padding-right: 2.5rem;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    background-color: #fdfcfc;
}

.sg-select-wrapper.sg-select-pill .sg-select-arrow {
    right: 0.85rem;
    border-radius: 50%;
}

.sg-select-trigger:hover:not(:disabled) {
    border-color: #d4af37;
    background-color: #fffdf9;
    box-shadow: 0 3px 10px rgba(212, 175, 55, 0.12);
}

.sg-select-trigger:focus,
.sg-select-wrapper.sg-open .sg-select-trigger {
    outline: none;
    border-color: #d4af37 !important;
    background-color: #ffffff;
    box-shadow: 0 0 0 3.5px rgba(212, 175, 55, 0.2), 0 4px 12px rgba(96, 0, 16, 0.08) !important;
}

.sg-select-wrapper.sg-invalid .sg-select-trigger {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18) !important;
}

.sg-select-trigger:disabled,
.sg-select-wrapper.sg-disabled .sg-select-trigger {
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
    box-shadow: none;
}

/* Dark glassmorphism surface integration (Public Gold Prices Hero Card) */
body.page-gold-prices .round-selector-card .sg-select-trigger {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #ffffff;
    box-shadow: none;
}

body.page-gold-prices .round-selector-card .sg-select-trigger:hover:not(:disabled),
body.page-gold-prices .round-selector-card .sg-select-wrapper.sg-open .sg-select-trigger {
    background: rgba(255, 255, 255, 0.22);
    border-color: #ffd700 !important;
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.22) !important;
}

body.page-gold-prices .round-selector-card .sg-select-label.sg-placeholder {
    color: rgba(255, 255, 255, 0.8);
}

body.page-gold-prices .round-selector-card .sg-select-arrow {
    background: rgba(255, 215, 0, 0.22);
    color: #ffd700;
}

.sg-select-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

.sg-select-label.sg-placeholder {
    color: #64748b;
}

/* Custom Chevron Indicator */
.sg-select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(212, 175, 55, 0.12);
    color: #870018;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, color 0.2s ease;
    pointer-events: none;
}

.sg-select-wrapper.sg-open .sg-select-arrow {
    transform: translateY(-50%) rotate(180deg);
    background: linear-gradient(135deg, #600010 0%, #870018 100%);
    color: #ffd700;
}

/* Floating Portal Menu for Custom Select */
.sg-select-portal {
    position: fixed;
    z-index: 2150;
    background: #ffffff;
    border: 1px solid rgba(212, 175, 55, 0.38);
    border-radius: 14px;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16), 0 4px 14px rgba(96, 0, 16, 0.1);
    padding: 0.45rem;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Sarabun', 'Prompt', sans-serif;
    animation: sgDropdownFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.sg-select-portal.sg-show {
    display: flex;
}

@keyframes sgDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Search Box inside Select Portal (auto-shown when visible options >= 8) */
.sg-select-search-wrap {
    padding: 0.25rem 0.25rem 0.45rem;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.3rem;
    position: relative;
}

.sg-select-search-input {
    width: 100%;
    padding: 0.42rem 0.75rem 0.42rem 2rem;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc;
    color: #1e293b;
    transition: all 0.18s ease;
}

.sg-select-search-input:focus {
    outline: none;
    background: #ffffff;
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16);
}

.sg-select-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-55%);
    color: #94a3b8;
    font-size: 0.78rem;
    pointer-events: none;
}

/* Options List */
.sg-select-options {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 265px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.45) transparent;
}

.sg-select-options::-webkit-scrollbar {
    width: 6px;
}

.sg-select-options::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.45);
    border-radius: 6px;
}

.sg-select-group-header {
    padding: 0.45rem 0.75rem 0.25rem;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #870018;
}

.sg-select-option {
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.89rem;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    margin-bottom: 2px;
}

.sg-select-option:last-child {
    margin-bottom: 0;
}

.sg-select-option:hover,
.sg-select-option.sg-focused {
    background: linear-gradient(135deg, rgba(96, 0, 16, 0.06) 0%, rgba(212, 175, 55, 0.15) 100%);
    color: #600010;
}

.sg-select-option.sg-selected {
    background: linear-gradient(135deg, #600010 0%, #870018 100%);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(96, 0, 16, 0.18);
}

.sg-select-option.sg-selected .sg-select-check {
    color: #ffd700;
    opacity: 1;
}

.sg-select-option.sg-disabled {
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    background: transparent !important;
}

.sg-select-check {
    font-size: 0.78rem;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.sg-select-empty {
    padding: 0.85rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

@media print {
    .sg-select-portal,
    .sg-select-arrow {
        display: none !important;
    }
}
