/* ============================================================
   "Meine Aufgaben" – Styles
   ============================================================ */

:root {
    --accent: #0078d4;
    --accent-dark: #005f9e;
    --danger: #d6336a;
    --ok: #0f9d58;
    --radius: 10px;
}

html[data-theme="light"] {
    --bg: #f2f4f7;
    --sidebar-bg: #ffffff;
    --card: #ffffff;
    --text: #1b1b1f;
    --text-dim: #6b6f76;
    --hover: #eef1f5;
    --active-bg: #e3f0fb;
    --border: #e2e5ea;
    --input-bg: #ffffff;
    --shadow: 0 8px 24px rgba(0, 0, 0, .12);
    --badge-bg: #f0f2f5;
}

html[data-theme="dark"] {
    --bg: #1d2126;
    --sidebar-bg: #23272e;
    --card: #2a2f37;
    --text: #e8eaed;
    --text-dim: #9aa1ab;
    --hover: #31373f;
    --active-bg: #24394d;
    --border: #3a404a;
    --input-bg: #23272e;
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    --badge-bg: #333a43;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

#app.app { display: flex; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 30;
}

.side-top { padding: 18px 16px 10px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand img { border-radius: 6px; }
.brand-name { font-size: 15px; }

.nav { flex: 1; overflow-y: auto; padding: 4px 8px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    text-align: left;
    color: var(--text);
    margin-bottom: 2px;
    position: relative;
}
.nav-item .nav-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    color: var(--text-dim);
}
.nav-item .nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14.5px;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active {
    background: var(--active-bg);
    font-weight: 600;
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--accent);
}
.nav-item.active .nav-ico { color: var(--accent); }

.nav-important .nav-ico { color: var(--danger) !important; }

.nav-list .nav-ico { font-size: 17px; }
.nav-list .nav-ico::before { content: attr(data-icon); }

.nav-sep { border: none; border-top: 1px solid var(--border); margin: 10px 12px; }

.nav-add { color: var(--accent); font-weight: 500; }
.nav-add .nav-ico { color: var(--accent); }

.side-bottom { padding: 10px 12px 14px; border-top: 1px solid var(--border); }

.side-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    text-align: left;
    font-size: 14px;
    color: var(--text-dim);
}
.side-btn:hover { background: var(--hover); color: var(--text); }
.side-btn svg { flex-shrink: 0; }

.user-btn { margin-top: 2px; }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------- Main ---------- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.main-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 26px 10px;
}
.main-head h1 { font-size: 22px; font-weight: 650; margin: 0; white-space: nowrap; }
.head-count {
    font-size: 13px;
    color: var(--text-dim);
    background: var(--badge-bg);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.menu-btn {
    display: none;
    font-size: 20px;
    width: 38px; height: 38px;
    border-radius: 8px;
}
.menu-btn:hover { background: var(--hover); }

.search-wrap {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--badge-bg);
    border-radius: 8px;
    padding: 7px 12px;
    max-width: 280px;
    flex: 1;
}
.search-wrap .search-ico { color: var(--text-dim); display: inline-flex; }
.search-wrap input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    color: var(--text);
}

.list-scroll { flex: 1; overflow-y: auto; padding: 4px 26px 30px; }

/* ---------- Add row ---------- */

.add-row-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 14px;
    padding: 9px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.add-row-inner .add-btn {
    color: var(--accent);
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
}
.add-row-inner .add-btn:hover { background: var(--hover); }
.add-row-inner input { border: none; background: none; outline: none; flex: 1; color: var(--text); }

/* ---------- Task rows ---------- */

.task-list { display: flex; flex-direction: column; }

.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 2px;
    cursor: pointer;
    background: var(--card);
    border: 1px solid var(--border);
}
.task-row:hover { background: var(--hover); }
.task-row.overdue .task-title { color: var(--danger); }

.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.task-title {
    font-size: 14.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }

.check {
    width: 26px; height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    border-radius: 50%;
    flex-shrink: 0;
}
.check:hover { background: var(--hover); color: var(--accent); }
.task-row.done .check { color: var(--ok); }
.task-row.done .check svg circle { fill: var(--ok); stroke: var(--ok); }
.task-row.done .check svg path { stroke: #fff; }

.task-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--badge-bg);
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.badge.due.today { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.badge.due.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); font-weight: 600; }
.badge.prio { color: var(--text-dim); }
.badge.prio.high { color: var(--danger); }
.badge.bell.late { color: var(--danger); }
.badge.listchip { color: var(--chip-color, var(--text-dim)); }

/* Section headers */
.section-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 16px 12px 6px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.section-head .section-sub { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12.5px; }

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 0;
    font-size: 14px;
}

.footer-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px;
    margin: 8px 0;
    border-radius: 8px;
    color: var(--accent);
    font-size: 13.5px;
}
.footer-btn:hover { background: var(--hover); }
.footer-btn.danger { color: var(--danger); }
.footer-btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ---------- Detail panel ---------- */

.detail {
    position: fixed;
    top: 0; right: 0;
    height: 100dvh;
    width: 400px;
    max-width: 100vw;
    background: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 18px 20px 24px;
    overflow-y: auto;
    z-index: 40;
    animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.detail-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-dim);
}
.detail-close:hover { background: var(--hover); color: var(--text); }

