/* ══════════════════════════════════════════
   FrontFlow — app.css
   ══════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --bg:        #f6f6f8;
    --surface:   #ffffff;
    --surface2:  #f6f6f8;
    --surface3:  #eeeff2;
    --border:    rgba(0,0,0,0.08);
    --border2:   rgba(0,0,0,0.14);
    --text:      #0f0f14;
    --text-2:    #3c3c46;
    --text-3:    #8c8c9a;
    --accent:    #5b3df5;
    --accent-2:  #4028d8;
    --accent-s:  rgba(91,61,245,0.09);
    --prio-high: #dc2626;
    --prio-highs: rgba(220,38,38,0.08);
    --prio-mid:  #f97316;
    --prio-mids: rgba(249,115,22,0.09);
    --prio-low:  #8c8c9a;
    --prio-lows: rgba(140,140,154,0.08);
    --ok:        #22c55e;
    --ok-s:      rgba(34,197,94,0.09);
    --r:   16px;
    --rs:  12px;
    --rx:  8px;
    --hh:  54px;
    --nb:  62px;
    --sb:  env(safe-area-inset-bottom, 0px);
    --sh0: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
    --sh1: 0 2px 8px rgba(0,0,0,0.08);
    --sh2: 0 6px 20px rgba(0,0,0,0.10);
    --ease: cubic-bezier(.16,1,.3,1);
    --fd: 'Plus Jakarta Sans', system-ui, sans-serif;
}

body.dark {
    --bg:       #09090b;
    --surface:  #111113;
    --surface2: #18181b;
    --surface3: #222228;
    --border:   rgba(255,255,255,0.07);
    --border2:  rgba(255,255,255,0.12);
    --text:     rgba(255,255,255,0.92);
    --text-2:   rgba(255,255,255,0.54);
    --text-3:   rgba(255,255,255,0.30);
    --accent:   #7c6af8;
    --accent-2: #6655e8;
    --accent-s: rgba(124,106,248,0.12);
    --sh0: 0 1px 3px rgba(0,0,0,.35);
    --sh1: 0 2px 10px rgba(0,0,0,.45);
    --sh2: 0 6px 22px rgba(0,0,0,.55);
    color-scheme: dark;
}

/* ── Keyframes ── */
@keyframes fadeUp   { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:none} }
@keyframes toastIn  { from{opacity:0;transform:translateY(8px) scale(.96)} to{opacity:1;transform:none} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes pinBounce { 0%,100%{transform:scale(1)} 40%{transform:scale(.87)} 70%{transform:scale(1.07)} }
@keyframes shake    { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }
@keyframes sheetUp  { from{transform:translateY(24px);opacity:0} to{transform:none;opacity:1} }
@keyframes checkPop { 0%{transform:scale(0)} 60%{transform:scale(1.25)} 100%{transform:scale(1)} }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--fd);
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: calc(var(--nb) + var(--sb) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    width: min(360px, calc(100vw - 32px));
}
.toast-item {
    background: var(--text);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: var(--rs);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    animation: toastIn .28s var(--ease) both;
    box-shadow: var(--sh2);
}
.toast-item.error { background: #ef4444; color: #fff; }
.toast-item.ok    { background: #22c55e; color: #fff; }

/* ── Loading ── */
#loadingOverlay {
    position: fixed; inset: 0; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 8000;
}
.spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid var(--border2);
    border-top-color: var(--accent);
    animation: spin .7s linear infinite;
}

/* ══════════════════════════
   LOGIN
   ══════════════════════════ */
#loginView {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
}
.login-card {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--sh2);
    padding: 32px 28px;
    width: 100%; max-width: 360px;
    animation: fadeUp .35s var(--ease) both;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: .04em; color: var(--accent); }
.login-tagline { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.login-step { animation: fadeUp .28s var(--ease) both; }

.field-label {
    display: block; font-size: 12px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-3); margin-bottom: 6px; margin-top: 16px;
}
.field-label:first-child { margin-top: 0; }
.field-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--rs);
    padding: 10px 12px; font-size: 15px; color: var(--text);
    outline: none; transition: border-color .18s; appearance: none;
}
.field-input:focus { border-color: var(--accent); }
textarea.field-input { resize: vertical; min-height: 80px; }

