/* webgras Aufgabenmanagement — single stylesheet, system fonts, no CDN. */

:root {
    --green: #3a7d2c;
    --green-dark: #2f6624;
    --green-light: #e8f3e4;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1c2430;
    --muted: #5a6572;
    --border: #dde2e8;
    --highlight: #fff3c2;
    --error: #c62828;
    --error-bg: #fdecea;
    --success: #2e7d32;
    --success-bg: #e8f5e9;
    --warn-bg: #fff8e1;
    --warn-border: #f0c36d;
    --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--green-dark); }
a:hover { color: var(--green); }

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }

code { background: #eef1f4; padding: .1rem .3rem; border-radius: 4px; font-size: .85em; }

/* ---------------------------------------------------------- top bar --- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    min-height: 56px;
}
.brand {
    font-weight: 700;
    color: var(--green);
    text-decoration: none;
    font-size: 1.05rem;
}
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a {
    text-decoration: none;
    color: var(--text);
    padding: .4rem .65rem;
    border-radius: 6px;
    font-size: .92rem;
}
.mainnav a:hover { background: var(--green-light); }
.mainnav a.nav-new { color: var(--green-dark); font-weight: 600; }
.nav-search { margin-left: auto; }
.nav-search input {
    padding: .4rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: .9rem;
    width: 180px;
}
.nav-user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.nav-user a { display: flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--text); }
.nav-user .nav-logout { color: var(--muted); }

.avatar { border-radius: 50%; vertical-align: middle; object-fit: cover; }
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
}

/* ------------------------------------------------------------- page --- */
.page { max-width: 1400px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* Large screens: use (almost) the full browser width */
@media (min-width: 1200px) {
    .page, .topbar-inner { max-width: none; width: 95%; }
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; }
.card-narrow { max-width: 800px; margin-left: auto; margin-right: auto; }

.banner {
    padding: .6rem .9rem;
    border-radius: 6px;
    margin: .5rem 0;
    font-size: .92rem;
}
.banner-error { background: var(--error-bg); color: var(--error); }
.banner-success { background: var(--success-bg); color: var(--success); }
.banner-info { background: #e3f2fd; color: #1565c0; }
.banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #7a5b00; }

.empty { color: var(--muted); font-style: italic; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 .75rem; }
.ok { color: var(--success); }

/* ---------------------------------------------------------- buttons --- */
.btn {
    display: inline-block;
    background: var(--green);
    color: #fff;
    border: 0;
    padding: .5rem 1rem;
    border-radius: 6px;
    font: inherit;
    font-size: .92rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--green-dark); color: #fff; }
.btn-secondary { background: #ffffff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-small { padding: .25rem .6rem; font-size: .82rem; }
.icon-btn {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: .95rem;
    padding: .2rem .3rem;
    border-radius: 4px;
}
.icon-btn:hover { background: var(--green-light); }

/* ------------------------------------------------------------ forms --- */
label { display: block; margin-bottom: .8rem; font-size: .9rem; font-weight: 600; }
input:not([type="checkbox"]), select, textarea {
    display: block;
    width: 100%;
    margin-top: .3rem;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-weight: 400;
    background: #fff;
    color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: 0;
    border-color: var(--green);
}
fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 0 0 .8rem;
}
legend { font-size: .85rem; font-weight: 600; padding: 0 .35rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
}

/* Single-column form (e.g. new task) */
.form-stack { display: block; }

.filter-check {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: 400;
    cursor: pointer;
}
.filter-check input { margin: 0; }
.check-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }

.filterbar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}
.filterbar label { margin: 0; }
.filterbar input, .filterbar select { margin-top: .25rem; width: auto; min-width: 160px; }
/* The "wichtig" checkbox looks like the other controls and lines up with them */
.filterbar .filter-check {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: .45rem .7rem;
    font-size: .9rem;
}
.filterbar .filter-check input { min-width: 0; margin: 0; }
.filterbar .filter-check:has(input:checked) {
    background: var(--green-light);
    border-color: var(--green);
}

.filter-field { }
.filter-label {
    display: block;
    font-size: .9rem;
    font-weight: 600;
}
.hint-inline { font-weight: 400; color: var(--muted); font-size: .8rem; }

/* Checkbox pills (multi-select status filter) */
.pill-group { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .35rem; }
.pill {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    padding: .3rem .7rem;
    font-size: .85rem;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
}
.pill input { margin: 0; min-width: 0; }
.pill:has(input:checked) {
    background: var(--green-light);
    border-color: var(--green);
    font-weight: 600;
}

/* ----------------------------------------------------------- tables --- */
.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
    text-align: left;
    padding: .55rem .6rem;
    background: #f7f9fa;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--muted);
}
.data-table td {
    padding: .45rem .6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tr:last-child td { border-bottom: 0; }

/* Sortable column headers */
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: " ↕"; color: #b6bec8; }
th[data-sort]:hover { color: var(--text); }
th[data-sort].sort-asc::after { content: " ↑"; color: var(--green); }
th[data-sort].sort-desc::after { content: " ↓"; color: var(--green); }

/* Admin dashboard */
.dashboard-table .col-dash { white-space: nowrap; }

.col-important { width: 2rem; text-align: center; }
.col-check { width: 3.4rem; text-align: center; }
.col-actions { width: 2.5rem; text-align: center; }
.col-date { white-space: nowrap; }
.col-num { text-align: right; width: 4rem; }
.col-task { min-width: 220px; }
.col-comments { min-width: 160px; max-width: 260px; }
.col-status select { width: auto; }
.col-progress { min-width: 140px; }

.row-important td { background: #fffaf0; }
.row-inactive td { opacity: .55; }
.row-status-abgeschlossen .col-task .cell-display { text-decoration: line-through; color: var(--muted); }

.pre-line { white-space: pre-line; }
.clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Deep-link highlight (CSS only, via #task-<id> anchor) */
tr:target td {
    background: var(--highlight) !important;
    transition: background .3s;
}

/* Editable cells */
[data-field][data-type] { cursor: pointer; }
/* The edit pencil always occupies its space (transparent when idle) so
   hovering does not shift the cell content. */
[data-field][data-type] .cell-display::after {
    content: " ✎";
    color: transparent;
    font-size: .8em;
}
[data-field][data-type]:hover .cell-display::after {
    color: var(--muted);
}
[data-field].editing { cursor: default; }
.editor-wrap input, .editor-wrap textarea, .editor-wrap select {
    margin-top: 0;
    min-width: 160px;
    font-size: .9rem;
}
.editor-wrap textarea { min-width: 240px; }

@keyframes savedFlash {
    0% { background: #c9e7bd; }
    100% { background: transparent; }
}
.saved-flash { animation: savedFlash 1.2s ease-out; }

/* Status badges + colored selects */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    white-space: nowrap;
    background: #eceff3;
}
select.status-select {
    border-radius: 999px;
    padding: .2rem 1.6rem .2rem .6rem;
    font-size: .82rem;
    width: auto;
}
.status-nicht_gestartet { background: #eceff3; color: #444d57; }
.status-in_bearbeitung { background: #e3f2fd; color: #1565c0; }
.status-warten_auf { background: #fff3e0; color: #b26a00; }
.status-zu_besprechen { background: #f3e5f5; color: #7b1fa2; }
.status-abgeschlossen { background: var(--success-bg); color: var(--success); }
.project-status-offen { background: #e3f2fd; color: #1565c0; }
.project-status-abgeschlossen { background: var(--success-bg); color: var(--success); }

.important-mark { color: var(--error); }

/* --------------------------------------------------------- progress --- */
.progress {
    background: #e6eaee;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    min-width: 90px;
}
.progress-bar { background: var(--green); height: 100%; border-radius: 999px; }
.progress-label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.project-progress { display: flex; align-items: center; gap: .6rem; }

/* ----------------------------------------------------- project meta --- */
.meta-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .4rem 1.25rem;
    margin: 1rem 0 0;
}
.meta-grid dt { font-weight: 600; font-size: .88rem; color: var(--muted); padding-top: .1rem; }
.meta-grid dd { margin: 0; }
@media (max-width: 600px) {
    .meta-grid { grid-template-columns: 1fr; gap: 0; }
    .meta-grid dt { margin-top: .5rem; }
}

/* ------------------------------------------------------------ login --- */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { color: var(--green); margin-bottom: 1rem; }
.login-card .btn { width: 100%; margin-top: .5rem; }

/* ---------------------------------------------------------- profile --- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}
.profile-grid .card { margin-bottom: 0; }

/* ------------------------------------------------------------ misc --- */
.result-list { list-style: none; padding: 0; }
.result-list li { padding: .45rem 0; border-bottom: 1px solid var(--border); }

.toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translate(-50%, 20px);
    background: var(--text);
    color: #fff;
    padding: .6rem 1.1rem;
    border-radius: 8px;
    font-size: .9rem;
    opacity: 0;
    transition: all .3s;
    z-index: 100;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--error); }
.toast-success { background: var(--success); }
