/**
 * 後台管理 - Modal 和 Toast 樣式
 * Admin Modal & Toast Styles
 * 黑金/白金主題 (Black-Gold / White-Gold Theme)
 */

/* ==================== Modal ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    /* 防止滾動穿透 */
    overscroll-behavior: contain;
    will-change: opacity, visibility;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

/* 確認彈窗需浮在其他 modal 之上（例如從 GlobalConfig 編輯視窗開啟時） */
#confirmModal {
    z-index: 2100;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    /* 防止觸控事件穿透 */
    touch-action: none;
}

.modal-content {
    position: relative;
    background-color: var(--admin-bg-elevated);
    border: 1px solid rgba(212, 165, 32, 0.1);
    border-radius: 0.75rem;
    width: 90%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(12px);
    transition: transform 0.2s ease;
    /* 防止滾動穿透到背景 */
    overscroll-behavior: contain;
    will-change: transform;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-sm .modal-content,
.modal-content.modal-sm {
    max-width: 24rem;
}

.modal-lg .modal-content,
.modal-content.modal-lg {
    max-width: 40rem;
}

.modal-xl .modal-content,
.modal-content.modal-xl {
    max-width: 60rem;
}

.modal-game .modal-content,
.modal-content.modal-game {
    max-width: 32rem;
}

.light-theme .modal-content {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.99) 0%, rgba(255, 253, 248, 1) 100%);
    border: 1px solid rgba(184, 134, 11, 0.12);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(212, 165, 32, 0.1);
}

.light-theme .modal-header {
    border-bottom-color: rgba(184, 134, 11, 0.12);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #ff6b6b;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(212, 165, 32, 0.1);
}

.modal-footer-with-delete {
    justify-content: space-between;
}

.modal-footer-right {
    display: flex;
    gap: 0.75rem;
}

.light-theme .modal-footer {
    border-top-color: rgba(184, 134, 11, 0.12);
}

/* ==================== Confirm Modal 強化版 ==================== */
.modal-confirm .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.125rem;
    padding: 1.5rem 1.5rem 1.25rem;
}

.modal-confirm .confirm-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.06));
    border: 1px solid rgba(245, 158, 11, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.light-theme .modal-confirm .confirm-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.08));
    border-color: rgba(245, 158, 11, 0.45);
    color: #b45309;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.modal-confirm .confirm-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    text-align: center;
}

.modal-confirm .confirm-text {
    margin: 0;
    color: #d1d5db;
    font-size: 0.9375rem;
    line-height: 1.55;
}

.light-theme .modal-confirm .confirm-text {
    color: #4b5563;
}

.modal-confirm .confirm-question {
    margin: 0;
    color: #f3f4f6;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.5;
}

.light-theme .modal-confirm .confirm-question {
    color: #1f2937;
}

.modal-confirm .confirm-info-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: rgba(212, 165, 32, 0.06);
    border: 1px solid rgba(212, 165, 32, 0.18);
    border-radius: 0.5rem;
    text-align: left;
}

.light-theme .modal-confirm .confirm-info-list {
    background: rgba(212, 165, 32, 0.08);
    border-color: rgba(212, 165, 32, 0.28);
}

.modal-confirm .confirm-info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.modal-confirm .confirm-info-label {
    color: #9ca3af;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.light-theme .modal-confirm .confirm-info-label {
    color: #6b7280;
}

.modal-confirm .confirm-info-value {
    color: #f5c542;
    font-weight: 600;
    font-family: 'SF Mono', 'Consolas', monospace;
    letter-spacing: 0.025em;
    text-align: right;
    word-break: break-all;
}

.light-theme .modal-confirm .confirm-info-value {
    color: #8b6914;
}

/* ==================== 版本變更清單（一鍵設置最新） ==================== */
/* 內容較寬，加大確認彈窗寬度以容納單行排列 */
#confirmModal .modal-content:has(.confirm-version-list) {
    max-width: 32rem;
}

.modal-confirm .confirm-version-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 42vh;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0.5rem;
    background: rgba(212, 165, 32, 0.06);
    border: 1px solid rgba(212, 165, 32, 0.18);
    border-radius: 0.5rem;
    text-align: left;
}

.light-theme .modal-confirm .confirm-version-list {
    background: rgba(212, 165, 32, 0.08);
    border-color: rgba(212, 165, 32, 0.28);
}

/* 單行排列：顯示名稱 (專案代碼) 舊版本 → 新版本（整行置中，X 靠右） */
.modal-confirm .confirm-version-item {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 2rem;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.875rem;
    white-space: nowrap;
}

