/* ============================================================
 * CRM MVP 样式表 - Week2 完整版
 * ============================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

a { color: #1890ff; text-decoration: none; }
a:hover { color: #40a9ff; }

/* ============================================================
 * 登录页
 * ============================================================ */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h1 {
    font-size: 28px;
    color: #333;
    margin-bottom: 8px;
}

.login-header p {
    color: #999;
    font-size: 14px;
}

/* 登录 Tab */
.login-tabs {
    display: flex;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.login-links {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #666;
    font-size: 13px;
}

.form-group input, .form-group select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
    background: #fff;
}

.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.code-input-group {
    display: flex;
    gap: 10px;
}

.code-input-group input { flex: 1; }

.btn-send-code {
    width: 130px;
    height: 44px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-send-code:hover { background: #5a6fd6; }
.btn-send-code:disabled { background: #ccc; cursor: not-allowed; }

.error-msg {
    color: #ff4d4f;
    font-size: 13px;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #fff2f0;
    border-radius: 6px;
}

.success-msg {
    color: #52c41a;
    font-size: 13px;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #f6ffed;
    border-radius: 6px;
    border: 1px solid #b7eb8f;
}

.btn-login {
    width: 100%;
    height: 46px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-login:hover { opacity: 0.9; }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: #999;
    font-size: 12px;
}

/* ============================================================
 * 主布局
 * ============================================================ */
.top-nav {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.top-nav-left { display: flex; align-items: center; gap: 16px; }
.top-nav-left .brand { font-size: 18px; font-weight: 600; color: #667eea; }
.top-nav-left .tenant-name { font-size: 13px; color: #999; padding: 2px 10px; background: #f5f5f5; border-radius: 12px; }

.top-nav-right { display: flex; align-items: center; gap: 12px; }
.top-nav-right .user-info { font-size: 14px; color: #333; }

.role-badge { font-size: 12px; padding: 2px 8px; background: #e6f7ff; color: #1890ff; border-radius: 10px; }

.btn-logout { font-size: 13px; color: #999; padding: 4px 12px; border: 1px solid #d9d9d9; border-radius: 6px; transition: all 0.2s; }
.btn-logout:hover { color: #ff4d4f; border-color: #ff4d4f; }

.main-layout { display: flex; margin-top: 56px; min-height: calc(100vh - 56px); }

/* ============================================================
 * 侧边栏
 * ============================================================ */
.sidebar {
    width: 220px;
    background: #001529;
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 99;
}

.nav-menu { list-style: none; padding: 8px 0; }

.nav-item a {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255,255,255,0.65);
    transition: all 0.2s;
    font-size: 14px;
}

.nav-item a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-item.active a { color: #fff; background: #667eea; }
.nav-icon { margin-right: 10px; font-size: 16px; }

/* ============================================================
 * 主内容区
 * ============================================================ */
.content {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
    min-height: calc(100vh - 56px);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 { font-size: 20px; color: #333; }
.welcome-text { color: #999; font-size: 14px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
 * 按钮系统
 * ============================================================ */
.btn-primary {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
    text-align: center;
}
.btn-primary:hover { opacity: 0.9; color: #fff; }

.btn-secondary {
    display: inline-block;
    padding: 8px 20px;
    background: #fff;
    color: #666;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { color: #667eea; border-color: #667eea; }

.btn-danger-sm {
    padding: 4px 12px;
    background: #fff;
    color: #ff4d4f;
    border: 1px solid #ff4d4f;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.btn-danger-sm:hover { background: #ff4d4f; color: #fff; }

.btn-sm {
    display: inline-block;
    padding: 3px 10px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-sm:hover { background: #e6f7ff; color: #1890ff; border-color: #1890ff; }

.btn-danger-text {
    background: none;
    border: none;
    color: #ff4d4f;
    cursor: pointer;
    font-size: 12px;
    padding: 3px 6px;
}
.btn-danger-text:hover { color: #ff7875; }

.btn-primary-sm {
    padding: 6px 16px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-primary-sm:hover { background: #5a6fd6; }

.btn-filter {
    padding: 6px 16px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-filter:hover { background: #5a6fd6; }

/* ============================================================
 * Flash 消息
 * ============================================================ */
.flash-msg {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}
.flash-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.flash-error { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.flash-info { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }

/* ============================================================
 * 统计卡片（工作台）
 * ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon { font-size: 32px; }
.stat-number { font-size: 28px; font-weight: 600; color: #333; }
.stat-label { font-size: 13px; color: #999; }

/* ============================================================
 * 工作台分区
 * ============================================================ */
.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.section-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.section-card h3 { font-size: 16px; margin-bottom: 16px; color: #333; }

.recent-list { display: flex; flex-direction: column; gap: 12px; }
.recent-item { padding: 10px; border-radius: 6px; background: #fafafa; }
.recent-meta { display: flex; justify-content: space-between; font-size: 12px; color: #999; margin-bottom: 4px; }
.recent-user { color: #333; font-weight: 500; }
.recent-content { font-size: 13px; margin-bottom: 4px; }
.recent-text { font-size: 13px; color: #666; }
.recent-empty, .todo-empty { text-align: center; padding: 32px 0; color: #999; }
.recent-empty .hint, .todo-empty .hint { font-size: 13px; margin-top: 4px; }

/* ============================================================
 * 快捷操作
 * ============================================================ */
.quick-actions { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.quick-actions h3 { font-size: 16px; margin-bottom: 16px; }
.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.action-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: #f6f8fa; border-radius: 8px; color: #333; font-size: 14px; transition: all 0.2s; }
.action-btn:hover { background: #e6f7ff; color: #1890ff; }

/* ============================================================
 * 筛选栏
 * ============================================================ */
.filter-bar {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.filter-input, .filter-select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.filter-input { min-width: 180px; }
.filter-input:focus, .filter-select:focus { border-color: #667eea; }

/* ============================================================
 * 数据表格
 * ============================================================ */
.table-wrapper {
    background: #fff;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

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

.data-table th {
    padding: 12px 16px;
    text-align: left;
    background: #fafafa;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.data-table tbody tr:hover { background: #fafafa; }

/* ============================================================
 * 分页
 * ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
}

.page-link {
    padding: 6px 16px;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    color: #333;
    font-size: 13px;
}
.page-link:hover { color: #667eea; border-color: #667eea; }

.page-info { font-size: 13px; color: #999; }

/* ============================================================
 * 空状态
 * ============================================================ */
.empty-state {
    background: #fff;
    border-radius: 8px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-hint { color: #999; font-size: 13px; padding: 16px 0; }

/* ============================================================
 * 详情卡片
 * ============================================================ */
.detail-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.detail-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-badge {
    font-size: 12px;
    background: #f0f0f0;
    color: #999;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: normal;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.detail-item {
    display: flex;
    gap: 12px;
    font-size: 13px;
    padding: 6px 0;
}

.detail-item .label {
    color: #999;
    min-width: 100px;
    flex-shrink: 0;
}

/* ============================================================
 * 表单卡片（新增/编辑）
 * ============================================================ */
.form-card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.crud-form .form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0;
}

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

.crud-form .form-group input,
.crud-form .form-group select {
    height: 40px;
    font-size: 14px;
}

.crud-form .form-group textarea {
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.required { color: #ff4d4f; }
.disabled-input { background: #f5f5f5; color: #999; cursor: not-allowed; }

/* ============================================================
 * 内联表单（详情页快速添加）
 * ============================================================ */
.inline-form {
    margin-bottom: 16px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
}

.form-row.compact {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.form-input-sm {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    min-width: 100px;
}

.form-select-sm {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.form-input-sm:focus, .form-select-sm:focus { border-color: #667eea; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

/* 跟进表单 */
.followup-form {
    margin-bottom: 16px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
}

.followup-form .form-group {
    margin-bottom: 8px;
}

/* ============================================================
 * 时间线
 * ============================================================ */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e8e8e8;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    background: #667eea;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e8e8e8;
}

.timeline-content {
    background: #fafafa;
    padding: 12px 16px;
    border-radius: 6px;
}

.timeline-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
    color: #999;
}

.timeline-user { color: #333; font-weight: 500; }
.timeline-time { color: #999; }
.timeline-links { font-size: 13px; margin-bottom: 4px; }
.timeline-text { font-size: 13px; color: #333; line-height: 1.6; }
.timeline-next { font-size: 12px; color: #666; margin-top: 4px; }

/* ============================================================
 * 标签
 * ============================================================ */
.tag {
    display: inline-block;
    padding: 1px 8px;
    background: #e6f7ff;
    color: #1890ff;
    border-radius: 10px;
    font-size: 11px;
}

.key-badge { color: #faad14; font-size: 14px; }

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
}
.status-active { background: #e6f7ff; color: #1890ff; }
.status-won { background: #f6ffed; color: #52c41a; }
.status-lost { background: #fff2f0; color: #ff4d4f; }
.status-paused { background: #fffbe6; color: #faad14; }

/* 状态操作区 */
.status-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================================
 * 占位页
 * ============================================================ */
.placeholder-card {
    background: #fff;
    border-radius: 8px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.placeholder-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-message { font-size: 16px; color: #666; margin-bottom: 24px; }
.btn-back { display: inline-block; padding: 8px 24px; background: #667eea; color: #fff; border-radius: 6px; font-size: 14px; }
.btn-back:hover { background: #5a6fd6; color: #fff; }

/* ============================================================
 * 响应式
 * ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .nav-text { display: none; }
    .sidebar .nav-icon { margin-right: 0; }
    .sidebar .nav-item a { justify-content: center; padding: 12px; }
    .content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-sections { grid-template-columns: 1fr; }
    .crud-form .form-row { flex-direction: column; gap: 0; }
    .filter-form { flex-direction: column; }
    .filter-input, .filter-select { width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row.compact { flex-direction: column; }
}
