/* Bosbach Gamification — Stylesheet.
 *
 * Dunkles, hochwertiges Grundthema mit sommerlichem Akzent (Kampagne
 * "Attacke auf den Sommer"). Alles ueber Variablen, damit das finale
 * Corporate Design (Feinkonzept Kap. 27) zentral eingetauscht werden kann.
 */

:root {
    --bg:           #0b0d12;
    --bg-raised:    #141824;
    --bg-input:     #0f1219;
    --border:       #262c3d;
    --text:         #eef1f7;
    --text-muted:   #97a0b5;
    --accent:       #ff9f1c;   /* Sommer-Orange — wird durch CD ersetzt */
    --accent-hover: #ffb347;
    --accent-text:  #1a1200;
    --accent-soft:  rgba(255, 159, 28, .12);
    --success:      #2ec27e;
    --error:        #ff5c5c;
    --radius:       12px;
    --shadow:       0 8px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
}

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--accent); }

.muted  { color: var(--text-muted); }
.small  { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.hint   { color: var(--text-muted); font-size: .85rem; margin: -.25rem 0 1rem; }
.muted-link { color: var(--text-muted); }

.page-title    { margin-bottom: .25rem; }
.section-title { margin-top: 2rem; font-size: 1.05rem; color: var(--text-muted); }
.back-link     { display: inline-block; margin-bottom: .75rem; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--text); }

/* ---------- Kopfleiste ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: .7rem 1.25rem;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand { display: flex; align-items: center; }
.brand img { height: 26px; width: auto; display: block; }

.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: .4rem .8rem;
    border-radius: 8px;
    white-space: nowrap;
}
.nav a:hover  { color: var(--text); }
.nav a.active { color: var(--text); background: rgba(255, 255, 255, .06); }

.nav-toggle { display: none; }

.user-menu { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

.user-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
    text-decoration: none;
    font-size: .95rem;
}
.user-chip img,
.avatar-fallback {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .75rem;
    font-weight: 700;
}

.inline { display: inline; }

.link-btn {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit; font-size: .95rem;
    padding: .4rem .5rem;
}
.link-btn:hover { color: var(--text); }

/* ---------- Hauptbereich ---------- */

.main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.main-bare {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem;
    flex-direction: column;
}

.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card.slim { padding: 1rem 1.25rem; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
.card-head h1, .card-head h2 { margin-bottom: 0; }

.empty { text-align: center; padding: 2rem 1rem; }
.empty h1 { font-size: 2.5rem; }
.empty-emoji { font-size: 2.5rem; margin-bottom: .25rem; }

.form-grid { display: grid; gap: 1.25rem; }

/* ---------- Anmeldung ---------- */

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-logo-img {
    display: block;
    margin: 0 auto .75rem;
    width: 180px; max-width: 100%; height: auto;
}
.auth-claim {
    color: var(--accent);
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-size: .8rem;
}
.auth-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 1.25rem; }

/* ---------- Formulare ---------- */