.light-theme .modal-confirm .confirm-version-item {
    background: rgba(0, 0, 0, 0.03);
}

.modal-confirm .confirm-version-name {
    font-weight: 600;
    color: #e5e7eb;
}

.light-theme .modal-confirm .confirm-version-name {
    color: #374151;
}

.modal-confirm .confirm-version-code {
    font-size: 0.75rem;
    font-weight: 400;
    color: #9ca3af;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.light-theme .modal-confirm .confirm-version-code {
    color: #6b7280;
}

.modal-confirm .confirm-version-old {
    color: #9ca3af;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8125rem;
    text-decoration: line-through;
    text-decoration-color: rgba(156, 163, 175, 0.5);
}

.modal-confirm .confirm-version-arrow {
    color: #d4a520;
    font-size: 0.6875rem;
    flex-shrink: 0;
}

.modal-confirm .confirm-version-new {
    color: #f5c542;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8125rem;
}

.light-theme .modal-confirm .confirm-version-new {
    color: #8b6914;
}

.modal-confirm .confirm-version-remove {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: #9ca3af;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-confirm .confirm-version-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.modal-confirm .confirm-note {
    margin: 0;
    font-size: 0.8125rem;
    color: #9ca3af;
}

.light-theme .modal-confirm .confirm-note {
    color: #6b7280;
}

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background-color: #1e1e1e;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    min-width: 16rem;
}

.toast.show {
    transform: translateX(0);
}

.light-theme .toast {
    background-color: #fff;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.toast i {
    font-size: 1.125rem;
}

.toast-success i {
    color: #4caf50;
}

.toast-error i {
    color: #ff6b6b;
}

.toast-warning i {
    color: #ff9800;
}

.toast-info i {
    color: var(--admin-primary);
}

