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

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1a1d23;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --column-todo: #f0f4ff;
    --column-progress: #fef9ee;
    --column-done: #f0fdf4;
    --priority-low: #6ee7b7;
    --priority-medium: #fbbf24;
    --priority-high: #f87171;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
    --transition: 150ms ease;
    --sidebar-width: 240px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    display: flex;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 200;
    transition: transform 200ms ease, opacity 200ms ease;
}

.sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 4px 8px;
    margin-bottom: 4px;
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: var(--text);
    font-family: inherit;
}

.project-item:hover {
    background: var(--bg);
}

.project-item.active {
    background: #eef2ff;
    color: var(--primary);
}

.project-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.project-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-item-count {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(0,0,0,0.06);
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.btn-add-project {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 8px 10px;
    width: 100%;
    font-size: 13px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-add-project:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .user-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.sidebar-footer .user-selector label {
    white-space: nowrap;
}

.sidebar-footer .user-selector select {
    flex: 1;
    min-width: 0;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-toggle {
    display: none;
    font-size: 18px;
}

/* ===== Board ===== */
.board {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
}

.board-columns {
    display: flex;
    gap: 20px;
    min-height: calc(100vh - 100px);
}

.column {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.column[data-status="todo"] .column-header { background: var(--column-todo); }
.column[data-status="in-progress"] .column-header { background: var(--column-progress); }
.column[data-status="done"] .column-header { background: var(--column-done); }

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
}

.column-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.task-count {
    background: rgba(0,0,0,0.08);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.task-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
    padding: 4px;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.task-list.drag-over {
    background: rgba(37, 99, 235, 0.06);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Task Card ===== */
.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: grab;
    transition: box-shadow var(--transition), transform var(--transition);
    position: relative;
}

.task-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.task-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.task-card-priority {
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 2px 2px 0;
}

.task-card-priority[data-priority="low"] { background: var(--priority-low); }
.task-card-priority[data-priority="medium"] { background: var(--priority-medium); }
.task-card-priority[data-priority="high"] { background: var(--priority-high); }

.task-card-title {
    font-size: 14px;
    font-weight: 500;
    margin-left: 6px;
    margin-bottom: 6px;
    word-break: break-word;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.task-card-meta .assignee {
    background: #eef2ff;
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.task-card-meta .deadline {
    display: flex;
    align-items: center;
    gap: 3px;
}

.task-card-meta .deadline.overdue {
    color: var(--danger);
    font-weight: 500;
}

.task-card-meta .comment-count {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ===== Buttons ===== */
.btn {
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    font-weight: 500;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    padding: 8px 16px;
    font-weight: 500;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 8px;
}

.btn-ghost:hover { background: rgba(0,0,0,0.05); }

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

.btn-add-task {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 10px;
    width: 100%;
    font-size: 13px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-add-task:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 200ms ease;
}

.modal-sm { max-width: 400px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body { padding: 20px; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.modal-footer-right {
    display: flex;
    gap: 8px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group { flex: 1; }

/* ===== Color Picker ===== */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text);
}

/* ===== Comments ===== */
.comments-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.comments-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.comment {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.comment-author {
    font-weight: 600;
    font-size: 12px;
}

.comment-date {
    font-size: 11px;
    color: var(--text-muted);
}

.comment-text {
    color: var(--text);
    line-height: 1.4;
}

.comment-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.comment-input textarea {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    resize: none;
}

.comment-input textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Users Modal ===== */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 14px;
}

.add-user-row {
    display: flex;
    gap: 8px;
}

.add-user-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.add-user-row input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .board-columns {
        flex-direction: column;
    }

    .column {
        min-width: unset;
        max-width: unset;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