.btn-primary {
    width: 100%; background: var(--accent); color: #fff;
    font-size: 15px; font-weight: 700; padding: 12px;
    border-radius: var(--rs); margin-top: 16px;
    transition: opacity .18s, transform .12s;
}
.btn-primary:active { transform: scale(.97); opacity: .9; }
.btn-back {
    width: 100%; color: var(--text-3); font-size: 14px; font-weight: 600;
    padding: 10px; margin-top: 8px; border-radius: var(--rs);
    transition: color .18s;
}
.btn-back:hover { color: var(--text-2); }

.staff-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-top: 4px; max-height: 280px; overflow-y: auto;
}
.staff-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--rs); padding: 12px; cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}
.staff-card:active { transform: scale(.97); }
.staff-card:hover  { background: var(--accent-s); border-color: var(--accent); }
.staff-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-s); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 700; color: var(--accent);
}
.staff-name { font-size: 15px; font-weight: 700; }
.staff-role { font-size: 12px; color: var(--text-3); }

.pin-name { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 20px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 24px; }
.pin-dots span {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--border2); transition: background .18s, transform .18s;
}
.pin-dots span.filled { background: var(--accent); transform: scale(1.1); }
.pin-dots.shake { animation: shake .35s ease; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--rs); padding: 18px 8px;
    font-size: 22px; font-weight: 700; color: var(--text);
    transition: background .12s, transform .1s;
}
.pin-pad button:active { transform: scale(.93); background: var(--accent-s); }
.pin-pad button.pin-empty { background: transparent; border-color: transparent; cursor: default; }
.pin-error { text-align: center; font-size: 13px; font-weight: 600; color: #ef4444; margin-top: 10px; min-height: 18px; }

/* ══════════════════════════
   APP SHELL
   ══════════════════════════ */
#appView { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.app-header {
    height: var(--hh); background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; flex-shrink: 0; z-index: 100;
}
.header-left  { display: flex; align-items: center; gap: 8px; }
.header-icon  { font-size: 22px; line-height: 1; }
.header-title { font-size: 17px; font-weight: 800; letter-spacing: .02em; color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 4px; }
.header-hotel {
    font-size: 12px; font-weight: 700; color: var(--text-3);
    max-width: 120px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; margin-right: 4px;
}
.icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; transition: background .15s;
}
.icon-btn:hover { background: var(--surface2); }

.tab-bar {
    display: flex; background: var(--surface);
    border-top: 1px solid var(--border);
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--nb) + var(--sb));
    padding-bottom: var(--sb); z-index: 100;
}
.tab {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; font-weight: 600;
    color: var(--text-3); transition: color .18s; padding-top: 6px;
}
.tab .tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent); }

.tab-content {
    flex: 1; overflow-y: auto;
    padding: 16px 16px calc(var(--nb) + var(--sb) + 8px);
    -webkit-overflow-scrolling: touch;
}

.section-header {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 16px;
}
.section-header h2 { font-size: 19px; font-weight: 800; }
.btn-add {
    background: var(--accent); color: #fff;
    font-size: 13px; font-weight: 700;
    padding: 7px 14px; border-radius: 20px;
    transition: opacity .18s, transform .1s;
}
.btn-add:active { opacity: .85; transform: scale(.96); }

.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-3);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; font-weight: 600; }
.empty-state small { font-size: 13px; }

/* ══════════════════════════
   TASKS TAB
   ══════════════════════════ */
.prio-group { margin-bottom: 16px; }
.prio-group-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px;
}
.prio-label {
    font-size: 11px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase;
}
.prio-dot { width: 8px; height: 8px; border-radius: 50%; }

.prio-high  .prio-label { color: var(--prio-high); }
.prio-high  .prio-dot   { background: var(--prio-high); }
.prio-mid   .prio-label { color: var(--prio-mid); }
.prio-mid   .prio-dot   { background: var(--prio-mid); }
.prio-low   .prio-label { color: var(--prio-low); }
.prio-low   .prio-dot   { background: var(--prio-low); }

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

.task-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 13px 14px;
    box-shadow: var(--sh0); animation: fadeUp .22s var(--ease) both;
    display: flex; align-items: flex-start; gap: 12px;
    transition: opacity .25s;
}
.task-card.done { opacity: .45; }
.task-card.done .task-title { text-decoration: line-through; }

