/* ============================================
   Dev OS - 全局样式 (深色主题)
   ============================================ */

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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2230;
    --bg-card: #1a1f2e;
    --bg-hover: #222838;
    --border: #2d3349;
    --border-light: #363d56;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #6366f1;
    --accent-hover: #5558e6;
    --accent-bg: rgba(99,102,241,.12);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
    --nav-height: 56px;
    --sidebar-width: 240px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ===================== 导航栏 ===================== */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 8px; }

.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo-icon { font-size: 22px; }
.logo-text { background: linear-gradient(135deg, #6366f1, #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.topbar-nav { display: flex; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px;
    transition: all .2s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-icon { font-size: 16px; }

.topbar-right { display: flex; align-items: center; }
.user-info { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
}
.user-name { font-size: 13px; color: var(--text-secondary); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
    padding: 5px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-size: 12px; cursor: pointer;
    transition: all .2s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ===================== 布局 ===================== */
.layout {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    position: fixed;
    top: var(--nav-height);
    bottom: 0;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: 1400px;
}

/* ===================== 侧边栏 ===================== */
.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px 12px; font-size: 12px; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: 1px;
}
.sidebar-add {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--bg-tertiary); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; transition: all .2s;
}
.sidebar-add:hover { background: var(--accent); color: #fff; }
.sidebar-projects { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.sidebar-project {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    transition: all .2s; font-size: 13px;
}
.sidebar-project:hover { background: var(--bg-hover); }
.sidebar-project.active { background: var(--accent-bg); color: var(--accent); }
.project-dot { font-size: 16px; width: 20px; text-align: center; }
.project-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archived-tag { font-size: 10px; color: var(--text-muted); padding: 2px 6px; background: var(--bg-tertiary); border-radius: 4px; }
.sidebar-empty { color: var(--text-muted); font-size: 13px; padding: 12px; text-align: center; }

/* ===================== 页面标题 ===================== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ===================== 卡片 ===================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color .2s;
}
.card:hover { border-color: var(--border-light); }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* ===================== 统计卡片 ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* ===================== 按钮 ===================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-tertiary);
    color: var(--text-primary); font-size: 13px; cursor: pointer;
    transition: all .2s; font-family: inherit;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ===================== 表单 ===================== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 14px; font-family: inherit;
    transition: border-color .2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 100px; }

/* ===================== 徽章 ===================== */
.badge {
    display: inline-block; padding: 2px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 500;
}

/* ===================== 看板 ===================== */
.kanban {
    display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px;
}
.kanban-column {
    flex: 1; min-width: 280px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
}
.kanban-column-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; font-size: 14px; font-weight: 600;
}
.kanban-column-count {
    background: var(--bg-tertiary); padding: 2px 8px;
    border-radius: 12px; font-size: 12px; color: var(--text-secondary);
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: grab;
    transition: all .2s;
    user-select: none;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.kanban-card[draggable="true"]:hover { box-shadow: 0 2px 8px rgba(99,102,241,0.15); }
.kanban-card.dragging { opacity: 0.4; transform: rotate(2deg); }
.kanban-cards.drag-over { background: rgba(99,102,241,0.08); border: 2px dashed var(--accent); border-radius: var(--radius-sm); }
.kanban-card-title { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kanban-card-tag {
    font-size: 11px; padding: 2px 6px;
    background: var(--bg-tertiary); border-radius: 4px;
    color: var(--text-secondary);
}

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover { background: var(--bg-hover); }

/* ===================== 空状态 ===================== */
.empty-state {
    text-align: center; padding: 60px 20px;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 16px; }

/* ===================== 骨架屏 ===================== */
.skeleton-item { padding: 16px; border-bottom: 1px solid var(--border); }
.skeleton-line {
    height: 14px; background: var(--bg-tertiary); border-radius: 4px;
    margin-bottom: 8px; animation: pulse 1.5s ease-in-out infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===================== 进度条 ===================== */
.progress-bar {
    position: relative; height: 24px;
    background: var(--bg-tertiary); border-radius: 12px;
    overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 12px; transition: width .3s ease;
}
.progress-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 500; color: #fff;
}

/* ===================== 弹窗 ===================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto;
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-actions {
    display: flex; gap: 12px; justify-content: flex-end;
    margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* ===================== AI 规划 ===================== */
.planner-input {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
}
.planner-result {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.planner-task-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 8px;
}
.planner-loading {
    display: flex; align-items: center; gap: 12px;
    padding: 40px; justify-content: center; color: var(--text-secondary);
}
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===================== 网格 ===================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .topbar-nav { display: none; }
}

/* ===================== 登录页 ===================== */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a1f2e 100%);
    padding: 20px;
}
.auth-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 40px; max-width: 400px; width: 100%;
    box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon { font-size: 48px; }
.auth-logo-text { font-size: 28px; font-weight: 700; margin-top: 8px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--bg-primary); border-radius: var(--radius-sm); padding: 4px; }
.auth-tab { flex: 1; text-align: center; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); font-size: 14px; transition: all .2s; }
.auth-tab.active { background: var(--accent); color: #fff; }

/* ===================== 工具类 ===================== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-right { text-align: right; }
.cursor-pointer { cursor: pointer; }

/* ===================== 认证页增强 ===================== */

/* 方式切换器 (邮箱/手机) */
.auth-method-switch {
    display: flex; gap: 4px; margin-bottom: 20px;
    background: var(--bg-primary); border-radius: var(--radius-sm); padding: 4px;
}
.auth-method {
    flex: 1; text-align: center; padding: 8px;
    border-radius: var(--radius-sm); cursor: pointer;
    color: var(--text-secondary); font-size: 13px; transition: all .2s;
}
.auth-method.active { background: var(--bg-tertiary); color: var(--accent); }
.auth-method:hover:not(.active) { color: var(--text-primary); }

/* 验证码输入组 */
.otp-group {
    display: flex; gap: 8px;
}
.otp-group .form-input { flex: 1; }
.otp-btn {
    white-space: nowrap; padding: 10px 16px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-tertiary); color: var(--accent);
    font-size: 13px; cursor: pointer; transition: all .2s;
    font-family: inherit;
}
.otp-btn:hover:not(:disabled) { background: var(--accent-bg); border-color: var(--accent); }
.otp-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 忘记密码链接 */
.forgot-link {
    text-align: right; margin-top: -8px; margin-bottom: 16px;
}
.forgot-link a {
    color: var(--text-secondary); font-size: 12px; transition: color .2s;
}
.forgot-link a:hover { color: var(--accent); }

/* 分隔线 */
.auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; color: var(--text-muted); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* 返回链接 */
.auth-back {
    text-align: center; margin-top: 16px;
}
.auth-back a {
    color: var(--text-secondary); font-size: 13px; transition: color .2s;
}
.auth-back a:hover { color: var(--accent); }

/* 成功提示框 */
.auth-success-box {
    text-align: center; padding: 24px;
}
.auth-success-box .success-icon {
    font-size: 48px; margin-bottom: 16px;
}
.auth-success-box h3 {
    font-size: 18px; margin-bottom: 8px; color: var(--success);
}
.auth-success-box p {
    color: var(--text-secondary); font-size: 14px; margin-bottom: 20px;
}

/* 手机号前缀 */
.phone-input-group {
    display: flex; align-items: center; gap: 0;
}
.phone-prefix {
    padding: 10px 12px; background: var(--bg-tertiary);
    border: 1px solid var(--border); border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-secondary); font-size: 14px; white-space: nowrap;
}
.phone-input-group .form-input {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
