/**
 * TravelPuzzle - 公共样式
 * 包含全局变量、动画、通用组件样式
 */

/* ==================== 全局样式重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #0f172a;
    --card-bg: #1e293b;
    --card-bg-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ==================== 动画定义 ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(99, 102, 241, 0.5); }
    50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.8), 0 0 40px rgba(99, 102, 241, 0.4); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

@keyframes confetti {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ==================== 通用组件样式 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--card-bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--card-bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

select.form-input {
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

/* ==================== 难度星级选择器 ==================== */
.difficulty-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
}

.difficulty-star {
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    opacity: 0.4;
}

.difficulty-star:hover,
.difficulty-star.active {
    color: #ffc107;
    opacity: 1;
    transform: scale(1.1);
}

.difficulty-star.active {
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

/* ==================== 页面容器 ==================== */
.page {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal.large {
    max-width: 900px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== 表格样式 ==================== */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.table-search {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    padding: 8px 12px;
    background: var(--card-bg-light);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    width: 240px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--card-bg-light);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-official {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.status-official::before {
    background: var(--success-color);
}

.status-test {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.status-test::before {
    background: var(--warning-color);
}

.status-disabled {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.status-disabled::before {
    background: var(--text-secondary);
}

.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.status-in_progress {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
}

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--card-bg-light);
    color: var(--text-primary);
}

.action-btn:disabled,
.action-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.action-btn:disabled:hover,
.action-btn.disabled:hover {
    background: transparent;
    color: var(--text-secondary);
}

/* ==================== 标签页组件 ==================== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* ==================== 表单布局 ==================== */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-section {
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* ==================== 题目列表 ==================== */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-item {
    background: var(--card-bg-light);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: move;
    transition: all 0.3s ease;
}

.question-item:hover {
    border-color: var(--primary-color);
}

.question-drag-handle {
    color: var(--text-secondary);
    cursor: grab;
}

.question-number-badge {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.question-info {
    flex: 1;
}

.question-info-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.question-info-type {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==================== Toast 提示 ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

/* ==================== 加载动画 ==================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==================== 工具类 ==================== */
.hidden {
    display: none !important;
}

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

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .navbar-menu {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .games-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .game-container {
        padding: 20px 16px;
    }

    .question-card {
        padding: 24px;
    }

    .question-title {
        font-size: 18px;
    }

    .password-lock {
        gap: 8px;
    }

    .lock-digit {
        width: 50px;
        height: 70px;
        font-size: 24px;
    }

    .completion-stats {
        flex-direction: column;
        gap: 20px;
    }

    .completion-title {
        font-size: 28px;
    }

    .login-container {
        margin: 20px;
        padding: 24px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