.task-check {
    width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--border2); cursor: pointer; margin-top: 1px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .15s, background .15s;
    font-size: 12px; color: #fff;
}
.task-card.done .task-check {
    background: var(--ok); border-color: var(--ok);
    animation: checkPop .25s var(--ease) both;
}
.task-check:hover { border-color: var(--ok); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 15px; font-weight: 700; word-break: break-word; }
.task-meta  { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.task-meta-chip {
    font-size: 11px; font-weight: 600; padding: 2px 7px;
    border-radius: 20px; background: var(--surface2);
    color: var(--text-3); border: 1px solid var(--border);
}
.task-meta-chip.due { background: var(--prio-mids); color: var(--prio-mid); border-color: transparent; }
body.dark .task-meta-chip.due { color: #fdba74; }
.task-meta-chip.recurring { background: var(--accent-s); color: var(--accent); border-color: transparent; }

.task-actions { display: flex; gap: 6px; margin-top: 8px; }
.btn-icon {
    font-size: 13px; font-weight: 600; padding: 4px 9px;
    border-radius: var(--rx); transition: background .15s;
    color: var(--text-3);
}
.btn-icon:hover { background: var(--surface2); }
.btn-icon.del:hover { background: var(--prio-highs); color: var(--prio-high); }

/* ══════════════════════════
   HANDOVER TAB
   ══════════════════════════ */
.handover-compose {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 14px; box-shadow: var(--sh0); margin-bottom: 16px;
}
.handover-compose-header {
    font-size: 13px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
}
.shift-select {
    display: flex; gap: 6px; margin-bottom: 10px;
}
.shift-btn {
    flex: 1; padding: 8px; border-radius: var(--rs);
    font-size: 13px; font-weight: 600; color: var(--text-3);
    background: var(--surface2); border: 1px solid var(--border);
    transition: background .15s, border-color .15s, color .15s;
}
.shift-btn.active { background: var(--accent-s); border-color: var(--accent); color: var(--accent); }

.handover-list { display: flex; flex-direction: column; gap: 10px; }
.handover-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 14px; box-shadow: var(--sh0);
    animation: fadeUp .22s var(--ease) both;
}
.handover-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.shift-badge {
    font-size: 11px; font-weight: 700; padding: 3px 9px;
    border-radius: 20px; letter-spacing: .04em;
}
.shift-badge.früh  { background: rgba(251,191,36,0.12); color: #92400e; }
.shift-badge.spät  { background: rgba(91,61,245,0.09); color: var(--accent); }
.shift-badge.nacht { background: rgba(107,114,128,0.09); color: var(--text-3); }
body.dark .shift-badge.früh { color: #fde68a; }
body.dark .shift-badge.spät { color: var(--accent); }

.handover-author { font-size: 12px; font-weight: 600; color: var(--text-3); }
.handover-ts     { font-size: 11px; color: var(--text-3); margin-bottom: 8px; }
.handover-text   { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.handover-del-btn {
    font-size: 12px; color: var(--text-3); padding: 3px 8px;
    border-radius: var(--rx); transition: color .15s, background .15s;
}
.handover-del-btn:hover { color: #ef4444; background: rgba(239,68,68,0.08); }

/* ══════════════════════════
   ARRIVALS TAB
   ══════════════════════════ */
.arrivals-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.arrivals-filter {
    display: flex; gap: 6px;
}
.filter-btn {
    padding: 5px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 600; color: var(--text-3);
    background: var(--surface2); border: 1px solid var(--border);
    transition: background .15s, color .15s;
}
.filter-btn.active { background: var(--accent-s); border-color: var(--accent); color: var(--accent); }

.arrivals-list { display: flex; flex-direction: column; gap: 8px; }
.arrival-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 13px 14px;
    box-shadow: var(--sh0); animation: fadeUp .22s var(--ease) both;
    display: flex; align-items: flex-start; gap: 12px;
}
.arrival-type-badge {
    font-size: 11px; font-weight: 700; padding: 3px 8px;
    border-radius: 20px; flex-shrink: 0; margin-top: 2px;
}
.arrival-type-badge.arrival   { background: rgba(34,197,94,0.10); color: #15803d; }
.arrival-type-badge.departure { background: rgba(59,130,246,0.10); color: #1d4ed8; }
body.dark .arrival-type-badge.arrival   { color: #86efac; }
body.dark .arrival-type-badge.departure { color: #93c5fd; }

.arrival-body { flex: 1; min-width: 0; }
.arrival-guest { font-size: 15px; font-weight: 700; }
.arrival-meta  { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.arrival-meta-chip {
    font-size: 11px; font-weight: 600; padding: 2px 7px;
    border-radius: 20px; background: var(--surface2);
    color: var(--text-3); border: 1px solid var(--border);
}
.arrival-note { font-size: 13px; color: var(--text-3); margin-top: 4px; font-style: italic; }
.arrival-done-check {
    width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--border2); cursor: pointer; margin-top: 2px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #fff; transition: all .15s;
}
.arrival-done-check.done { background: var(--ok); border-color: var(--ok); }
.arrival-done-check:not(.done):hover { border-color: var(--ok); }

/* ══════════════════════════
   MODAL
   ══════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 500; padding: 0 0 var(--sb);
}
.modal-sheet {
    background: var(--surface);
    border-radius: var(--r) var(--r) 0 0;
    width: 100%; max-width: 560px;
    max-height: 92dvh; overflow-y: auto;
    animation: sheetUp .28s var(--ease) both;
    padding: 20px 20px calc(24px + var(--sb));
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--surface2); font-size: 14px; color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.modal-close:hover { background: var(--surface3); }

.prio-picker {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px;
}
.prio-pick-btn {
    padding: 10px; border-radius: var(--rs); text-align: center;
    font-size: 13px; font-weight: 700; cursor: pointer;
    background: var(--surface2); border: 1px solid var(--border);
    transition: all .15s;
}
.prio-pick-btn[data-prio="dringend"].active { background: var(--prio-highs); border-color: var(--prio-high); color: var(--prio-high); }
.prio-pick-btn[data-prio="normal"].active   { background: var(--prio-mids);  border-color: var(--prio-mid);  color: var(--prio-mid); }
.prio-pick-btn[data-prio="niedrig"].active  { background: var(--surface3);   border-color: var(--border2);   color: var(--text-2); }
body.dark .prio-pick-btn[data-prio="dringend"].active { color: #fca5a5; }
body.dark .prio-pick-btn[data-prio="normal"].active   { color: #fdba74; }

.type-picker {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px;
}
.type-pick-btn {
    padding: 10px; border-radius: var(--rs); text-align: center;
    font-size: 13px; font-weight: 700; cursor: pointer;
    background: var(--surface2); border: 1px solid var(--border);
    transition: all .15s;
}
.type-pick-btn[data-type="arrival"].active   { background: rgba(34,197,94,0.09); border-color: var(--ok); color: #15803d; }
.type-pick-btn[data-type="departure"].active { background: rgba(59,130,246,0.09); border-color: #3b82f6; color: #1d4ed8; }
body.dark .type-pick-btn[data-type="arrival"].active   { color: #86efac; }
body.dark .type-pick-btn[data-type="departure"].active { color: #93c5fd; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── App Switcher ── */
.app-switcher { position: relative; }
.app-switcher-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s; color: var(--text-3);
}
.app-switcher-btn:hover { background: var(--surface2); }
.app-switcher-popover {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: var(--r); box-shadow: var(--sh3);
    padding: 12px; width: 224px; z-index: 999;
    animation: fadeUp .2s var(--ease) both;
}
.app-switcher-popover.hidden { display: none !important; }
.switcher-label {
    font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-3);
    padding: 0 4px; margin-bottom: 8px;
}
.switcher-apps { display: flex; flex-direction: column; gap: 2px; }
.switcher-app {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--rs);
    text-decoration: none; color: var(--text); transition: background .15s;
}
.switcher-app:hover { background: var(--surface2); }
.switcher-app.current { background: var(--accent-s); }
.switcher-app-icon {
    width: 30px; height: 30px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.switcher-app-name { font-size: 13px; font-weight: 700; }
.switcher-app-sub  { font-size: 11px; color: var(--text-3); }
.switcher-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0; margin-left: auto;
}
