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

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --priority-low: #94a3b8;
    --priority-medium: #3b82f6;
    --priority-high: #f59e0b;
    --priority-urgent: #ef4444;
}

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

/* === Login Page === */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* === Forms === */
label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], textarea, select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 0.85rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-row { display: flex; gap: 0.75rem; }
.form-group { flex: 1; }

.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
.form-actions-right { display: flex; gap: 0.5rem; }

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
    text-decoration: none;
    gap: 0.35rem;
}

.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

/* === Top Bar === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.filter-bar select {
    margin-bottom: 0;
    width: auto;
    min-width: 150px;
}

/* === Board === */
.board {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    overflow-x: auto;
    min-height: calc(100vh - 60px);
    align-items: flex-start;
}

.column {
    flex: 0 0 300px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 100px);
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.column-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--col-color, var(--text-light));
}

.column-name {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text);
}

.column-count {
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    margin-left: 0.4rem;
}

.column-tasks {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 60px;
}

.column-footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border);
}

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

.add-task-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59,130,246,0.04);
}

/* === Task Card === */
.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    transition: box-shadow 0.15s, border-color 0.15s;
    border-left: 3px solid var(--priority-color, var(--border));
}

.task-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--text-light);
    border-left-color: var(--priority-color, var(--text-light));
}

.task-card.sortable-ghost {
    opacity: 0.4;
}

.task-card.sortable-chosen {
    box-shadow: var(--shadow-lg);
}

.task-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
    line-height: 1.35;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-card-due {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.task-card-due.overdue { color: var(--danger); font-weight: 600; }
.task-card-due.due-soon { color: var(--warning); font-weight: 600; }

.task-card-assignee {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text-light);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}

.task-card-labels {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.task-label-pill {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
}

/* === Priority indicators === */
.priority-low    { --priority-color: var(--priority-low); }
.priority-medium { --priority-color: var(--priority-medium); }
.priority-high   { --priority-color: var(--priority-high); }
.priority-urgent { --priority-color: var(--priority-urgent); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 8vh;
    z-index: 1000;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* === Label Checkboxes === */
.label-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.label-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.label-checkbox.checked {
    color: #fff;
    border-color: transparent;
}

.label-checkbox input { display: none; }

/* === Users List (admin) === */
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.user-row:last-child { border-bottom: none; }

/* === Labels List (admin) === */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.85rem;
}

.label-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* === Scrollbar === */
.column-tasks::-webkit-scrollbar { width: 4px; }
.column-tasks::-webkit-scrollbar-track { background: transparent; }
.column-tasks::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* === Responsive === */
@media (max-width: 768px) {
    .board { padding: 0.75rem; gap: 0.75rem; }
    .column { flex: 0 0 260px; }
    .topbar { padding: 0.5rem 0.75rem; }
    .topbar-title { font-size: 0.95rem; }
}
