:root {
    --bg-color: #0f0f13;
    --text-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.05);
    --primary-color: #007bff;
}

[data-theme="light"] {
    --bg-color: #d9d9d9; /* 从 #f0f2f5 调暗一点，更偏向护眼的浅灰色 */
    --text-color: #1a1a1a;
    --card-bg: rgba(0, 0, 0, 0.05);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
html {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #00c6ff, #0072ff);
    z-index: 9999;
    transition: width 0.1s;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.model-toggle {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.eye-tracking-toggle {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.model-toggle:hover,
.eye-tracking-toggle:hover,
.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Ensure modal is hidden by default but can be shown */
.modal-overlay[style*="display: none"] {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(20, 20, 30, 0.9);
    backdrop-filter: blur(20px);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

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

/* Special handling for create modal which uses flex display directly */
#createModelModal[style*="display: flex"] .modal-content {
    opacity: 1;
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    opacity: 1;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.option-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.option-card.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.option-icon {
    font-size: 24px;
}

.option-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.modal-footer {
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
}

.primary-btn {
    background: white;
    color: black;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Creation Modal Styles */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab {
    padding: 10px 15px;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.6;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab.active {
    opacity: 1;
    border-bottom-color: white;
    font-weight: 500;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
}

.input-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.input-group textarea:focus {
    border-color: rgba(255, 255, 255, 0.3);
    outline: none;
}

.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-area:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.upload-icon {
    font-size: 24px;
}

.upload-text {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
}

#imagePreview {
    margin-top: 15px;
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
}

#imagePreview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#removeImageBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.creation-status {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.8);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Avatar Options & Carousel */
.carousel-item {
    position: absolute;
    width: 600px;
    height: 800px;
    left: 50%;
    top: 0;
    margin-left: -300px; /* center it horizontally */
    transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), filter 0.8s ease;
    pointer-events: auto; /* 允许内部元素交互 */
}
.carousel-item:not(.active) {
    filter: brightness(0.6) drop-shadow(0 0 10px rgba(0,0,0,0.5));
    cursor: pointer;
}

[data-theme="light"] .carousel-item:not(.active) {
    filter: brightness(0.8); /* 白天模式下只变暗一点，去掉阴影 */
}

.carousel-item.active {
    filter: brightness(1);
}

/* Avatar Tag Styles */
.avatar-tag {
    position: absolute;
    top: 40px; /* 距离模型容器顶部 40px，作为统一默认值 */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    white-space: nowrap;
    z-index: 20;
    pointer-events: none; /* 让鼠标点击穿透 tag */
    text-shadow: 0 1px 4px rgba(0,0,0,0.8); /* 简单的文字阴影保证在复杂背景下也能看清 */
}

[data-theme="light"] .avatar-tag {
    color: #000;
    text-shadow: none; /* 白天模式去掉文字阴影 */
}

.avatar-name {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .avatar-name {
    color: rgba(0, 0, 0, 0.9); /* 白天模式名字用深黑色 */
}

.avatar-status {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.avatar-status.active-status {
    color: rgba(255, 255, 255, 0.5); /* 浅灰色表示在职 */
}

[data-theme="light"] .avatar-status.active-status {
    color: rgba(0, 0, 0, 0.5); /* 白天模式在职状态用灰色 */
}

.avatar-status.inactive-status {
    color: rgba(255, 255, 255, 0.3); /* 更暗的灰色表示离职 */
}

[data-theme="light"] .avatar-status.inactive-status {
    color: rgba(0, 0, 0, 0.3); /* 白天模式离职状态用浅灰色 */
}

/* Breathing animation for input focus using only black, white, and gray */
@keyframes breathe-monochrome {
    0% {
        box-shadow: 0 0 5px rgba(200, 200, 200, 0.2);
        border-color: rgba(200, 200, 200, 0.4);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 20px rgba(150, 150, 150, 0.4);
        border-color: rgba(255, 255, 255, 1);
    }
    100% {
        box-shadow: 0 0 5px rgba(200, 200, 200, 0.2);
        border-color: rgba(200, 200, 200, 0.4);
    }
}

#talkinghead-text:focus {
    outline: none !important;
    animation: breathe-monochrome 2s ease-in-out infinite;
}

/* 白天模式下输入框适配 */
[data-theme="light"] #talkinghead-text {
    background: rgba(255, 255, 255, 0.7) !important;
    color: #333 !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] #talkinghead-text::placeholder {
    color: rgba(0, 0, 0, 0.4) !important;
}

[data-theme="light"] #talkinghead-loading {
    color: #333 !important;
}
