/* =============================================
    应用全局样式
    用于 index.html 中的 HTML DOM 元素
    组件内部样式已通过 shadow DOM 隔离
    ============================================= */

/* =============================================
    1. 基础样式（Base Styles）
    ============================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none;
}

/* =============================================
    2. 布局样式（Layout Styles）
    ============================================= */

.container {
    width: 100%;
    background: #f8f9fa;
    min-height: 100vh;
    padding-top: 60px;
    box-sizing: border-box;
}

header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    height: 60px;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

h1 {
    font-size: 1.5em;
    font-weight: normal;
    cursor: pointer;
    transition: color 0.3s ease;
}

#appTitleText:hover {
    color: #3498db;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.header-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-icon,
.stats-icon {
    font-size: 0.8em;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.85;
}

.info-icon:hover,
.stats-icon:hover {
    opacity: 1;
}

/* =============================================
    3. 用户菜单样式（User Menu Styles）
    ============================================= */

.user-status {
    display: flex;
    align-items: center;
}

.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    padding: 6px 12px;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.user-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

img.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.3s ease;
}

.user-btn:hover img.user-avatar {
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.user-name {
    font-weight: 500;
}

.dropdown-arrow {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.user-btn:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1001;
    display: none;
    margin-top: 5px;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
    animation: dropdownSlideIn 0.2s ease-out;
}

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

.user-info {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.user-email {
    font-size: 0.85em;
    color: #6c757d;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
    color: #2c3e50;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.user-menu-item:hover {
    background: #f8f9fa;
}

.user-menu-item.logout-btn {
    color: #e74c3c;
}

.user-menu-item.logout-btn:hover {
    background: #fdf2f2;
}

.user-menu-divider {
    height: 1px;
    background: #e9ecef;
}

/* =============================================
    4. 认证按钮样式（Auth Button Styles）
    ============================================= */

.auth-buttons {
    display: flex;
    gap: 8px;
}

.login-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.login-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =============================================
    5. 浮动按钮样式（Floating Button Styles）
    ============================================= */

.floating-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1002;
    display: flex;
    gap: 10px;
}

.floating-btn {
    background: rgba(200, 200, 200, 0.15);
    color: #666;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    opacity: 0.6;
    white-space: nowrap;
}

.floating-btn:hover {
    background: rgba(200, 200, 200, 0.25);
    color: #555;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    opacity: 0.9;
}

/* =============================================
    6. 模态框样式（Modal Styles）
    ============================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.modal-content {
    background: white;
    margin: 60px auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    overflow-y: auto;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 10px 0;
}

.modal-content-md {
    max-width: 520px;
}

.modal-content-lg {
    max-width: 900px;
}

.stats-modal-content {
    max-width: 800px;
    max-height: 92vh;
    background: white;
}

/* =============================================
    7. 表单样式（Form Styles）
    ============================================= */

.auth-form {
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: #6c757d;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

.forgot-password-btn {
    background: none;
    border: none;
    color: #3498db;
    font-size: 0.85em;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.forgot-password-btn:hover {
    color: #2980b9;
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.auth-submit-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

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

.auth-divider {
    position: relative;
    text-align: center;
    margin: 20px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e9ecef;
}

.auth-divider span {
    background: white;
    padding: 0 15px;
    color: #6c757d;
    font-size: 0.9em;
}

.auth-footer {
    text-align: center;
}

.auth-footer p {
    margin-bottom: 10px;
    color: #6c757d;
    font-size: 0.9em;
}

.auth-switch-btn {
    background: none;
    border: 1px solid #3498db;
    color: #3498db;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-switch-btn:hover {
    background: #3498db;
    color: white;
}

.auth-info {
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.4;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-buttons .save-btn {
    flex: 1;
    margin-top: 0;
}

.form-buttons .header-btn {
    flex: 1;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

.form-buttons .header-btn:hover {
    background: #7f8c8d;
}

.save-btn {
    width: 100%;
    padding: 10px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
    transition: background 0.3s ease;
}

.save-btn:hover {
    background: #219653;
}

.auth-cancel-btn {
    flex: 1;
    padding: 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-cancel-btn:hover {
    background: #5a6268;
}

.modal .form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal .auth-cancel-btn {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    flex: 1;
}

.modal .auth-cancel-btn:hover {
    background: #7f8c8d;
}

.modal .auth-submit-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    flex: 1;
}

.modal .auth-submit-btn:hover {
    background: #2980b9;
}

/* =============================================
    8. 个人资料样式（Profile Styles）
    ============================================= */

.profile-avatar {
    text-align: center;
    margin-bottom: 20px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    border: 3px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.avatar-upload-label {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.avatar-upload-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}

.avatar-upload-input {
    width: 150px;
    padding: 8px 12px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    text-align: center;
}

.avatar-upload-input:hover {
    border-color: #3498db;
    background: #e9ecef;
    color: #3498db;
}

.avatar-upload-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.avatar-upload-input::file-selector-button {
    display: none;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* =============================================
    9. 设置样式（Settings Styles）
    ============================================= */

.settings-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: #2c3e50;
    min-width: 150px;
}

.setting-icon {
    font-size: 1.1em;
    opacity: 0.8;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #3498db;
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px #3498db;
}

.toggle-switch:hover .toggle-slider {
    background-color: #b3b3b3;
}

input:checked:hover + .toggle-slider {
    background-color: #2980b9;
}

.duration-input {
    width: 90px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 6px 8px;
    background: white;
    font-size: 0.9em;
    text-align: center;
}

.duration-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* =============================================
    10. 内容容器样式（Content Container Styles）
    ============================================= */

.content-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.content-container-sm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.content-scrollable {
    color: #2c3e50;
    line-height: 1.7;
    overflow-y: auto;
}

.content-scrollable-lg {
    max-height: 68vh;
}

.content-scrollable-md {
    max-height: 50vh;
}

.content-scrollable-sm {
    max-height: 40vh;
}

/* =============================================
    11. 语言切换器样式（Language Switcher Styles）
    ============================================= */

.language-switcher {
    position: relative;
    display: inline-block;
}

/* =============================================
    12. 页面状态样式（Page State Styles）
    ============================================= */

.active {
    display: block;
}

#homePage {
    display: none;
}

#homePage.active {
    display: block;
}

/* =============================================
    13. 初始化模态框样式（Initialization Modal Styles）
    ============================================= */

#initializationModal .modal-icon {
    font-size: 24px;
    color: #3498db;
}

#initializationModal .modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

#initializationModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#initializationModal .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#initializationModal .modal-body {
    flex: 1;
    overflow-y: auto;
    line-height: 1.6;
    color: #666;
}

#initializationModal .modal-body p {
    margin-bottom: 15px;
}

.warning-section {
    background: #fff8e6;
    border: 1px solid #ffd54f;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.warning-title {
    font-weight: 600;
    color: #e65100;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.warning-icon {
    color: #ff6b35;
}

.warning-text {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.benefit-section {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.benefit-title {
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.benefit-icon {
    color: #4caf50;
}

.benefit-text {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.benefit-text span {
    white-space: pre-line;
}

#initializationModal .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

#initializationModal .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#initializationModal .btn-secondary {
    background: #f5f5f5;
    color: #666;
}

#initializationModal .btn-secondary:hover {
    background: #e0e0e0;
}

#initializationModal .btn-primary {
    background: #3498db;
    color: white;
}

#initializationModal .btn-primary:hover {
    background: #2980b9;
}

/* =============================================
    14. 账户安全模态框样式（Account Security Modal Styles）
    ============================================= */

.security-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.security-option {
    padding: 12px 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
}

.security-option:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

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

.security-option-content {
    flex: 1;
}

.security-option-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.security-option-desc {
    font-size: 12px;
    color: #666;
}

.security-option-arrow {
    color: #999;
    font-size: 16px;
}

.warning-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #856404;
}

.warning-message strong {
    display: block;
    margin-bottom: 4px;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* =============================================
    15. 移动端适配（Mobile Responsive）
    ============================================= */

@media (max-height: 600px) {
    .modal-content {
        margin: 20px auto;
        padding: 15px;
        max-height: 95vh;
    }
    
    .modal-content-md,
    .modal-content-lg {
        max-width: 95%;
    }
    
    .stats-modal-content {
        max-height: 95vh;
    }
}

@media (max-width: 600px) {
    header {
        padding: 8px 12px;
    }
    
    h1 {
        font-size: 1.1em;
    }
    
    .info-icon, .stats-icon {
        display: none;
    }
    
    #languageSwitcher,#authButtons {
        display: none !important;
    }
    
    .header-btn {
        padding: 5px 8px;
        font-size: 0.85em;
    }
    
    .user-btn {
        padding: 4px 8px;
    }
    
    .user-name {
        display: none;
    }
    
    .dropdown-arrow {
        display: none;
    }
}
