/* ========== AI教具网 - 全局基础样式 ========== */
/* 浅色主题：精美、大气、儒雅 */

:root {
    --primary: #4A90D9;
    --primary-light: #6BA3E0;
    --primary-dark: #3A7BC8;
    --accent: #6C5CE7;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #E17055;
    --bg-body: #F0F2F5;
    --bg-white: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-hover: #F5F7FA;
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --border-color: #E9ECEF;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 240px;
    --navbar-height: 60px;
    --font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.logo-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.site-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
}

.nav-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 12px 6px;
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.1), rgba(108, 92, 231, 0.08));
    color: var(--primary);
    font-weight: 500;
}

.nav-item.active i {
    color: var(--primary);
}

.nav-item i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-hot-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #E17055, #fab1a0);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

/* ========== 主内容区 ========== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-navbar {
    height: var(--navbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-right: 12px;
}

.navbar-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
}

/* .user-avatar 样式已移至下方用户下拉菜单区域 */

.page-container {
    position: relative;
    flex: 1;
    padding: 20px 24px;
    max-width: 100%;
    margin: 0;
    width: 100%;
    overflow-x: hidden;
}

.page-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* ========== 通用卡片 ========== */
.card-custom {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 24px;
    transition: box-shadow 0.2s ease;
}

.card-custom:hover {
    box-shadow: var(--shadow-md);
}

/* ========== 移动端侧边栏遮罩 ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    .mobile-menu-btn {
        display: block;
    }
    .page-container {
        padding: 12px 16px;
        max-width: 100vw;
    }
    .top-navbar {
        padding: 0 12px;
    }
}


/* ========== Toast通知样式 ========== */
.alert-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
}

.alert-toast.show {
    transform: translateX(0);
}

.alert-toast-success {
    background: var(--success);
}

.alert-toast-error {
    background: var(--danger);
}

.alert-toast-warning {
    background: var(--warning);
    color: var(--text-primary);
}

.alert-toast-info {
    background: var(--primary);
}


/* ========== 顶部导航登录/注册按钮 ========== */
.btn-login-nav,
.btn-register-nav {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-login-nav {
    color: var(--primary);
    border: 1px solid var(--primary);
    background: transparent;
}

.btn-login-nav:hover {
    background: var(--primary);
    color: #fff;
}

.btn-register-nav {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border: none;
    margin-left: 8px;
}

.btn-register-nav:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}


/* ========== 用户头像（顶部导航栏） ========== */
.user-info {
    position: relative;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-info:hover .user-avatar {
    transform: scale(1.08);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.4);
}

.avatar-initial {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    user-select: none;
}

/* ========== 用户下拉菜单 ========== */
.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    background: var(--bg-white);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.user-info:hover .user-dropdown,
.user-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 下拉菜单顶部用户信息区 */
.dropdown-user-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #f0f4ff, #f5f0ff);
}

.dropdown-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.dropdown-avatar span {
    color: #fff;
    font-size: 17px;
    font-weight: 700;
}

.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.dropdown-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-role {
    font-size: 12px;
    color: #667eea;
    font-weight: 500;
}

/* 下拉菜单项 */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 15px;
    transition: all 0.2s ease;
    position: relative;
}

.dropdown-item:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08), transparent);
    color: #667eea;
    padding-left: 22px;
}

.dropdown-item i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    transition: transform 0.2s ease;
}

.dropdown-item:hover i {
    transform: scale(1.15);
}

.dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 4px 12px;
}

.dropdown-item-danger {
    color: #999;
}

.dropdown-item-danger:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.06);
    padding-left: 22px;
}


/* ========== 通用模态框样式 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-icon {
    text-align: center;
    margin-bottom: 20px;
}

.modal-icon i {
    font-size: 64px;
}

.success-modal .modal-icon i {
    color: #00B894;
    animation: successPulse 0.6s ease;
}

.error-modal .modal-icon i {
    color: #E17055;
    animation: errorShake 0.6s ease;
}

.warning-modal .modal-icon i {
    color: #FDCB6E;
    animation: warningBounce 0.6s ease;
}

.confirm-modal .modal-icon i {
    color: #4A90D9;
    animation: confirmPulse 0.6s ease;
}

.info-modal .modal-icon i {
    color: #17a2b8;
    animation: confirmPulse 0.6s ease;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes warningBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes confirmPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #2D3436;
    text-align: center;
    margin-bottom: 12px;
}

.modal-message {
    font-size: 15px;
    color: #636E72;
    text-align: center;
    line-height: 1.6;
    margin-bottom: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.modal-btn-primary {
    background: #4A90D9;
    color: #fff;
}

.modal-btn-primary:hover {
    background: #3A7BC8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.3);
}

.modal-btn-primary:active {
    transform: translateY(0);
}

.modal-btn-secondary {
    background: #E9ECEF;
    color: #636E72;
}

.modal-btn-secondary:hover {
    background: #DEE2E6;
    transform: translateY(-1px);
}

.modal-btn-secondary:active {
    transform: translateY(0);
}

/* ==================== 管理员切换用户横幅 ==================== */

.admin-switch-banner {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #fff;
    padding: 8px 20px;
    font-size: 14px;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.switch-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.switch-banner-content i {
    font-size: 16px;
}

.btn-switch-back {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 4px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-switch-back:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: #fff;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .custom-modal {
        min-width: 90%;
        max-width: 90%;
        padding: 24px;
    }
    
    .modal-icon i {
        font-size: 48px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-message {
        font-size: 14px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}
