/* ============================================
   公共样式 - 按钮、卡片、表单、Toast、布局
   ============================================ */

:root {
    --primary: #4f8cff;
    --primary-dark: #3a6fd8;
    --primary-light: #e8f0ff;
    --success: #34c759;
    --success-bg: #eafef0;
    --warning: #ff9800;
    --warning-bg: #fff5e6;
    --danger: #ff3b30;
    --danger-bg: #ffeae8;
    --gray-bg: #f5f5f5;
    --gray-border: #e0e0e0;
    --gray-text: #888;
    --dark: #1a1a1a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.12);
    --max-width: 480px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: var(--dark);
    line-height: 1.6;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--primary);
    text-decoration: none;
}

input, button, textarea, select {
    font-family: inherit;
    font-size: inherit;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
}

/* ============================================
   布局
   ============================================ */

#app {
    min-height: 100vh;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 12px;
    color: var(--gray-text);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 12px;
}

/* ============================================
   卡片
   ============================================ */

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

/* ============================================
   按钮
   ============================================ */

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    transition: opacity 0.2s, transform 0.1s;
    border: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============================================
   表单
   ============================================ */

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--gray-text);
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
}

/* ============================================
   Toast
   ============================================ */

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: #fff;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.toast-info { background: rgba(0, 0, 0, 0.8); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ============================================
   模态弹窗
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-border);
    font-size: 17px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

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

/* ============================================
   表格
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: var(--gray-bg);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-text);
    border-bottom: 1px solid var(--gray-border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-border);
}

.data-table tr:hover {
    background: var(--primary-light);
}

/* ============================================
   进度条
   ============================================ */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s;
}

/* ============================================
   通用工具类
   ============================================ */

.text-center { text-align: center; }
.text-gray { color: var(--gray-text); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.bold { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }
.w-full { width: 100%; }
