/* ==========================================================================
   TaskFlow — design tokens
   ========================================================================== */
:root {
    --color-bg: #f4f5f9;
    --color-surface: #ffffff;
    --color-border: #e4e6ef;
    --color-text: #1c1f2b;
    --color-text-muted: #6b7080;

    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-soft: #eef0fd;

    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-danger-soft: #fdecec;

    --color-success: #16a34a;
    --color-success-soft: #eafbf1;

    --status-todo: #6b7080;
    --status-todo-bg: #eef0f3;
    --status-inprogress: #b45309;
    --status-inprogress-bg: #fef3e2;
    --status-done: #15803d;
    --status-done-bg: #e9f9ef;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(20, 21, 40, 0.06);
    --shadow-md: 0 8px 24px rgba(20, 21, 40, 0.10);
    --shadow-lg: 0 24px 48px rgba(20, 21, 40, 0.18);

    --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, Helvetica, Arial, sans-serif;

    --transition-fast: 150ms ease;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-header__inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
}
.brand:hover { text-decoration: none; }

.brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.brand__mark--lg {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.1rem;
}

.brand__name {
    font-weight: 650;
    font-size: 1.05rem;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-bar__name {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.app-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); }

.btn--secondary {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}
.btn--secondary:hover:not(:disabled) { background: #e2e4fb; }

.btn--danger {
    background: var(--color-danger);
    color: #fff;
}
.btn--danger:hover:not(:disabled) { background: var(--color-danger-hover); }

.btn--ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-bg); }

.btn--sm { padding: 6px 12px; font-size: 0.82rem; }
.btn--block { width: 100%; }
.btn__icon { font-size: 1rem; line-height: 1; }

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    font-size: 0.95rem;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.icon-btn:hover { background: var(--color-bg); }
.icon-btn--danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
textarea,
select,
.select {
    font-family: inherit;
    font-size: 0.92rem;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
textarea { resize: vertical; min-height: 70px; font-family: inherit; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-error {
    background: var(--color-danger-soft);
    color: var(--color-danger);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin: 0;
}

/* ==========================================================================
   Auth pages
   ========================================================================== */
body.auth-page .app-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 65px);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
    text-align: center;
}

.auth-card__brand { margin-bottom: 16px; }
.auth-card__title { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card__subtitle { color: var(--color-text-muted); font-size: 0.9rem; margin: 0 0 24px; }
.auth-card .form { text-align: left; margin-bottom: 20px; }
.auth-card__footer { font-size: 0.85rem; color: var(--color-text-muted); margin: 0; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dashboard__toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard__subtitle { color: var(--color-text-muted); margin: 4px 0 0; font-size: 0.92rem; }
.dashboard__actions { display: flex; gap: 12px; align-items: center; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.task-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
}

.task-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: var(--color-bg); transition: background var(--transition-fast); }

.task-table__actions-col { width: 90px; text-align: right; white-space: nowrap; }
.task-table__loading { text-align: center; color: var(--color-text-muted); padding: 32px 0; }

.task-title { font-weight: 600; }
.task-desc { font-size: 0.83rem; color: var(--color-text-muted); margin-top: 3px; max-width: 360px; }

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 650;
}
.status-badge--Todo { background: var(--status-todo-bg); color: var(--status-todo); }
.status-badge--InProgress { background: var(--status-inprogress-bg); color: var(--status-inprogress); }
.status-badge--Done { background: var(--status-done-bg); color: var(--status-done); }

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--color-text-muted);
}
.empty-state h1 { margin-bottom: 8px; color: var(--color-text); }
.empty-state .btn { margin-top: 14px; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}
.pagination__info { font-size: 0.85rem; color: var(--color-text-muted); }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 18, 30, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: fadeIn var(--transition-fast);
}

.modal-overlay:not([hidden]) {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 460px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px 28px 28px;
    animation: slideUp 180ms ease;
}
.modal--sm { max-width: 400px; }

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.modal__close:hover { background: var(--color-bg); }

.modal__body-text {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    margin: 0 0 24px;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--color-text);
    color: #fff;
    font-size: 0.87rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.toast--visible { opacity: 1; transform: translateY(0); }

.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }
.toast--info { background: var(--color-text); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .dashboard__toolbar { flex-direction: column; align-items: stretch; }
    .dashboard__actions { justify-content: space-between; }
    .task-table thead { display: none; }
    .task-table, .task-table tbody, .task-table tr, .task-table td { display: block; width: 100%; }
    .task-table tr { padding: 12px 20px; border-bottom: 1px solid var(--color-border); }
    .task-table td { padding: 4px 0; border-bottom: none; }
    .task-table__actions-col { text-align: left; margin-top: 8px; }
}