/* ==================== CDN 設定 Modal 專用樣式 ==================== */
.cdn-config-modal {
    max-width: 36rem;
    border: 1px solid rgba(212, 165, 32, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(212, 165, 32, 0.1);
}

.light-theme .cdn-config-modal {
    border-color: rgba(212, 165, 32, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(212, 165, 32, 0.2);
}

/* Modal Header */
.cdn-modal-header {
    background: linear-gradient(135deg, rgba(212, 165, 32, 0.1) 0%, rgba(184, 134, 11, 0.05) 100%);
    border-bottom: 1px solid rgba(212, 165, 32, 0.2) !important;
    padding: 1.25rem 1.5rem !important;
}

.light-theme .cdn-modal-header {
    background: linear-gradient(135deg, rgba(212, 165, 32, 0.08) 0%, rgba(184, 134, 11, 0.03) 100%);
}

.cdn-modal-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cdn-modal-icon {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, #f6821f 0%, #faad3f 100%);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(246, 130, 31, 0.3);
}

.cdn-modal-title-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.cdn-modal-title-text h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.cdn-modal-subtitle {
    font-size: 0.75rem;
    color: #888;
}

.light-theme .cdn-modal-subtitle {
    color: #666;
}

/* Modal Body */
.cdn-modal-body {
    padding: 1rem 1.5rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
}

/* Form Sections */
.cdn-form-section {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    overflow: hidden;
    flex-shrink: 0;
}

/* Fallback spacing for browsers that don't support gap */
.cdn-form-section:not(:last-child) {
    margin-bottom: 1rem;
}

@supports (gap: 1rem) {
    .cdn-form-section:not(:last-child) {
        margin-bottom: 0;
    }
}

.light-theme .cdn-form-section {
    background-color: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

.cdn-form-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: rgba(212, 165, 32, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8125rem;
    font-weight: 600;
    color: #d4a520;
}

.light-theme .cdn-form-section-header {
    background-color: rgba(212, 165, 32, 0.1);
    border-bottom-color: rgba(0, 0, 0, 0.06);
    color: #8b6914;
}

.cdn-form-section-header i {
    font-size: 0.875rem;
}

.cdn-form-section-badge {
    margin-left: auto;
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.125rem 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    color: #888;
}

.light-theme .cdn-form-section-badge {
    background-color: rgba(0, 0, 0, 0.08);
    color: #666;
}

.cdn-form-section-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* CDN Form Row - Two columns */
.cdn-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Form Group enhancements for CDN modal */
.cdn-modal-body .form-group {
    gap: 0.5rem;
}

.cdn-modal-body .form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #d1d5db;
}

.light-theme .cdn-modal-body .form-group label {
    color: #374151;
}

.cdn-modal-body .form-group label i {
    font-size: 0.75rem;
    color: #9ca3af;
}

.light-theme .cdn-modal-body .form-group label i {
    color: #6b7280;
}

.cdn-modal-body .form-input {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.light-theme .cdn-modal-body .form-input {
    background-color: #fff;
    border-color: #e5e7eb;
}

.cdn-modal-body .form-input:focus {
    border-color: #d4a520;
    box-shadow: 0 0 0 3px rgba(212, 165, 32, 0.15);
}

.cdn-modal-body .form-input::placeholder {
    color: #6b7280;
}

.form-input-mono {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8125rem !important;
    letter-spacing: 0.025em;
}

.cdn-modal-body .form-hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: #6b7280;
    padding-left: 0.25rem;
}

.cdn-modal-body .form-hint i {
    font-size: 0.625rem;
    color: #f59e0b;
}

/* Input with toggle (password visibility) */
.cdn-modal-body .input-with-toggle {
    position: relative;
    display: flex;
}

.cdn-modal-body .input-with-toggle .form-input {
    flex: 1;
    padding-right: 3rem;
}

.cdn-modal-body .toggle-visibility {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.cdn-modal-body .toggle-visibility:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #d4a520;
}

.light-theme .cdn-modal-body .toggle-visibility:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Modal Footer */
.cdn-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem !important;
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    gap: 1rem;
}

.light-theme .cdn-modal-footer {
    background-color: rgba(0, 0, 0, 0.03);
    border-top-color: #e5e7eb !important;
}

.cdn-modal-footer-right {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

/* Button with icon */
.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cdn-modal-footer .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    font-weight: 500;
}

.cdn-modal-footer .btn-primary {
    background: linear-gradient(135deg, #d4a520 0%, #b8860b 100%) !important;
    border: none !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(212, 165, 32, 0.3);
}

.cdn-modal-footer .btn-primary:hover {
    background: linear-gradient(135deg, #f5c542 0%, #d4a520 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(212, 165, 32, 0.4);
}

.cdn-modal-footer .btn-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #d1d5db !important;
    box-shadow: none !important;
}

.light-theme .cdn-modal-footer .btn-secondary {
    background: #f3f4f6 !important;
    border-color: #e5e7eb !important;
    color: #374151 !important;
}

.cdn-modal-footer .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: none !important;
}

.light-theme .cdn-modal-footer .btn-secondary:hover {
    background: #e5e7eb !important;
}

#cdnConfigModal .cdn-modal-footer .btn.btn-danger,
.cdn-config-modal .cdn-modal-footer .btn.btn-danger,
.cdn-modal-footer .btn.btn-danger {
    background: rgba(239, 68, 68, 0.12) !important;
    background-image: none !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: #f87171 !important;
    box-shadow: none !important;
    flex-shrink: 0;
}

#cdnConfigModal .cdn-modal-footer .btn.btn-danger:hover,
.cdn-config-modal .cdn-modal-footer .btn.btn-danger:hover,
.cdn-modal-footer .btn.btn-danger:hover {
    background: rgba(239, 68, 68, 0.22) !important;
    background-image: none !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
    transform: none !important;
}

.light-theme #cdnConfigModal .cdn-modal-footer .btn.btn-danger,
.light-theme .cdn-config-modal .cdn-modal-footer .btn.btn-danger,
.light-theme .cdn-modal-footer .btn.btn-danger {
    background: rgba(239, 68, 68, 0.08) !important;
    background-image: none !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
    color: #dc2626 !important;
}

.light-theme #cdnConfigModal .cdn-modal-footer .btn.btn-danger:hover,
.light-theme .cdn-config-modal .cdn-modal-footer .btn.btn-danger:hover,
.light-theme .cdn-modal-footer .btn.btn-danger:hover {
    background: rgba(239, 68, 68, 0.18) !important;
    background-image: none !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

/* ==================== Modal 內的 Select 下拉選單樣式 ==================== */
.modal-body select.form-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-body select.form-input:hover {
    border-color: #d4a520;
}

.modal-body select.form-input:focus {
    border-color: #d4a520;
    box-shadow: 0 0 0 3px rgba(212, 165, 32, 0.15);
}

/* 淺色主題 */
.light-theme .modal-body select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* Select 選項樣式（針對 option 元素） */
.modal-body select.form-input option {
    padding: 0.625rem 0.75rem;
    background-color: #1e1e1e;
    color: #fff;
}

.modal-body select.form-input option:hover,
.modal-body select.form-input option:focus,
.modal-body select.form-input option:checked {
    background: linear-gradient(135deg, #d4a520 0%, #b8860b 100%);
    color: #fff;
}

.light-theme .modal-body select.form-input option {
    background-color: #fff;
    color: #333;
}

.light-theme .modal-body select.form-input option:checked {
    background: linear-gradient(135deg, #d4a520 0%, #b8860b 100%);
    color: #fff;
}

/* 限制下拉選單的最大高度 */
@supports (-webkit-appearance: none) or (-moz-appearance: none) {
    .modal-body select.form-input {
        max-height: 2.75rem;
    }
}

/* ==================== 自定義下拉選單組件 ==================== */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 2.75rem;
}

.custom-select-trigger:hover {
    border-color: #d4a520;
}

.custom-select.open .custom-select-trigger {
    border-color: #d4a520;
    box-shadow: 0 0 0 3px rgba(212, 165, 32, 0.15);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger .selected-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-trigger .selected-text.placeholder {
    color: #888;
}

.custom-select-trigger .arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #888;
    transition: transform 0.2s ease;
    margin-left: 0.75rem;
    flex-shrink: 0;
}

.custom-select.open .custom-select-trigger .arrow {
    transform: rotate(180deg);
    border-top-color: #d4a520;
}

/* 全域下拉容器 */
.custom-select-dropdown-container {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999;
    pointer-events: none;
}

.custom-select-dropdown-container .custom-select-options {
    pointer-events: auto;
}

.custom-select-options {
    background-color: #1e1e1e;
    border: 1px solid #d4a520;
    border-radius: 0 0 0.5rem 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.custom-select-options.show {
    display: block;
}

/* 下拉內搜尋框 */
.custom-select-search {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.5rem;
    background-color: #1e1e1e;
    border-bottom: 1px solid rgba(212, 165, 32, 0.25);
}

.custom-select-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.7rem;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 0.375rem;
    color: #f3f4f6;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.custom-select-search-input::placeholder {
    color: #777;
}

.custom-select-search-input:focus {
    border-color: #d4a520;
}

.custom-select-empty {
    padding: 1rem 0.875rem;
    color: #888;
    font-size: 0.875rem;
    text-align: center;
    font-style: italic;
}

.light-theme .custom-select-search {
    background-color: #fff;
    border-bottom-color: rgba(212, 165, 32, 0.3);
}

.light-theme .custom-select-search-input {
    background-color: #f5f5f5;
    border-color: #d1d5db;
    color: #1f2937;
}

.light-theme .custom-select-search-input::placeholder {
    color: #9ca3af;
}

.light-theme .custom-select-empty {
    color: #9ca3af;
}

.custom-select-option {
    padding: 0.625rem 0.875rem;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.875rem;
}

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

.custom-select-option:hover {
    background-color: rgba(212, 165, 32, 0.15);
    color: #fff;
}

.custom-select-option.selected {
    background: linear-gradient(135deg, rgba(212, 165, 32, 0.25) 0%, rgba(184, 134, 11, 0.2) 100%);
    color: #d4a520;
    font-weight: 500;
}

.custom-select-option.disabled {
    color: #666;
    cursor: not-allowed;
    font-style: italic;
}

.custom-select-option.disabled:hover {
    background-color: transparent;
    color: #666;
}

/* 選項中的遊戲資訊顯示 */
.custom-select-option .option-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-select-option .custom-select-option-icon,
.custom-select-option .custom-select-option-icon-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
    background-color: rgba(255, 255, 255, 0.06);
}

.custom-select-option .custom-select-option-icon-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 0.75rem;
}

.custom-select-option .option-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-option .option-code {
    color: #888;
    font-size: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    flex-shrink: 0;
}

/* 自定義捲軸 */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 0 0.5rem 0;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 32, 0.4);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 165, 32, 0.6);
}