.field { display: block; margin-bottom: 1rem; min-width: 0; }
.field span {
    display: block;
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: .35rem;
}
.field input, .field select, .field textarea,
.filter-bar input, .filter-bar select {
    width: 100%;
    padding: .6rem .8rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus,
.filter-bar input:focus, .filter-bar select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}
.field input[type="date"] { color-scheme: dark; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.field-row .field { min-width: 0; }

.filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-bar input[type="search"] { flex: 2; min-width: 180px; }
.filter-bar select { flex: 1; min-width: 140px; width: auto; }
.filter-bar.compact { margin-bottom: .75rem; }

.checkbox-list { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.checkbox-list.scrollable {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .75rem;
}
.checkbox { display: flex; align-items: center; gap: .5rem; cursor: pointer; flex-wrap: wrap; }
.checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: .6rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--text-muted); }
.btn-danger { background: transparent; color: var(--error); border-color: rgba(255, 92, 92, .4); }
.btn-danger:hover { border-color: var(--error); }
.btn-sm    { padding: .35rem .75rem; font-size: .875rem; }
.btn-big   { padding: .9rem 1.5rem; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; }

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    padding: .25rem .55rem;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text-muted); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.action-stack { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.action-stack.horizontal { flex-direction: row; flex-wrap: wrap; }

/* ---------- Flash-Meldungen ---------- */

.flash {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.flash-success, .flash-celebrate {
    background: rgba(46, 194, 126, .12);
    border-color: rgba(46, 194, 126, .4);
    color: var(--success);
}
.flash-celebrate {
    background: var(--accent-soft);
    border-color: rgba(255, 159, 28, .5);
    color: var(--accent);
    font-weight: 600;
    font-size: 1.05rem;
}
.flash-error {
    background: rgba(255, 92, 92, .12);
    border-color: rgba(255, 92, 92, .4);
    color: var(--error);
}
.main-bare .flash { width: 100%; max-width: 400px; }

.confetti-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
}

/* ---------- Status-Badges ---------- */

.badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
}
.badge-active       { background: rgba(46, 194, 126, .15); color: var(--success); }
.badge-grace_period { background: var(--accent-soft); color: var(--accent); }
.badge-scheduled    { background: rgba(94, 178, 255, .15); color: #5eb2ff; }
.badge-finished     { background: rgba(151, 160, 181, .15); color: var(--text-muted); }
.badge-draft        { background: rgba(151, 160, 181, .15); color: var(--text-muted); }
.badge-inactive     { background: rgba(255, 92, 92, .15); color: var(--error); }
.badge-user-active   { background: rgba(46, 194, 126, .15); color: var(--success); }
.badge-user-invited  { background: rgba(94, 178, 255, .15); color: #5eb2ff; }
.badge-user-inactive { background: rgba(255, 92, 92, .15); color: var(--error); }

/* ---------- Challenge-Karten (Teilnehmer-Start) ---------- */

.challenge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}
.challenge-grid.single { grid-template-columns: 1fr; }

.challenge-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: linear-gradient(145deg, var(--bg-raised), #1a1f30);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .12s ease, border-color .12s ease;
}
.challenge-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.challenge-card.state-active,
.challenge-card.state-grace_period {
    border-color: rgba(255, 159, 28, .45);
    background: linear-gradient(145deg, #1c1607 0%, var(--bg-raised) 55%);
}
.challenge-card h3 { margin: 0; font-size: 1.2rem; }
.challenge-card .btn { align-self: flex-start; margin-top: .5rem; }
.challenge-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.challenge-dates { color: var(--text-muted); font-size: .85rem; }
.challenge-card-stats {
    display: flex;
    gap: 1.25rem;
    color: var(--text-muted);
    font-size: .9rem;
}
.challenge-card-stats strong { color: var(--accent); font-size: 1.05rem; }

/* ---------- Challenge-Hero (Detailseite) ---------- */

.challenge-hero {
    background:
        radial-gradient(ellipse at 85% -20%, rgba(255, 159, 28, .35), transparent 55%),
        linear-gradient(145deg, #1a1f30, var(--bg-raised));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.challenge-hero h1 { font-size: 1.75rem; margin: .5rem 0 .25rem; }
.hero-subtitle { color: var(--accent); font-weight: 600; margin-bottom: .25rem; }
.hero-meta { color: var(--text-muted); margin: 0; }

/* ---------- Stat-Karten ---------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-row.wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}
.stat-label { color: var(--text-muted); font-size: .85rem; }

/* ---------- Rangliste ---------- */

.ranking { list-style: none; margin: 0 0 1rem; padding: 0; }
.ranking-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .6rem;
    border-radius: 8px;
}
.ranking-row + .ranking-row { margin-top: 2px; }
.ranking-row:nth-child(odd) { background: rgba(255, 255, 255, .025); }
.ranking-row.is-me {
    background: var(--accent-soft);
    outline: 1px solid rgba(255, 159, 28, .4);
}
.ranking-rank {
    width: 2rem;
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}
.ranking-row.is-top .ranking-rank { font-size: 1.15rem; }
.ranking-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.ranking-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ranking-name em { color: var(--accent); font-style: normal; font-size: .85rem; }
.ranking-points { font-weight: 700; color: var(--accent); white-space: nowrap; }
.ranking-points small { color: var(--text-muted); font-weight: 400; }

/* ---------- Eigene Eintraege ---------- */

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.entry-row:last-child { border-bottom: none; }
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-title { font-weight: 600; }
.entry-meta { color: var(--text-muted); font-size: .82rem; }
.entry-points { color: var(--success); font-weight: 700; white-space: nowrap; }

/* ---------- Erfassung (Wizard) ---------- */

.wizard fieldset {
    border: none;
    margin: 0 0 1.5rem;
    padding: 0;
}
.wizard legend {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.step-nr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .9rem;
}
.milestone-picker { display: grid; gap: .5rem; }
.milestone-option input { position: absolute; opacity: 0; }
.milestone-box {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .75rem 1rem;
    cursor: pointer;
    transition: border-color .1s ease, background .1s ease;
}
.milestone-option input:checked + .milestone-box {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.milestone-option input:focus-visible + .milestone-box { outline: 2px solid var(--accent); }
.milestone-title { font-weight: 600; }
.milestone-desc { color: var(--text-muted); font-size: .85rem; }
.milestone-points { color: var(--accent); font-weight: 700; font-size: .9rem; }
.wizard-summary { font-size: 1rem; }

/* ---------- Tabellen (Admin) ---------- */

.table-card { padding: 1rem 1.25rem; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: .6rem;
    border-bottom: 1px solid rgba(38, 44, 61, .6);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

.pagination { display: flex; gap: .25rem; margin: 1rem 0 .5rem; flex-wrap: wrap; }
.pagination a {
    padding: .3rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
}
.pagination a.current { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- Admin-Bausteine ---------- */

.link-box {
    background: var(--accent-soft);
    border: 1px solid rgba(255, 159, 28, .5);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.link-box-row { display: flex; gap: .5rem; margin: .5rem 0; }
.link-box-row input {
    flex: 1;
    padding: .5rem .75rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: .85rem;
    min-width: 0;
}
.link-box .hint { margin: 0; }

.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px solid rgba(38, 44, 61, .6);
    flex-wrap: wrap;
}
.member-list li:last-child { border-bottom: none; }

.milestone-admin-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.milestone-admin-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .75rem 0;
    border-bottom: 1px solid rgba(38, 44, 61, .6);
}
.milestone-admin-row:last-child { border-bottom: none; }
.milestone-admin-row.is-inactive .milestone-admin-main { opacity: .55; }
.milestone-admin-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.milestone-edit-form {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-top: .5rem;
}

.add-box summary { list-style: none; display: inline-block; }
.add-box summary::-webkit-details-marker { display: none; }
.add-box[open] summary { display: none; }

.assign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

.avatar-block { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-preview {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    font-size: 1.5rem;
}

/* ---------- Responsiv ---------- */

@media (min-width: 900px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid > .table-card:only-child, .form-grid > .card.wide { grid-column: 1 / -1; }
}

@media (max-width: 899px) {
    .assign-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .topbar { flex-wrap: wrap; gap: .5rem; }

    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        margin-left: auto;
        background: none;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: .5rem .6rem;
        cursor: pointer;
    }
    .nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); }

    .nav { display: none; order: 4; width: 100%; flex-direction: column; }
    body.nav-open .nav { display: flex; }
    .nav a { padding: .6rem .8rem; }

    .user-menu { margin-left: 0; order: 3; }
    .user-chip span:last-child { display: none; }

    .main { padding: 1rem 1rem 2.5rem; }
    .field-row { grid-template-columns: 1fr; gap: 0; }
    .stat-row { gap: .5rem; }
    .stat-card { padding: .75rem .5rem; }
    .stat-value { font-size: 1.25rem; }
    .challenge-hero { padding: 1.5rem 1.25rem; }
    .challenge-hero h1 { font-size: 1.4rem; }

    /* Tabellen werden zu Karten — keine horizontale Scrollpflicht (27.6). */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: .75rem;
        padding: .5rem .75rem;
    }
    .data-table td { border: none; padding: .25rem 0; }
    .data-table td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--text-muted);
        font-size: .8rem;
    }
    .data-table .num { text-align: left; }
    .row-actions { justify-content: flex-start; padding-top: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .challenge-card { transition: none; }
    .challenge-card:hover { transform: none; }
}
