/* ══════════════════════════════════════════
   ChefFlow — 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:       #dc2626;
    --prio-s:     rgba(220,38,38,0.08);
    --warn:       #f97316;
    --warn-s:     rgba(249,115,22,0.10);
    --ok:         #22c55e;
    --ok-s:       rgba(34,197,94,0.10);
    --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)} }

/* ── 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%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
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 Spinner ── */
#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;
    background: var(--bg);
}

.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 */
.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);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 700; color: var(--accent);
    flex-shrink: 0;
}
.staff-name  { font-size: 15px; font-weight: 700; }
.staff-role  { font-size: 12px; color: var(--text-3); }

/* PIN pad */
.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;
}

/* ── Header ── */
.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 ── */
.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); }

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

/* ── Section headers ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 {
    font-size: 19px;
    font-weight: 800;
}

/* ── Buttons ── */
.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); }

.btn-sm {
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: var(--rx);
    transition: opacity .15s, transform .1s;
}
.btn-sm:active { transform: scale(.95); }
.btn-sm.ok     { background: var(--ok-s); color: #15803d; }
.btn-sm.del    { background: var(--prio-s); color: var(--prio); }
.btn-sm.edit   { background: var(--accent-s); color: var(--accent); }

body.dark .btn-sm.ok   { color: #86efac; }
body.dark .btn-sm.del  { color: #fca5a5; }
body.dark .btn-sm.edit { color: var(--accent); }

/* ══════════════════════════
   ROOMS TAB
   ══════════════════════════ */
.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px;
    box-shadow: var(--sh0);
    animation: fadeUp .25s var(--ease) both;
}
.room-card.critical {
    border-color: rgba(220,38,38,0.35);
    background: linear-gradient(135deg, var(--surface) 0%, rgba(220,38,38,0.04) 100%);
}

.room-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.room-number {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}
.room-number span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    margin-left: 6px;
}
.critical-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(220,38,38,0.10);
    color: #dc2626;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}
body.dark .critical-badge { color: #fca5a5; background: rgba(220,38,38,0.18); }

.allergy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}
.allergy-chip {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(249,115,22,0.10);
    color: #c2410c;
}
.allergy-chip.critical-allergen {
    background: rgba(220,38,38,0.12);
    color: #dc2626;
}
body.dark .allergy-chip { color: #fdba74; }
body.dark .allergy-chip.critical-allergen { color: #fca5a5; }

.diet-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
}
.diet-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(34,197,94,0.10);
    color: #15803d;
}
body.dark .diet-badge { color: #86efac; }

.guest-note {
    font-size: 13px;
    color: var(--text-3);
    font-style: italic;
    margin-top: 4px;
}

.room-card-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.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; }

/* ══════════════════════════
   ORDERS TAB
   ══════════════════════════ */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 8px 0 6px;
}
.order-group-label:first-child { margin-top: 0; }

.order-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;
}
.order-card.done {
    opacity: .6;
}

.order-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.order-room-badge {
    font-size: 12px;
    font-weight: 700;
    background: var(--accent-s);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.order-item {
    font-size: 16px;
    font-weight: 700;
    margin: 6px 0 4px;
}
.order-note {
    font-size: 13px;
    color: var(--text-3);
}
.order-ts {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 6px;
}
.order-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    justify-content: flex-end;
}

/* ══════════════════════════
   BREAKFAST TAB
   ══════════════════════════ */
.breakfast-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bf-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}
.bf-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 14px;
    box-shadow: var(--sh0);
    text-align: center;
}
.bf-stat-num  { font-size: 32px; font-weight: 800; color: var(--accent); }
.bf-stat-label{ font-size: 12px; font-weight: 600; color: var(--text-3); margin-top: 2px; }

.bf-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px;
    box-shadow: var(--sh0);
}
.bf-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 10px;
}
.bf-allergy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.bf-allergy-row:last-child { border-bottom: none; }
.bf-allergy-name { font-weight: 600; }
.bf-allergy-count {
    font-size: 12px;
    font-weight: 700;
    background: rgba(249,115,22,0.10);
    color: #c2410c;
    padding: 2px 8px;
    border-radius: 20px;
}
body.dark .bf-allergy-count { color: #fdba74; }

.bf-diet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.bf-diet-row:last-child { border-bottom: none; }
.bf-diet-name { font-weight: 600; }
.bf-diet-count {
    font-size: 12px;
    font-weight: 700;
    background: rgba(34,197,94,0.10);
    color: #15803d;
    padding: 2px 8px;
    border-radius: 20px;
}
body.dark .bf-diet-count { color: #86efac; }

.bf-room-list { list-style: none; }
.bf-room-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.bf-room-item:last-child { border-bottom: none; }
.bf-room-num {
    font-weight: 800;
    min-width: 36px;
    color: var(--accent);
}
.bf-room-info { flex: 1; }
.bf-room-info .diet-badge { display: inline-block; margin-bottom: 3px; }

/* ══════════════════════════
   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));
}
@keyframes sheetUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.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); }

/* allergen checkboxes */
.allergen-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 6px;
}
.allergen-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--rs);
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: border-color .15s, background .15s;
    -webkit-user-select: none;
    user-select: none;
}
.allergen-checkbox input { display: none; }
.allergen-checkbox.checked {
    border-color: var(--warn);
    background: rgba(249,115,22,0.08);
    color: #c2410c;
}
body.dark .allergen-checkbox.checked { color: #fdba74; }
.allergen-checkbox .check-dot {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border2);
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.allergen-checkbox.checked .check-dot {
    background: #f97316; border-color: #f97316;
}

.diet-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 6px;
}
.diet-option {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--rs);
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    -webkit-user-select: none;
    user-select: none;
}
.diet-option.selected {
    border-color: var(--ok);
    background: rgba(34,197,94,0.08);
    color: #15803d;
}
body.dark .diet-option.selected { color: #86efac; }

.date-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
}

/* Scrollbar */
::-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;
}