.detail-title {
    width: 100%;
    font-size: 20px;
    font-weight: 600;
    border: none;
    background: none;
    outline: none;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text);
    margin-right: 30px;
}
.detail-title:focus { background: var(--hover); }
.detail-title.done { text-decoration: line-through; color: var(--text-dim); }

.detail-done {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    font-size: 13.5px;
    color: var(--text-dim);
    cursor: pointer;
}
.detail-done input { width: 16px; height: 16px; accent-color: var(--ok); }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    padding: 10px 0 14px;
    border-bottom: 1px solid var(--border);
}

.detail-field { display: flex; flex-direction: column; gap: 5px; }
.detail-field label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.detail-field input, .detail-field select {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--input-bg);
    outline: none;
    width: 100%;
}
.detail-field input:focus, .detail-field select:focus { border-color: var(--accent); }

.detail-toggle { display: flex; align-items: center; gap: 8px; padding-top: 4px; cursor: pointer; }
.detail-toggle input { accent-color: var(--accent); }

.detail-section-label {
    display: block;
    font-size: 12px;
    font-weight: 650;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 18px 0 8px;
}

.detail-notes {
    width: 100%;
    min-height: 90px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--input-bg);
    padding: 9px;
    outline: none;
}
.detail-notes:focus { border-color: var(--accent); }

.subtask-list { list-style: none; margin: 0 0 8px; padding: 0; }
.subtask {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 4px;
    border-radius: 6px;
}
.subtask:hover { background: var(--hover); }
.subtask input { accent-color: var(--ok); width: 15px; height: 15px; }
.subtask span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.subtask.done span { text-decoration: line-through; color: var(--text-dim); }
.subtask-del {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    color: var(--text-dim);
    opacity: 0;
}
.subtask:hover .subtask-del { opacity: 1; }
.subtask-del:hover { background: var(--badge-bg); color: var(--danger); }

.subtask-add {
    width: 100%;
    border: 1px dashed var(--border);
    background: none;
    border-radius: 7px;
    padding: 7px 9px;
    outline: none;
    color: var(--text);
}
.subtask-add:focus { border-color: var(--accent); }

.detail-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.detail-created { font-size: 12px; color: var(--text-dim); }
.detail-delete {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--danger);
    padding: 7px 12px;
    border-radius: 7px;
    font-size: 13.5px;
}
.detail-delete:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ---------- Listen-Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    padding: 20px;
}
.modal {
    background: var(--card);
    border-radius: 14px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 14px; font-size: 18px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.emoji-btn {
    font-size: 19px;
    padding: 5px;
    border-radius: 8px;
}
.emoji-btn:hover { background: var(--hover); }
.emoji-btn.selected { background: var(--active-bg); outline: 2px solid var(--accent); }

.modal-name {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    outline: none;
    margin-bottom: 12px;
}
.modal-name:focus { border-color: var(--accent); }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.color-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
}
.color-btn.selected { outline: 2px solid var(--text); outline-offset: 2px; }

.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-delete {
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 8px;
    margin-right: auto;
}
.modal-delete:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.modal-cancel, .modal-ok { padding: 8px 14px; border-radius: 8px; }
.modal-cancel { color: var(--text-dim); }
.modal-cancel:hover { background: var(--hover); }
.modal-ok { background: var(--accent); color: #fff; font-weight: 600; }
.modal-ok:hover { background: var(--accent-dark); }

/* ---------- Toasts ---------- */

#toast-root {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}
.toast {
    background: #1b1b1f;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(12px);
    transition: all .25s ease;
    box-shadow: var(--shadow);
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 34px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-logo { border-radius: 12px; }
.login-card h1 { font-size: 22px; margin: 14px 0 6px; }
.login-sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 20px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    font-size: 13px;
    color: var(--text-dim);
}
#login-form input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    outline: none;
}
#login-form input:focus { border-color: var(--accent); }
#login-form button {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 11px;
    border-radius: 8px;
    margin-top: 4px;
}
#login-form button:hover { background: var(--accent-dark); }
.login-hint { color: var(--text-dim); font-size: 12.5px; margin-top: 16px; }
.login-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ---------- DB Banner & misc ---------- */

.db-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #fff3cd;
    color: #7a5c00;
    border-bottom: 1px solid #ffe08a;
    padding: 9px 16px;
    font-size: 14px;
    z-index: 5;
}
.db-banner code { background: rgba(0,0,0,.08); padding: 1px 5px; border-radius: 4px; }
.db-banner a { color: var(--accent); font-weight: 600; }

.noscript { position: fixed; bottom: 10px; left: 10px; font-size: 13px; }

.logout-pop {
    position: fixed;
    bottom: 14px;
    left: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 70;
}
.logout-pop button { padding: 10px 16px; color: var(--danger); }
.logout-pop button:hover { background: var(--hover); }

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }
    #app.nav-open .sidebar { transform: none; }
    #app.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 25;
    }
    .menu-btn { display: inline-flex; }
    .main { margin-left: 0; }
    .main-head { padding: 12px 16px 8px; flex-wrap: wrap; }
    .main-head h1 { font-size: 19px; }
    .search-wrap { max-width: none; }
    .list-scroll { padding: 4px 14px 24px; }
    .detail { width: 100vw; border-left: none; }
    .detail-grid { grid-template-columns: 1fr; }
}