/* 淺色主題 */
.light-theme .custom-select-trigger {
    background-color: #fff;
    border-color: #e5e7eb;
    color: #333;
}

.light-theme .custom-select-trigger:hover {
    border-color: #d4a520;
}

.light-theme .custom-select.open .custom-select-trigger {
    border-color: #d4a520;
    box-shadow: 0 0 0 3px rgba(212, 165, 32, 0.1);
}

.light-theme .custom-select-trigger .selected-text.placeholder {
    color: #9ca3af;
}

.light-theme .custom-select-trigger .arrow {
    border-top-color: #9ca3af;
}

.light-theme .custom-select.open .custom-select-trigger .arrow {
    border-top-color: #d4a520;
}

.light-theme .custom-select-options {
    background-color: #fff;
    border-color: #d4a520;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.light-theme .custom-select-option {
    color: #374151;
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

.light-theme .custom-select-option:hover {
    background-color: rgba(212, 165, 32, 0.1);
    color: #1f2937;
}

.light-theme .custom-select-option.selected {
    background: linear-gradient(135deg, rgba(212, 165, 32, 0.15) 0%, rgba(184, 134, 11, 0.1) 100%);
    color: #8b6914;
}

.light-theme .custom-select-option.disabled {
    color: #9ca3af;
}

.light-theme .custom-select-option .option-code {
    color: #6b7280;
}

.light-theme .custom-select-option .custom-select-option-icon,
.light-theme .custom-select-option .custom-select-option-icon-placeholder {
    background-color: rgba(0, 0, 0, 0.05);
}

.light-theme .custom-select-option .custom-select-option-icon-placeholder {
    color: #9ca3af;
}

.light-theme .custom-select-options::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

.light-theme .custom-select-options::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 32, 0.3);
}

