/* ===================================================
   TodoApp – CSS Murni
   =================================================== */

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

:root {
    --primary:    #6366f1;
    --primary-h:  #4f46e5;
    --success:    #10b981;
    --warning:    #f59e0b;
    --danger:     #ef4444;
    --bg:         #f8fafc;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --muted:      #64748b;
    --radius:     10px;
    --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,.10);
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

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

/* ---------- Navbar ---------- */
.navbar { font-family: 'Inter', sans-serif; }

.brand-icon {
    background: var(--primary);
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}
.brand-text { font-size: 18px; font-weight: 700; color: var(--primary); }

.nav-user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px;
    flex-shrink: 0;
}
.nav-user-name  { font-size: 14px; font-weight: 600; color: #1e293b; line-height: 1.2; }
.nav-user-email { font-size: 11px; color: #94a3b8; }

.btn-logout {
    border: 1px solid #e2e8f0;
    background: transparent;
    color: #64748b;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
    display: flex; align-items: center; gap: 6px;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Main ---------- */
.main-content { max-width: 1280px; margin: 0 auto; padding: 24px; }

.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 20px; font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ---------- Auth ---------- */
.auth-body { background: linear-gradient(135deg, #e0e7ff 0%, #f0fdf4 100%); min-height: 100vh; }

.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 24px; padding: 24px;
}
.auth-brand { text-align: center; }
.auth-brand .brand-icon {
    width: 56px; height: 56px; font-size: 24px;
    margin-bottom: 12px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 16px;
}
.auth-brand h1 { font-size: 28px; font-weight: 700; color: var(--primary); }
.auth-brand p  { color: var(--muted); margin-top: 4px; }

.auth-card {
    background: var(--surface); border-radius: 16px;
    padding: 32px; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-md);
}
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--muted); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.required { color: var(--danger); }

.form-input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; color: var(--text);
    background: var(--surface); transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-input.is-invalid { border-color: var(--danger); }

.form-textarea { min-height: 80px; resize: vertical; }
.form-select   { padding: 8px 12px; }
.form-color    { padding: 4px 6px; height: 42px; cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
    font-family: inherit; cursor: pointer; border: 1px solid transparent;
    transition: all .15s; white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-h); border-color: var(--primary-h); }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover  { border-color: var(--primary); color: var(--primary); }
.btn-full     { width: 100%; }

.btn-icon {
    background: none; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: var(--primary);
    transition: background .15s;
}
.btn-icon:hover { background: #eef2ff; }

.btn-icon-sm {
    background: none; border: 1px solid var(--border);
    cursor: pointer; width: 26px; height: 26px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--muted); transition: all .15s;
}
.btn-icon-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-sm:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Page Layout ---------- */
.page-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); overflow: hidden;
    box-shadow: var(--shadow);
    position: sticky; top: 72px;
}

.stats-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1px; background: var(--border);
    border-bottom: 1px solid var(--border);
}
.stat-card {
    background: var(--surface); padding: 14px 10px; text-align: center;
}
.stat-num   { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.stat-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-pending .stat-num { color: var(--warning); }
.stat-done    .stat-num { color: var(--success); }
.stat-overdue .stat-num { color: var(--danger); }

.sidebar-section { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }

.sidebar-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidebar-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.filter-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.filter-link {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px;
    border-radius: 7px; color: var(--text); font-size: 13px; font-weight: 500;
    transition: background .15s; text-decoration: none;
}
.filter-link:hover { background: var(--bg); text-decoration: none; }
.filter-link.active { background: #eef2ff; color: var(--primary); }

.category-row {
    display: flex; align-items: center; justify-content: space-between;
    border-radius: 7px;
}
.category-row:hover { background: var(--bg); }
.category-row .filter-link { flex: 1; }
.cat-actions { display: flex; gap: 3px; padding-right: 4px; opacity: 0; transition: opacity .15s; }
.category-row:hover .cat-actions { opacity: 1; }

.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cat-count {
    margin-left: auto; background: var(--bg); color: var(--muted);
    font-size: 11px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}

/* ---------- Main Area ---------- */
.top-bar {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.search-wrap { flex: 1; min-width: 200px; }
.search-form { display: flex; gap: 0; }
.search-input {
    flex: 1; padding: 9px 12px; border: 1px solid var(--border);
    border-right: none; border-radius: 8px 0 0 8px; font-size: 14px;
    font-family: inherit; outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); }
.btn-search {
    padding: 9px 14px; background: var(--primary); color: #fff;
    border: 1px solid var(--primary); border-radius: 0 8px 8px 0;
    cursor: pointer; font-size: 14px;
}
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.form-select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; font-family: inherit; background: var(--surface);
    cursor: pointer; outline: none; color: var(--text);
}

/* ---------- Todo Cards ---------- */
.todo-list { display: flex; flex-direction: column; gap: 10px; }

.todo-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 14px 16px;
    display: flex; align-items: flex-start; gap: 14px;
    box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s;
}
.todo-card:hover { box-shadow: var(--shadow-md); }
.todo-done    { opacity: .7; }
.todo-overdue { border-left: 3px solid var(--danger); }

.todo-check {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--surface);
    cursor: pointer; flex-shrink: 0; font-size: 12px; font-weight: 700;
    color: #fff; display: flex; align-items: center; justify-content: center;
    transition: all .15s; margin-top: 1px;
}
.todo-check:hover  { border-color: var(--primary); }
.todo-check.checked { background: var(--success); border-color: var(--success); }
.toggle-form { display: flex; }

.todo-body { flex: 1; min-width: 0; }

.todo-header {
    display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
    margin-bottom: 4px;
}
.todo-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.strikethrough { text-decoration: line-through; color: var(--muted); }

.todo-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
    display: inline-flex; align-items: center; gap: 3px;
}
.badge-high   { background: #fee2e2; color: #991b1b; }
.badge-medium { background: #fef9c3; color: #92400e; }
.badge-low    { background: #d1fae5; color: #065f46; }
.badge-cat {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
    border: 1px solid; display: inline-block;
}

.todo-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }

.todo-meta { margin-top: 8px; font-size: 12px; }
.text-muted   { color: var(--muted); }
.text-overdue { color: var(--danger); font-weight: 500; }
.overdue-badge {
    background: var(--danger); color: #fff; font-size: 10px;
    padding: 1px 6px; border-radius: 10px; margin-left: 6px; font-weight: 600;
}

.todo-actions {
    display: flex; gap: 4px; flex-shrink: 0;
    opacity: 0; transition: opacity .15s;
}
.todo-card:hover .todo-actions { opacity: 1; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center; padding: 60px 24px;
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p  { color: var(--muted); }

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal {
    background: var(--surface); border-radius: 14px;
    width: 100%; max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
    animation: modal-in .2s ease;
}
.modal-sm { max-width: 360px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    width: 30px; height: 30px; border-radius: 6px;
    color: var(--muted); font-size: 16px; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body   { padding: 20px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 20px; border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .page-wrapper { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar { flex-direction: column; align-items: stretch; }
    .top-bar-right { flex-wrap: wrap; }
    .todo-actions { opacity: 1; }
    .cat-actions  { opacity: 1; }
}
