/* ========================================
   LOCATION MODAL STYLES - BASIC THEME
   Using design tokens from tokens.css
   ======================================== */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base, 0.3s ease);
}

.modal-overlay.show,
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Location Modal Container */
.location-modal {
    background: var(--color-white, #ffffff);
    border-radius: var(--border-radius-lg, 12px);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow: visible;
    /* Allow dropdown to extend outside modal */
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
    transform: scale(0.9) translateY(20px);
    transition: all var(--transition-base, 0.3s ease);
    display: flex;
    flex-direction: column;
}

.modal-overlay.show .location-modal,
.modal-overlay.active .location-modal {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
    padding: var(--spacing-lg, 24px) var(--spacing-lg, 24px) 0;
    position: relative;
    z-index: 1;
    /* Below dropdown */
}

.modal-title {
    font-size: var(--font-size-h3, 20px);
    font-weight: var(--font-weight-bold, 700);
    color: var(--color-text-dark, #1A1A1A);
    margin-bottom: var(--spacing-xs, 8px);
}

.modal-subtitle {
    font-size: var(--font-size-body, 14px);
    color: var(--color-text-light, #4A4A4A);
    line-height: 1.43;
}

.modal-close {
    position: absolute;
    right: var(--spacing-lg, 24px);
    /* Góc phải */
    top: var(--spacing-lg, 24px);
    background: none;
    border: none;
    padding: 0;
    width: 24px;
    /* Icon size only, no holder */
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity var(--transition-base, 0.3s ease);
    z-index: 10;
    /* Above title and subtitle */
}

.modal-close svg {
    width: 24px;
    height: 24px;
    transition: opacity var(--transition-base, 0.3s ease);
}

.modal-close:hover svg {
    opacity: 0.7;
}

/* Modal Content */
.modal-content {
    padding: var(--spacing-lg, 24px) var(--spacing-lg, 24px) 0;
    overflow: visible;
    /* Allow dropdown to extend outside */
    position: relative;
}

/* Modal Actions */
.modal-actions {
    padding: var(--spacing-lg, 24px) var(--spacing-lg, 24px) var(--spacing-lg, 24px);
    position: relative;
    z-index: 1;
    /* Below dropdown */
}

/* ========================================
   CUSTOM DROPDOWN COMPONENT
   ======================================== */

/* Dropdown Container */
.custom-dropdown {
    position: relative;
    width: 100%;
    z-index: 1;
    /* Default z-index */
}

/* When dropdown is open, increase z-index */
.custom-dropdown.open {
    z-index: 10000;
    /* Very high z-index to appear above everything */
    /* Above modal content sections */
}

/* Dropdown Trigger */
.custom-dropdown__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md, 16px);
    padding: 12px var(--spacing-md, 16px);
    border: 1px solid var(--color-border, #E0E0E0);
    border-radius: 12px;
    background: var(--color-white, #FFFFFF);
    cursor: pointer;
    transition: all var(--transition-base, 0.3s ease);
    min-height: 48px;
}

.custom-dropdown__trigger:hover {
    border-color: var(--color-border-hover, #D1D5DB);
}

.custom-dropdown__trigger:focus {
    outline: none;
    border-color: var(--color-primary, #40C706);
    box-shadow: 0 0 0 3px rgba(64, 199, 6, 0.1);
}

.custom-dropdown.open .custom-dropdown__trigger {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
    border-color: var(--color-primary, #40C706);
}

/* Dropdown Value */
.custom-dropdown__value {
    flex: 1;
    color: var(--color-text-dark, #252525);
    font-size: var(--font-size-base, 16px);
    line-height: 1.5;
    user-select: none;
}

.custom-dropdown__value:empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-placeholder, #B0B0B0);
}

/* Dropdown Icon */
.custom-dropdown__icon {
    flex-shrink: 0;
    transition: transform var(--transition-base, 0.3s ease);
    pointer-events: none;
}

.custom-dropdown__trigger:hover .custom-dropdown__icon {
    transform: translateY(2px);
}

.custom-dropdown.open .custom-dropdown__icon {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.custom-dropdown__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white, #FFFFFF);
    border: 1px solid var(--color-primary, #FF2881);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.15));
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-base, 0.3s ease);
    z-index: 1000;
    /* High z-index to appear above all form elements */
    max-height: 0;
    overflow: hidden;
}

.custom-dropdown.open .custom-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: none;
    /* Remove height constraint */
}

/* Search Box */
.custom-dropdown__search {
    position: relative;
    padding: var(--spacing-md, 16px);
    border-bottom: 1px solid var(--color-border, #E5E7EB);
    background: var(--color-white, #FFFFFF);
}

.custom-dropdown__search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

.custom-dropdown__search-input {
    width: 100%;
    padding: 10px var(--spacing-md, 16px) 10px 36px;
    border: 1px solid var(--color-border, #E0E0E0);
    border-radius: var(--border-radius-md, 8px);
    outline: none;
    background: var(--color-white, #ffffff);
    font-size: 15px;
    transition: all var(--transition-base, 0.3s ease);
}

.custom-dropdown__search-input::placeholder {
    color: var(--color-text-placeholder, #B0B0B0);
    font-size: 14px;
}

.custom-dropdown__search-input:focus {
    border-color: var(--color-primary, #40C706);
    box-shadow: 0 0 0 3px rgba(64, 199, 6, 0.1);
}

/* Results List */
.custom-dropdown__list {
    max-height: 240px;
    /* 48px × 5 items */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar */
.custom-dropdown__list::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown__list::-webkit-scrollbar-track {
    background: var(--color-gray-50, #F9FAFB);
}

.custom-dropdown__list::-webkit-scrollbar-thumb {
    background: var(--color-border-hover, #D1D5DB);
    border-radius: 3px;
}

.custom-dropdown__list::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #888888);
}

/* Dropdown Item */
.custom-dropdown__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px var(--spacing-md, 16px);
    min-height: 48px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--color-text-dark, #252525);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #F3F4F6;
    user-select: none;
}

.custom-dropdown__item:last-child {
    border-bottom: none;
}

.custom-dropdown__item:hover {
    background-color: #E8F8E5;
}

.custom-dropdown__item.selected {
    background-color: var(--color-primary, #40C706);
    color: var(--color-white, #ffffff);
    font-weight: var(--font-weight-semibold, 600);
}

.custom-dropdown__item.selected:hover {
    background-color: #34AD00;
}

/* Checkmark Icon */
.custom-dropdown__check {
    flex-shrink: 0;
    margin-left: auto;
}

/* No Results Message */
.custom-dropdown__no-results {
    padding: var(--spacing-md, 16px);
    text-align: center;
    color: var(--color-text-muted, #888888);
    font-size: 14px;
}

/* Confirm Button */
.modal-confirm-btn {
    background: var(--primary-pink);
    color: var(--color-white, #ffffff);
    padding: 12px var(--spacing-lg, 24px);
    height: 48px;
    border-radius: 999px;
    border: none;
    font-size: var(--font-size-base, 16px);
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    transition: all var(--transition-base, 0.3s ease);
    width: 100%;
    margin: 0;
    box-shadow: 0 2px 8px rgba(255, 40, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-confirm-btn:hover:not(:disabled) {
    background: #E61E6E;
    box-shadow: 0 4px 12px rgba(255, 40, 129, 0.3);
    transform: translateY(-1px);
}

.modal-confirm-btn:disabled {
    background: var(--color-gray-400, #9CA3AF);
    cursor: not-allowed;
    box-shadow: none;
}

/* Select2 Styles for Modal */
.modal-overlay .select2-container {
    width: 100% !important;
    z-index: 10001;
}

/* Override any Bootstrap or framework styles */
.location-select-wrapper .select2-container,
.location-select-wrapper .select2-container *,
.location-select-wrapper .select2-container *:before,
.location-select-wrapper .select2-container *:after {
    box-sizing: border-box;
}

.location-select-wrapper .select2-container .select2-selection {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.modal-overlay .select2-container--default .select2-selection--single {
    height: auto !important;
    min-height: 24px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    display: flex;
    align-items: center;
    outline: none !important;
    box-shadow: none !important;
}

.modal-overlay .select2-container--default .select2-selection--single:hover {
    background: transparent !important;
    border: none !important;
}

.modal-overlay .select2-container--default.select2-container--focus .select2-selection--single,
.modal-overlay .select2-container--default.select2-container--open .select2-selection--single {
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    border: none !important;
}

.modal-overlay .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 24px;
    padding: 0;
    padding-right: 0;
    color: var(--color-text-dark, #1A1A1A);
    font-size: var(--font-size-base, 16px);
}

.modal-overlay .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--color-text-placeholder, #B0B0B0);
    font-size: var(--font-size-base, 16px);
}

/* Hide default select2 arrow since we have custom icon */
.modal-overlay .select2-container--default .select2-selection--single .select2-selection__arrow {
    display: none;
}

/* Rotate custom icon when dropdown is open */
.location-select-wrapper.dropdown-open .location-select-icon {
    transform: rotate(180deg);
}

/* Select2 Dropdown */
.custom-location-dropdown.select2-dropdown,
.select2-container--default .select2-dropdown {
    border: 1px solid var(--color-border, #E0E0E0);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
    z-index: 10002 !important;
    margin-top: 0;
    overflow: hidden;
    background: var(--color-white, #FFFFFF);
    margin-top: 0px;
}

/* Dropdown appears below wrapper */
.location-select-wrapper .select2-container--open .select2-dropdown--below {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Search Box Container */
.custom-location-dropdown .select2-search--dropdown,
.select2-container--default .select2-search--dropdown {
    padding: var(--spacing-md, 16px);
    background: var(--color-white, #FFFFFF);
    border-bottom: 1px solid var(--color-border, #E5E7EB);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Search Input Field */
.custom-location-dropdown .select2-search__field,
.select2-container--default .select2-search--dropdown .select2-search__field {
    padding: 10px var(--spacing-md, 16px);
    border: 1px solid var(--color-border, #E0E0E0);
    border-radius: var(--border-radius-md, 8px);
    outline: none;
    background: var(--color-white, #ffffff);
    font-size: 15px;
    width: 100%;
    transition: all var(--transition-base, 0.3s ease);
}

.custom-location-dropdown .select2-search__field:focus,
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--color-secondary, #0077B6);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
}

.custom-location-dropdown .select2-search__field::placeholder,
.select2-container--default .select2-search--dropdown .select2-search__field::placeholder {
    color: var(--color-text-placeholder, #B0B0B0);
    font-size: 14px;
}

/* Results Container - Show max 5 items */
.custom-location-dropdown .select2-results__options,
.select2-container--default .select2-results__options {
    max-height: 240px;
    /* 48px per item × 5 items = 240px */
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar */
.custom-location-dropdown .select2-results__options::-webkit-scrollbar,
.select2-container--default .select2-results__options::-webkit-scrollbar {
    width: 6px;
}

.custom-location-dropdown .select2-results__options::-webkit-scrollbar-track,
.select2-container--default .select2-results__options::-webkit-scrollbar-track {
    background: var(--color-gray-50, #F9FAFB);
}

.custom-location-dropdown .select2-results__options::-webkit-scrollbar-thumb,
.select2-container--default .select2-results__options::-webkit-scrollbar-thumb {
    background: var(--color-border-hover, #D1D5DB);
    border-radius: 3px;
}

.custom-location-dropdown .select2-results__options::-webkit-scrollbar-thumb:hover,
.select2-container--default .select2-results__options::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #888888);
}

/* Dropdown Option Items */
.custom-location-dropdown .select2-results__option,
.select2-container--default .select2-results__option {
    padding: 14px var(--spacing-md, 16px);
    min-height: 48px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--color-text-dark, #252525);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
}

.custom-location-dropdown .select2-results__option:last-child,
.select2-container--default .select2-results__option:last-child {
    border-bottom: none;
}

/* Hover state */
.custom-location-dropdown .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #E6F4F9;
    color: var(--color-text-dark, #252525);
}

/* Selected state */
.custom-location-dropdown .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--primary-pink);
    color: var(--color-white, #ffffff);
    font-weight: var(--font-weight-semibold, 600);
    position: relative;
}

/* Add checkmark to selected item */
.custom-location-dropdown .select2-results__option[aria-selected="true"]::after,
.select2-container--default .select2-results__option[aria-selected="true"]::after {
    content: '✓';
    position: absolute;
    right: var(--spacing-md, 16px);
    font-weight: bold;
}

.custom-location-dropdown .select2-results__option:hover,
.select2-container--default .select2-results__option:hover {
    background-color: var(--color-gray-50, var(--primary-pink));
}

/* No results message */
.custom-location-dropdown .select2-results__message,
.select2-container--default .select2-results__message {
    padding: var(--spacing-md, 16px);
    text-align: center;
    color: var(--color-text-muted, #888888);
    font-size: 14px;
}

/* Ensure dropdown appears above modal overlay */
.select2-dropdown {
    z-index: 10050 !important;
}

.select2-container--open {
    z-index: 10050 !important;
}

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

/* Mobile */
@media (max-width: 768px) {
    .location-select-wrapper {
        padding: 10px var(--spacing-sm, 12px);
        border-radius: 10px;
    }

    .location-select-wrapper.dropdown-open {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .modal-overlay .select2-container--default .select2-selection--single .select2-selection__rendered {
        font-size: 15px;
    }

    .modal-overlay .select2-container--default .select2-selection--single .select2-selection__placeholder {
        font-size: 15px;
    }

    /* Dropdown on mobile */
    .custom-location-dropdown.select2-dropdown,
    .select2-container--default .select2-dropdown {
        border-radius: 0 0 10px 10px;
    }

    /* Search box on mobile */
    .custom-location-dropdown .select2-search--dropdown,
    .select2-container--default .select2-search--dropdown {
        padding: 12px;
    }

    .custom-location-dropdown .select2-search__field,
    .select2-container--default .select2-search--dropdown .select2-search__field {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Results on mobile - show 4 items */
    .custom-location-dropdown .select2-results__options,
    .select2-container--default .select2-results__options {
        max-height: 192px;
        /* 48px × 4 items */
    }

    .custom-location-dropdown .select2-results__option,
    .select2-container--default .select2-results__option {
        padding: 12px;
        min-height: 48px;
        font-size: 14px;
    }

    .location-modal {
        width: 95%;
        max-width: none;
        margin: 0 10px;
        border-radius: var(--border-radius-lg, 12px);
    }

    .location-select-icon {
        width: 18px;
        height: 18px;
    }

    .modal-header {
        padding: var(--spacing-md-mobile, 20px) var(--spacing-md-mobile, 20px) 0;
    }

    .modal-title {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .modal-subtitle {
        font-size: 13px;
        line-height: 1.5;
    }

    .modal-content {
        padding: var(--spacing-md-mobile, 20px) var(--spacing-md-mobile, 20px) 0;
    }

    .modal-actions {
        padding: var(--spacing-md-mobile, 20px) var(--spacing-md-mobile, 20px) var(--spacing-md-mobile, 20px);
    }

    .modal-confirm-btn {
        font-size: 15px;
        padding: 12px var(--spacing-md-mobile, 20px);
        height: 44px;
    }
}

/* Very small mobile */
@media (max-width: 375px) {
    .location-select-wrapper {
        padding: 8px 12px;
        border-radius: 8px;
        gap: 12px;
    }

    .location-select-wrapper.dropdown-open {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .location-select-icon {
        width: 16px;
        height: 16px;
    }

    /* Dropdown on small mobile */
    .custom-location-dropdown.select2-dropdown,
    .select2-container--default .select2-dropdown {
        border-radius: 0 0 8px 8px;
    }

    /* Search box on small mobile */
    .custom-location-dropdown .select2-search--dropdown,
    .select2-container--default .select2-search--dropdown {
        padding: 10px;
    }

    .custom-location-dropdown .select2-search__field,
    .select2-container--default .select2-search--dropdown .select2-search__field {
        padding: 8px 10px;
        font-size: 13px;
    }

    /* Results on small mobile - show 3 items */
    .custom-location-dropdown .select2-results__options,
    .select2-container--default .select2-results__options {
        max-height: 144px;
        /* 48px × 3 items */
    }

    .custom-location-dropdown .select2-results__option,
    .select2-container--default .select2-results__option {
        padding: 10px;
        min-height: 48px;
        font-size: 13px;
    }

    .modal-header {
        padding: var(--spacing-sm, 16px) var(--spacing-sm, 16px) 0;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-subtitle {
        font-size: 12px;
    }

    .modal-content {
        padding: var(--spacing-sm, 16px) var(--spacing-sm, 16px) 0;
    }

    .modal-actions {
        padding: var(--spacing-sm, 16px) var(--spacing-sm, 16px) var(--spacing-sm, 16px);
    }

    .modal-confirm-btn {
        font-size: 14px;
        padding: 10px var(--spacing-sm, 16px);
        height: 40px;
    }

    .modal-close {
        top: var(--spacing-sm, 16px);
        right: var(--spacing-sm, 16px);
        /* Góc phải */
        width: 20px;
        /* Icon size only, no holder */
        height: 20px;
    }

    .modal-close svg {
        width: 20px;
        height: 20px;
    }
}

/* custom màu hồng cho dropdown select2 .theme_news_popup  */
.theme_news_popup #select2-location_province-results .select2-results__option--highlighted[aria-selected],
.theme_news_popup #select2-location_district-results .select2-results__option--highlighted[aria-selected],
.theme_news_popup #select2-location_ward-results .select2-results__option--highlighted[aria-selected] {
    /* background: #f1f1f1; */
    background: #FF2981;
    color: #000;
    border-radius: 0;
}
.theme_news_popup .select2-selection.select2-selection--single{
    outline: none;
}
.theme_news_popup #locationForm .select2-container.select2-container--default.select2-container--open {
    top: 99px !important;
}

.theme_news_popup.location-popup .select2-container--default .select2-selection--single {
    border: 1px solid #FF2981;
}
.theme_news_popup.location-popup .location-popup form button[type=submit], .location-popup form button.btn-submit {
    border-radius: 40px;
    background: #FF2981;
    margin-top: 22px;
    padding: 0 24px;
    line-height: 48px;
}
.theme_news_popup .custom-location-dropdown .select2-search__field:focus,
.theme_news_popup .select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--color-secondary, #FF2981);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
}

.theme_news_popup .select2-container:has(#select2-location_province-results) .select2-results{
    padding-top: 2px;
}
