/* 设置弹窗样式 - Dark Glass */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal.hidden {
    display: none;
}

.settings-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.settings-modal:not(.closing) .settings-backdrop {
    animation: settingsBackdropIn .38s ease forwards;
}

.settings-modal.closing .settings-backdrop {
    animation: settingsBackdropOut .28s ease forwards;
}

@keyframes settingsBackdropIn {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }

    100% {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes settingsBackdropOut {
    0% {
        opacity: 1;
        backdrop-filter: blur(8px);
    }

    100% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
}

.settings-dialog {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: rgba(30, 35, 45, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    overflow: hidden;
    animation: settingsIn .38s cubic-bezier(.22, .85, .3, 1) both;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.settings-modal.closing .settings-dialog {
    animation: settingsOut .28s cubic-bezier(.4, .15, .3, 1) forwards;
}

@keyframes settingsIn {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(.94);
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes settingsOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(18px) scale(.94);
    }
}

.settings-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: #f1f5f9;
}

.settings-close {
    position: absolute;
    right: 24px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: all 0.2s;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close:hover {
    color: #ef4444;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.settings-body {
    padding: 24px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.settings-body::-webkit-scrollbar {
    display: none;
}

/* Settings Items */
.settings-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.settings-info {
    flex: 1;
    padding-right: 16px;
}

.settings-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: #f1f5f9;
}

.settings-desc {
    font-size: 0.85rem;
    color: #94a3b8;
}

.settings-action {
    flex-shrink: 0;
}

/* Buttons in Settings */
.settings-action .btn {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn.danger {
    background: rgba(220, 38, 38, 0.25);
    border-color: rgba(248, 113, 113, 0.4);
    color: #fee2e2;
}

.btn.danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.4);
    border-color: rgba(248, 113, 113, 0.6);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.3);
}

/* Shortcut Inputs */
.shortcut-input,
.room-code-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #38bdf8;
    padding: 8px 12px;
    width: 140px;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.room-code-input {
    cursor: text;
}

.shortcut-input:focus,
.room-code-input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    background: rgba(0, 0, 0, 0.5);
}

.shortcut-input.conflict {
    border-color: rgba(239, 68, 68, 0.6);
    color: #ef4444;
    background: rgba(127, 29, 29, 0.1);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.conflict-msg {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 6px;
    text-align: center;
    display: none;
}

.shortcut-input.conflict+.conflict-msg {
    display: block;
}

/* 设置按钮（右上角图标） */
#settingsBtn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.2s, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    width: 40px;
    height: 40px;
}

#settingsBtn:hover {
    color: #f8fafc;
    transform: rotate(45deg);
}

#settingsBtn svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: #e2e8f0;
    transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: rgba(56, 189, 248, 0.3);
    border-color: rgba(56, 189, 248, 0.5);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Mobile Adaptation */
@media (max-width: 640px) {
    .settings-dialog {
        width: 95%;
        max-height: 90vh;
    }

    .settings-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .settings-action {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .shortcut-input {
        width: 100%;
    }
}

/* Loading Spinner for Online Status */
.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    font-family: Arial, sans-serif;
    margin-right: 4px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Toast Notification Styles */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
    padding: 10px 20px;
    border-radius: 99px;
    font-size: 0.9rem;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Light Mode Adjustment for Toast */
body.light-theme .toast-notification {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Viewer Loader Overlay */
.viewer-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #32323288;
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    /* transition: opacity 0.3s ease; is handled by hidden class toggling usually but let's keep it simple */
}

.viewer-loader.hidden {
    display: none !important;
}

.loader-content {
    text-align: center;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

#loaderText {
    font-size: 1.1rem;
    font-weight: 500;
    color: #94a3b8;
    margin: 0;
}

/* Light Mode Adapter for Loader */
body.light-theme .viewer-loader {
    background: #fff9f0b0;
}

body.light-theme .loader-content {
    color: #475569;
}

body.light-theme .spinner-large {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #2563eb;
}