/* ============================================================
   Was macht Ibrahim? — Styles (mobile first)
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1220;
    --bg-card: #1a1f35;
    --bg-card-2: #222945;
    --border: #2e3654;
    --text: #eef1fb;
    --text-muted: #9aa3c0;
    --accent: #6c5ce7;
    --accent-2: #a29bfe;
    --ibrahim: #ff1e1e;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(1200px 600px at 80% -10%, #232a52 0%, var(--bg) 55%);
    color: var(--text);
    /* Alles auf eine Bildschirmhöhe — die Seite selbst scrollt nicht */
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: .9rem; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: rgba(15, 18, 32, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; gap: 10px;
}
.logo { font-size: 1.15rem; font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.me-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .82rem; font-weight: 600;
    padding: 5px 10px; border-radius: 999px;
    background: var(--bg-card-2); border: 1px solid var(--border);
    max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.me-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- Buttons ---------- */
.btn {
    font: inherit; cursor: pointer; border: none;
    border-radius: 10px; padding: 8px 14px;
    background: var(--bg-card-2); color: var(--text);
    transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.15); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8e7bff);
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(108, 92, 231, .4);
}
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-danger { background: #c0392b; font-weight: 600; }

/* ---------- Kalender-Navigation ---------- */
.calnav {
    max-width: 1100px; margin: 12px auto 6px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px; padding: 0 14px;
}
.calnav-left { display: flex; gap: 6px; }
.btn-nav { padding: 8px 12px; font-weight: 700; }
.btn-today { font-size: .85rem; }
.range-title { font-weight: 800; font-size: 1rem; flex: 1; text-align: center; min-width: 140px; }
.view-switch { display: flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.view-btn { border-radius: 0; background: transparent; font-size: .85rem; padding: 8px 12px; }
.view-btn.active { background: var(--accent); font-weight: 700; }

/* ---------- Kalender ---------- */
.calendar {
    flex: 1 1 auto; min-height: 0;
    width: 100%; max-width: 1100px;
    margin: 6px auto; padding: 0 14px;
    overflow: auto;
}

/* ---------- Zeitraster (Woche & Tag) ---------- */
.tg-scroll {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    height: 100%;
    overscroll-behavior: contain;
}
.tg { min-width: fit-content; }

.tg-head {
    display: flex;
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.tg-corner {
    position: sticky; left: 0; z-index: 12;
    width: 52px; flex: none;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    font-size: .66rem; color: var(--text-muted); font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    text-align: center; line-height: 1.2;
}
.tg-dayhead {
    flex: 1 1 0; min-width: 0;
    background: var(--bg-card);
    text-align: center; padding: 5px 2px 7px;
    font-size: .72rem; color: var(--text-muted); font-weight: 700;
    cursor: pointer; user-select: none;
}
.tg-dayhead .dnum {
    display: inline-flex; width: 28px; height: 28px; border-radius: 50%;
    align-items: center; justify-content: center;
    font-size: .95rem; font-weight: 800; color: var(--text); margin-top: 2px;
}
.tg-dayhead.today .dnum { background: var(--ibrahim); color: #fff; }

.tg-body { display: flex; position: relative; }
.tg-lines { position: absolute; inset: 0; pointer-events: none; }
.tg-line {
    position: absolute; left: 0; right: 0; height: 1px;
    background: var(--border);
}
.tg-gutter {
    position: sticky; left: 0; z-index: 5;
    width: 52px; flex: none;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
}
.tg-hour {
    height: 48px;
    font-size: .66rem; color: var(--text-muted);
    text-align: right; padding-right: 6px;
    transform: translateY(-7px);
}

.tg-col {
    flex: 1 1 0; min-width: 0;
    position: relative;
    height: 1152px; /* 24 Stunden × 48px */
    border-right: 1px solid var(--border);
    cursor: pointer;
}
.tg-col.today { background-color: rgba(255, 30, 30, .07); }
.tg-hourmark {
    position: absolute; left: 0; right: 0;
    background: rgba(255, 255, 255, .06);
    pointer-events: none;
}
.tg-nowline {
    position: absolute; left: 0; right: 0; height: 2px;
    background: #ff4d4d; z-index: 4; pointer-events: none;
}
.tg-nowline::before {
    content: ''; position: absolute; left: -1px; top: -3px;
    width: 8px; height: 8px; border-radius: 50%; background: #ff4d4d;
}

.tg-ev {
    position: absolute; z-index: 3; overflow: hidden; cursor: pointer;
    border-radius: 8px; padding: 3px 6px;
    color: #fff;
    border: 1px solid rgba(0, 0, 0, .35);
    font-size: .68rem; line-height: 1.3;
    transition: filter .15s;
}
.tg-ev:hover { filter: brightness(1.15); z-index: 6; }
.tg-ev .t { font-weight: 700; }
.tg-ev .nm {
    font-weight: 700; font-size: .62rem; opacity: .95;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-ev .z { opacity: .85; font-size: .62rem; }
.tg-ev .ibra {
    font-weight: 900; font-size: .56rem; text-transform: uppercase;
    letter-spacing: .3px;
}
.tg-ev.ev-ibrahim {
    background: var(--ibrahim) !important;
    box-shadow: 0 2px 12px rgba(255, 30, 30, .45);
}

/* Handy: alle 7 Tage passen auf den Schirm — Termine nur Farbe + Emoji + Name */
@media (max-width: 700px) {
    .tg-corner, .tg-gutter { width: 40px; }
    .tg-hour { padding-right: 4px; font-size: .6rem; }
    .tg-week .tg-ev .tx,
    .tg-week .tg-ev .z,
    .tg-week .tg-ev .ibra { display: none; }
    .tg-week .tg-ev { padding: 3px 1px; text-align: center; }
    .tg-week .tg-ev .em { font-size: .85rem; }
    .tg-week .tg-ev .nm { font-size: .55rem; }
}

/* User-Chip (Detail-Ansicht & Legende) */
.ev-user {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .74rem; font-weight: 700; margin-top: 5px;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(255, 255, 255, .06);
}
.ev-user .me-dot { width: 8px; height: 8px; }

/* ---------- Monatsansicht ---------- */
.month-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.month-dow {
    text-align: center; font-size: .72rem; font-weight: 700;
    color: var(--text-muted); padding: 4px 0; text-transform: uppercase;
}
.month-cell {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; min-height: 74px; padding: 4px;
    cursor: pointer; overflow: hidden;
}
.month-cell:hover { filter: brightness(1.15); }
.month-cell.other { opacity: .38; }
.month-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.month-num { font-size: .74rem; font-weight: 700; margin-bottom: 3px; }
.month-chip {
    font-size: .66rem; font-weight: 600;
    border-radius: 4px; padding: 1px 4px; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: var(--chip-color, #555); color: #fff;
}
.month-chip.chip-ibrahim { font-weight: 900; }
.month-more { font-size: .64rem; color: var(--text-muted); }
@media (max-width: 560px) {
    .month-cell { min-height: 58px; }
    .month-chip { font-size: .58rem; padding: 1px 2px; }
}

/* ---------- Legende (eine Zeile, seitlich scrollbar) ---------- */
.legend-wrap {
    flex: none;
    width: 100%; max-width: 1100px;
    margin: 0 auto; padding: 4px 84px 10px 14px; /* rechts Platz für den +-Knopf */
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
}
.legend-title { font-size: .8rem; color: var(--text-muted); white-space: nowrap; margin: 0; }
.legend {
    display: flex; flex-wrap: nowrap; gap: 8px;
    overflow-x: auto; min-width: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.legend::-webkit-scrollbar { display: none; }
.legend-item { flex: none; }
.legend-item {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .82rem; font-weight: 600;
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 5px 11px; border-radius: 999px;
}

/* ---------- FAB ---------- */
.fab {
    position: fixed; right: 18px; bottom: 18px; z-index: 45;
    width: 60px; height: 60px; border-radius: 50%;
    border: none; cursor: pointer;
    font-size: 1.9rem; line-height: 1; color: #fff;
    background: linear-gradient(135deg, var(--accent), #8e7bff);
    box-shadow: 0 8px 24px rgba(108, 92, 231, .55);
    transition: transform .12s;
}
.fab:hover { transform: scale(1.07); }

/* ---------- Modals ---------- */
.modal {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(5, 7, 15, .7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-box {
    position: relative;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
    padding: 22px;
}
.modal-box h2 { margin-bottom: 6px; font-size: 1.2rem; }
.modal-close {
    position: absolute; top: 10px; right: 12px;
    background: none; border: none; color: var(--text-muted);
    font-size: 1.1rem; cursor: pointer; padding: 6px;
}
.modal-box form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.modal-box label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.modal-box input, .modal-box select, .modal-box textarea {
    font: inherit; color: var(--text);
    background: var(--bg-card-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px; width: 100%;
}
.modal-box input:focus, .modal-box select:focus, .modal-box textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: #ff7675; font-size: .86rem; font-weight: 600; }

/* ---------- Detail-Ansicht ---------- */
.detail-cat { font-size: 2rem; }
.detail-title { font-size: 1.25rem; font-weight: 800; margin: 6px 0; word-break: break-word; }
.detail-row { display: flex; gap: 8px; margin: 8px 0; font-size: .92rem; color: var(--text-muted); word-break: break-word; }
.detail-actions { display: flex; gap: 8px; margin-top: 18px; }
.detail-actions .btn { flex: 1; }
.detail-ibra {
    font-weight: 900; text-transform: uppercase; letter-spacing: .4px;
    color: var(--ibrahim); font-size: .85rem; margin-bottom: 4px;
}

/* ---------- Userliste (Admin) ---------- */
.user-create { display: flex; gap: 8px; margin-top: 12px; }
.user-create input {
    flex: 1; min-width: 0;
    font: inherit; color: var(--text);
    background: var(--bg-card-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px;
}
.user-create input:focus { outline: none; border-color: var(--accent); }
.user-create .btn { flex: none; }
.user-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-row {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 12px;
}
.user-row .name { flex: 1; font-weight: 700; }
.user-row .btn { padding: 6px 10px; font-size: .8rem; }

/* ---------- Cookie-Banner ---------- */
.cookie-banner {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(5, 7, 15, .75); backdrop-filter: blur(5px);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 16px;
}
@media (min-width: 640px) { .cookie-banner { align-items: center; } }
.cookie-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    max-width: 420px; width: 100%; padding: 22px; text-align: center;
}
.cookie-emoji { font-size: 2.6rem; margin-bottom: 8px; }
.cookie-box p { font-size: .92rem; line-height: 1.5; color: var(--text-muted); }
.cookie-box strong { color: var(--text); font-size: 1.05rem; }
.cookie-btns { display: flex; gap: 10px; margin-top: 16px; }
.cookie-btns .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
    z-index: 70; max-width: 90vw;
    background: var(--bg-card-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 10px 18px;
    font-weight: 600; font-size: .9rem;
    box-shadow: var(--shadow);
    animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
