:root {
    --bg-gradient: linear-gradient(135deg, #0b1120 0%, #171d2c 100%);
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(255, 255, 255, 0.05);
    --card-hover-border: rgba(59, 130, 246, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

.sidebar {
    width: 250px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.brand { font-size: 11px; color: var(--primary-color); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }

.board-list { list-style: none; padding: 16px; flex: 1; overflow-y: auto; }
.board-item { padding: 12px 16px; margin-bottom: 8px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all 0.2s ease; border: 1px solid transparent; }
.board-item:hover { background: rgba(255, 255, 255, 0.03); }
.board-item.active { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); color: var(--primary-color); font-weight: 500; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.main-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.main-header h1 { font-size: 18px; font-weight: 600; }

.actions { display: flex; align-items: center; gap: 16px; }

/* 控件外观设计 */
.control-group {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}
.custom-select {
    background: transparent;
    color: var(--text-main);
    border: none;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.custom-select option { background: #171d2c; color: #fff; }

.btn { padding: 8px 16px; border-radius: 6px; border: none; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; }
.primary-btn { background: var(--primary-color); color: white; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25); }
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }

.sync-status { font-size: 12px; color: #10b981; display: flex; align-items: center; gap: 6px; }
.sync-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #10b981; box-shadow: 0 0 8px #10b981; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

/* ================================
   视窗级排版 (Layout Views) 
   ================================ */
.board-view {
    flex: 1;
    padding: 32px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    /* 基础过渡，让各种切换丝滑无比 */
    transition: all 0.4s ease;
}

/* 1. 横排无限右滚模式 */
.view-horizontal {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}

/* 2. 网格大盘瀑布流（超4列回行） */
.view-grid {
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
    justify-content: flex-start;
}

/* 3. 迷你卡片堆叠（隐藏内部大列表） */
.view-compact {
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 12px;
}

.empty-state { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 15px; }

/* ================================
   容器架构及尺寸缩放 (Steps Sizing)
   ================================ */
.kanban-step {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideInLeft 0.3s ease forwards;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden; /* 为了彩色头部光晕限制边界 */
    cursor: grab; /* 大列本体可以被抓住 */
}
.kanban-step:active { cursor: grabbing; }

.kanban-step.dragging-step {
    opacity: 0.5;
    transform: scale(0.98);
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

@keyframes slideInLeft { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* 基础尺寸设定 (以横向为主) */
.kanban-step { width: 320px; min-width: 320px; height: calc(100vh - 140px); }

/* 网格模式尺寸补正 (高度无需定死撑满屏幕，可以适当缩短以看到第二行) */
.view-grid .kanban-step { height: 65vh; min-height: 400px; }

/* 用户可选缩放维度 */
.size-small .kanban-step { width: 250px; min-width: 250px; }
.size-large .kanban-step { width: 440px; min-width: 440px; }

/* 紧凑缩小视图下，直接重写高度与列宽做极致压缩 */
.view-compact .kanban-step { width: 200px; min-width: 200px; height: 120px; justify-content: center; }
.view-compact .step-content { display: none; } /* 直接隐藏内部数据流 */
.view-compact .step-header { border-bottom: none; height: 100%; justify-content: center; text-align: center; flex-direction: column; gap: 8px; }

/* 拖拽反馈样式 */
.kanban-step.drag-over {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5) inset;
    transform: scale(1.02);
}

/* ================================
   阶段首部 (Colorful Header)
   ================================ */
.step-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border-top: 4px solid var(--step-color, #3b82f6); /* JS 动态赋值颜色变量 */
}
/* 给头部加一点微弱的全局染色光晕 */
.step-header::before {
    content: '';
    position: absolute; top:0; left:0; width: 100%; height: 40px;
    background: var(--step-color, transparent);
    opacity: 0.1;
    pointer-events: none;
}

.step-header h3 { font-size: 14px; font-weight: 600; z-index: 1; }
.task-count { background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 10px; font-size: 11px; color: var(--text-muted); z-index: 1;}

.step-delete-btn {
    cursor: pointer;
    font-size: 12px;
    opacity: 0.3;
    transition: all 0.2s;
}
.step-delete-btn:hover {
    opacity: 1;
    transform: scale(1.1) translateY(-1px);
    text-shadow: 0 0 10px rgba(255,0,0,0.5);
}

.task-delete-btn {
    cursor: pointer;
    font-size: 13px;
    opacity: 0; /* 默认隐形，保持完美版面 */
    transition: all 0.2s ease;
}
.task-card:hover .task-delete-btn {
    opacity: 0.3; /* 悬浮卡片时微露真身 */
}
.task-delete-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1) translateY(-1px);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.step-color-picker {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    overflow: hidden;
    padding: 0;
    transition: transform 0.2s;
}
.step-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.step-color-picker::-webkit-color-swatch { border: none; border-radius: 50%; }
.step-color-picker:hover { transform: scale(1.2); box-shadow: 0 0 10px rgba(255,255,255,0.4); }

.step-name-editor {
    background: transparent;
    border: 1px solid transparent;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    width: 130px;
    outline: none;
    transition: all 0.2s;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.step-name-editor:not(:focus):hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }
.step-name-editor:focus { border-color: var(--primary-color); background: rgba(0,0,0,0.6); width: 180px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

.step-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.step-content::-webkit-scrollbar { width: 6px; }
.step-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ================================
   任务卡片与优先级徽章 (Priority Cards)
   ================================ */
.task-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 14px;
    cursor: grab;
    transition: all 0.2s ease;
    animation: slideUpFade 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: relative;
    z-index: 10;
}

.task-card:active { cursor: grabbing; }

.task-card.dragging {
    opacity: 0.6;
    transform: scale(0.95);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.task-card:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    background: rgba(30, 41, 59, 0.85); 
}

.task-header-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.task-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.contact-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.1);
    background: #1e293b;
    flex-shrink: 0;
}

.task-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #e2e8f0;
    word-break: break-word;
}

.task-tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.source-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.jump-chatwoot-btn:hover {
    transform: scale(1.3) translateY(-1px);
    opacity: 1 !important;
    text-shadow: 0 0 8px rgba(255,255,255,0.8);
}

.task-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

/* 优先级徽章样式 */
.priority-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255,255,255,0.05); /* 默认灰色 */
    color: #94a3b8;
    white-space: nowrap;
}
.priority-badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}

.prio-low { color: #3b82f6; background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.2) }
.prio-medium { color: #10b981; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2)}
.prio-high { color: #f59e0b; background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2)}
.prio-urgent { color: #ef4444; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2)}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #64748b;
    border-top: 1px dashed rgba(255,255,255,0.05);
    padding-top: 10px;
    margin-top: 8px;
}

.task-id-hash {
    opacity: 0.5;
}

.due-date {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    background: rgba(255,255,255,0.05);
    padding: 3px 8px;
    border-radius: 10px;
}
.time-past { color: #f87171; background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.2); }
.time-future { color: #fbbf24; background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.2); }

@keyframes slideUpFade { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
