/* ==========================================================================
   Catatan Tugas Harian — gaya tampilan
   ========================================================================== */

:root {
    --bg: #f5f7fc;
    --surface: #ffffff;
    --surface-soft: #f7f8fc;
    --text: #131a2b;
    --muted: #6b7488;
    --border: #e3e7f0;
    --border-strong: #ccd3e3;
    --accent: #4f46e5;
    --accent-soft: #eef1ff;
    --fill: #4f46e5;
    --success-bg: #eafaf1;
    --success-text: #0b7a4b;
    --danger-bg: #fdeeee;
    --danger-text: #b42318;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 14px 34px rgba(16, 24, 40, .09);
    --radius: 16px;
    --radius-sm: 11px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0f1d;
        --surface: #121a2c;
        --surface-soft: #172033;
        --text: #e9edf7;
        --muted: #99a3ba;
        --border: #24304a;
        --border-strong: #35425f;
        --accent: #a5b4fc;
        --accent-soft: #1b2340;
        --fill: #6366f1;
        --success-bg: #10291f;
        --success-text: #6ee7b7;
        --danger-bg: #2b1620;
        --danger-text: #fda4af;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 16px 40px rgba(0, 0, 0, .45);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    background-image: radial-gradient(900px 460px at 50% -220px, var(--accent-soft), transparent 72%);
    background-repeat: no-repeat;
}

.page {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 36px 20px 72px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------- Kepala halaman ---------- */

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.app-header__intro {
    flex: 1 1 260px;
    min-width: 0;
}

.app-header__title {
    margin: 0 0 6px;
    font-size: clamp(1.5rem, 4vw, 1.9rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.app-header__subtitle {
    margin: 0;
    max-width: 46ch;
    color: var(--muted);
    font-size: 0.94rem;
}

.stats {
    display: flex;
    gap: 10px;
    margin: 0;
}

.stats__item {
    min-width: 78px;
    padding: 10px 14px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.stats__item dt {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.stats__item dd {
    margin: 2px 0 0;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- Pesan ---------- */

.alerts {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.alert {
    margin: 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 500;
}

.alert--success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: currentColor;
}

.alert--error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: currentColor;
}

/* ---------- Form tambah ---------- */

.panel {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.add-form {
    display: flex;
    gap: 10px;
}

.add-form input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 13px 16px;
    font: inherit;
    color: inherit;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .16s ease, box-shadow .16s ease;
}

.add-form input[type="text"]::placeholder {
    color: var(--muted);
}

.add-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Tombol ---------- */

.btn {
    font: inherit;
    font-weight: 600;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.btn--primary {
    color: #ffffff;
    background-image: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 8px 20px rgba(79, 70, 229, .28);
}

.btn--primary:hover {
    background-image: linear-gradient(135deg, #5b54f0, #4338ca);
}

.btn--primary:active {
    transform: translateY(1px);
}

.btn--ghost {
    color: var(--muted);
    background: transparent;
    border-color: var(--border);
}

.btn--ghost:hover {
    color: var(--danger-text);
    border-color: currentColor;
    background: var(--danger-bg);
}

.btn-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: color .16s ease, background-color .16s ease, border-color .16s ease;
}

.btn-icon:hover {
    color: var(--danger-text);
    background: var(--danger-bg);
    border-color: currentColor;
}

/* ---------- Filter ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0 12px;
}

.filter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}

.filter:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.filter.is-active {
    color: #ffffff;
    background-image: linear-gradient(135deg, #6366f1, #4f46e5);
    border-color: transparent;
}

.filter__count {
    padding: 1px 8px;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    background: var(--surface-soft);
    border-radius: 999px;
    color: inherit;
}

.filter.is-active .filter__count {
    background: rgba(255, 255, 255, .22);
    color: #ffffff;
}

/* ---------- Daftar tugas ---------- */

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

.card--list {
    overflow: hidden;
}

.task-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.task {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background-color .16s ease;
}

.task:last-child {
    border-bottom: 0;
}

.task:hover {
    background: var(--surface-soft);
}

.task__form {
    display: flex;
    margin: 0;
}

.task__body {
    flex: 1 1 auto;
    min-width: 0;
}

.task__title {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.task__meta {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.task.is-done .task__title {
    font-weight: 500;
    color: var(--muted);
    text-decoration: line-through;
}

.check {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    color: #ffffff;
    background: transparent;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, transform .12s ease;
}

.check:hover {
    border-color: var(--fill);
}

.check:active {
    transform: scale(.94);
}

.check__icon {
    font-size: 15px;
    line-height: 1;
}

.task.is-done .check {
    background: var(--fill);
    border-color: var(--fill);
}

/* ---------- Keadaan kosong & aksi tambahan ---------- */

.empty {
    margin: 0;
    padding: 40px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}

.actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ---------- Responsif ---------- */

@media (max-width: 560px) {
    .page {
        padding: 26px 16px 56px;
    }

    .app-header {
        align-items: flex-start;
    }

    .stats {
        width: 100%;
    }

    .stats__item {
        flex: 1 1 0;
    }

    .add-form {
        flex-direction: column;
    }

    .btn--primary {
        width: 100%;
    }

    .actions {
        justify-content: stretch;
    }

    .actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}