.light-theme .custom-select-options::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 165, 32, 0.5);
}

/* 隱藏原生 select 和 wrapper 內的 options */
.custom-select select,
.custom-select > .custom-select-options {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 100%;
    height: 0;
    overflow: hidden;
}

/* ===== 手機版排序按鈕與選單 (共用元件 - 使用者/角色/環境頁面) ===== */
.mobile-sort-btn {
    display: none;
}

.mobile-sort-menu {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e1e1e;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-sort-menu.show {
    display: block;
    transform: translateY(0);
}

.light-theme .mobile-sort-menu {
    background: #fff;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
}

.sort-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 600;
    font-size: 0.9375rem;
}

.light-theme .sort-menu-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.sort-menu-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
}

.sort-menu-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.light-theme .sort-menu-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sort-menu-options {
    padding: 0.5rem 0;
    max-height: 60vh;
    overflow-y: auto;
}

.sort-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sort-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.light-theme .sort-option:hover {
    background: rgba(0, 0, 0, 0.03);
}

.sort-option i:first-child {
    width: 1.25rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sort-option .check-icon {
    margin-left: auto;
    color: #d4a520;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.sort-option.active {
    background: rgba(212, 165, 32, 0.08);
}

.sort-option.active .check-icon {
    opacity: 1;
}

.sort-option.active i:first-child {
    color: #d4a520;
}

/* 排序選單遮罩 */
.sort-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sort-menu-overlay.show {
    display: block;
    opacity: 1;
}

/* ==================== 遊戲新增 - 模式切換 Tab ==================== */
.game-create-mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
    border-radius: 8px;
}

.game-create-mode-tabs .mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary, #999);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-create-mode-tabs .mode-tab:hover {
    color: var(--text-primary, #fff);
    background: rgba(255, 255, 255, 0.04);
}

.game-create-mode-tabs .mode-tab.active {
    background: var(--brand-gold, #d4af37);
    color: #000;
}

/* ==================== 匯入區塊 ==================== */
.game-import-section .game-import-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.game-import-section .search-input-wrapper {
    flex: 1;
    position: relative;
}

.game-import-section .search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #999);
    pointer-events: none;
}

.game-import-section .search-input-wrapper input {
    padding-left: 36px;
}

.game-import-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.2));
}

.game-import-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.game-import-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.game-import-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--brand-gold, #d4af37);
}

.game-import-item .checkmark {
    display: none;
}

.game-import-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.04);
}

.game-import-info {
    flex: 1;
    min-width: 0;
}

.game-import-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-import-meta {
    font-size: 12px;
    color: var(--text-secondary, #999);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-import-hint {
    font-size: 12px;
    color: var(--text-secondary, #999);
    margin: 8px 0 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-import-hint i {
    color: var(--brand-gold, #d4af37);
}

.game-import-list .empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary, #999);
}

.game-import-list .empty-state.error {
    color: #e57373;
}

.game-import-list .empty-state i {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

/* ==================== 同步建立區塊 ==================== */
.game-sync-section {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px dashed var(--border-color, rgba(212, 175, 55, 0.3));
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.04);
}

.game-sync-brands {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-top: 8px;
}

.game-sync-brands .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.game-sync-hint {
    font-size: 12px;
    color: var(--text-secondary, #999);
    margin: 10px 0 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-sync-hint i {
    color: var(--brand-gold, #d4af37);
}
