/* ============================================================
   Kiosk-Styles — Optimiert für iPad iOS 12, Touch-first
   ============================================================ */

html, body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Screens ---- */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    gap: 1.5rem;
}

.screen.active {
    display: flex;
}

/* ---- Logo ---- */
.logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}

.logo-wrap img {
    width: min(240px, 55vw);
    height: auto;
}

.logo-wrap h1 {
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    color: var(--color-primary);
    font-weight: 700;
    text-align: center;
    letter-spacing: -.02em;
}

/* ---- Idle Screen ---- */
.idle-intro {
    color: #fff;
    font-size: 1.1rem;
    text-align: center;
    max-width: min(360px, 88vw);
    line-height: 1.6;
    margin: 0 0 1.25rem;
    font-weight: 500;
}

.idle-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(360px, 90vw);
}

.btn-main {
    min-height: var(--touch-min);
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: 700;
    border-radius: var(--radius-lg);
    padding: 1rem 2rem;
    letter-spacing: .01em;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow);
}

.btn-primary:active {
    background: var(--color-primary-dk);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 2.5px solid var(--color-primary);
}

.btn-secondary:active {
    background: var(--color-primary-lt);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    box-shadow: var(--shadow);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    font-size: .95rem;
    padding: .6rem 1.2rem;
}

/* ---- PIN Screen ---- */
.pin-greeting {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--color-text-muted);
    text-align: center;
}

.pin-dots {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    margin: .5rem 0;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid var(--color-primary);
    background: transparent;
    transition: background .15s;
}

.pin-dot.filled {
    background: var(--color-primary);
}

.pin-error {
    color: var(--color-danger);
    font-size: .95rem;
    min-height: 1.4em;
    text-align: center;
}

.pin-error.shake {
    animation: shake .4s ease;
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    75%      { transform: translateX(8px); }
}

/* PIN-Eingabe */
.pin-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(340px, 88vw);
}

.pin-input-wrap input {
    font-size: 1.6rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    border: 2.5px solid var(--color-border);
    min-height: var(--touch-min);
    text-align: center;
    letter-spacing: .15em;
    background: var(--color-surface);
    -webkit-user-select: auto;
    user-select: auto;
}

.pin-input-wrap input:focus {
    border-color: var(--color-primary);
    outline: none;
}

/* ---- Gast-Name Screen ---- */
.guest-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(380px, 90vw);
}

.guest-form input {
    font-size: 1.3rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    border: 2.5px solid var(--color-border);
    min-height: var(--touch-min);
}

.guest-form input:focus {
    border-color: var(--color-primary);
}

/* ---- Gast-Schnellauswahl ---- */
.guest-saved {
    width: min(380px, 90vw);
    margin-top: .25rem;
}

.guest-saved-label {
    font-size: .85rem;
    color: var(--color-text-muted);
    margin-bottom: .5rem;
    text-align: center;
}

.guest-saved-list {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
}

.guest-saved-btn {
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: 99px;
    padding: .45rem 1.1rem;
    font-size: .95rem;
    font-weight: 600;
    min-height: 44px;
    cursor: pointer;
}

/* ---- Drink Selection Screen ---- */
#screen-drinks {
    justify-content: flex-start;
    padding: 0;
    gap: 0;
    overflow: hidden;   /* verhindert, dass Grid-Inhalt über den Screen herauswächst */
    min-height: 0;      /* Flex-Kind darf auf verfügbare Höhe schrumpfen */
}

.drinks-header {
    width: 100%;
    background: var(--color-primary);
    color: #fff;
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.drinks-hd-left {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
}

.drinks-hd-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.drinks-hd-title {
    font-weight: 700;
    font-size: .95rem;
}

.drinks-hd-user {
    font-size: .78rem;
    opacity: .85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drinks-hd-right {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}

.user-balance {
    font-size: .82rem;
    font-weight: 600;
    opacity: .9;
    white-space: nowrap;
}

/* Header-Buttons */
.btn-hd {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.35);
    font-size: .82rem;
    font-weight: 600;
    padding: .35rem .75rem;
    border-radius: var(--radius-sm);
    min-height: 34px;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.btn-hd:active {
    background: rgba(255,255,255,.32);
}

/* Kategorie-Tabs */
.category-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--color-primary-dk);
    flex-shrink: 0;
    width: 100%;
}

.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
    flex-shrink: 0;
    padding: .75rem 1.4rem;
    font-size: .95rem;
    font-weight: 600;
    color: rgba(255,255,255,.7);
    background: transparent;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    min-height: 48px;
    white-space: nowrap;
}

.cat-tab.active {
    color: #fff;
    border-bottom-color: #fff;
}

/* Getränkekarten */
.drinks-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: .75rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
    align-content: start;
    width: 100%;
}

.drink-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .75rem;
    min-height: var(--touch-min);
    border: 2.5px solid transparent;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    text-align: left;
}

.drink-card:active {
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
    transform: scale(.98);
}

.drink-card.in-order {
    border-color: var(--color-primary);
    background: var(--color-primary-lt);
}

/* Bild links */
.drink-card-img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

/* Name + Preis rechts */
.drink-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.drink-name {
    font-size: clamp(.9rem, 2.5vw, 1.05rem);
    font-weight: 600;
    color: var(--color-text);
    white-space: normal;
    word-break: break-word;
}

.drink-price {
    font-size: 1rem;
    color: var(--color-primary);
    font-weight: 700;
}

/* Mengen-Badge rechts */
.drink-qty {
    background: var(--color-primary);
    color: #fff;
    border-radius: 99px;
    padding: .2em .75em;
    font-size: .9rem;
    font-weight: 700;
    flex-shrink: 0;
    display: none;
}

.drink-card.in-order .drink-qty {
    display: inline;
}

/* Bestell-Leiste (sticky bottom) */
.order-bar {
    width: 100%;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
    box-shadow: 0 -3px 12px rgba(0,0,0,.08);
}

.order-summary {
    flex: 1;
    font-size: .9rem;
}

.order-total {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.btn-book {
    min-height: 56px;
    min-width: 140px;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.btn-cancel-order {
    min-height: 56px;
    font-size: .9rem;
    padding: .5rem 1rem;
    flex-shrink: 0;
}

/* ---- Bestätigungs-Screen ---- */
.confirm-icon {
    font-size: 4rem;
    line-height: 1;
}

.confirm-title {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 800;
    color: var(--color-success);
}

.confirm-balance {
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

.confirm-balance strong {
    color: var(--color-text);
    font-size: 1.3rem;
}

.confirm-buttons {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    width: min(340px, 90vw);
    margin-top: .5rem;
}

.countdown {
    font-size: .85rem;
    color: var(--color-text-muted);
}

/* ---- Bezahlen-Screen ---- */
.btn-pay {
    background: #2980b9;
    color: #fff;
    border: none;
}
.btn-pay:active { background: #1a6fa3; }

#screen-konto {
    justify-content: flex-start;
    padding: 0;
    gap: 0;
}

.konto-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 1rem;
    gap: 1rem;
    overflow-y: auto;
    width: 100%;
}

.konto-receipt {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 14px rgba(0,0,0,.10);
    padding: 1.25rem 1.5rem;
    width: 100%;
    max-width: 480px;
}

.receipt-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding-bottom: .6rem;
    border-bottom: 1px solid #e4e4e4;
    margin-bottom: .25rem;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.receipt-table th {
    text-align: left;
    padding: .45rem .3rem .4rem;
    color: var(--color-text-muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #e4e4e4;
}
.receipt-table th:nth-child(2),
.receipt-table th:nth-child(3) { text-align: right; }

.receipt-table tbody td {
    padding: .55rem .3rem;
    border-bottom: 1px dashed #eeeeee;
    vertical-align: middle;
}
.receipt-table tbody td:nth-child(2) {
    text-align: right;
    color: var(--color-text-muted);
    font-size: .88rem;
    white-space: nowrap;
}
.receipt-table tbody td:nth-child(3) {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

/* Letzte Zeile vor Summe: durchgezogener Strich */
.receipt-table tbody tr:last-child td {
    border-bottom: 1.5px solid #c8c8c8;
    padding-bottom: .65rem;
}

/* Gesamtzeile */
.receipt-table tfoot td {
    padding: .6rem .3rem .25rem;
    font-weight: 700;
    font-size: 1rem;
}
.receipt-table tfoot td:last-child {
    text-align: right;
    color: var(--color-primary);
    font-size: 1.1rem;
}

.konto-pay-wrap {
    width: 100%;
    max-width: 480px;
    flex-shrink: 0;
}

#screen-pay {
    justify-content: flex-start;
    padding: 1rem 1.5rem 1.5rem;
    overflow-y: auto;
}

.pay-header {
    text-align: center;
    margin-bottom: 1.25rem;
    width: 100%;
}

.pay-title {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.pay-amount {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.pay-body {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 860px;
    align-items: flex-start;
}

.pay-qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    flex: 0 0 auto;
}

#pay-qr {
    width: 220px;
    height: 220px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pay-qr-hint {
    font-size: .8rem;
    color: var(--color-text-muted);
    text-align: center;
    max-width: 220px;
    margin: 0;
}

.pay-iban {
    font-size: .82rem;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.6;
}

.pay-history {
    flex: 1;
    min-width: 0;
}

.pay-history-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.pay-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.pay-table th {
    text-align: left;
    border-bottom: 2px solid #eee;
    padding: .4rem .5rem;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
}

.pay-table td {
    padding: .5rem .5rem;
    border-bottom: 1px solid #f0f0f0;
}

.pay-close-btn {
    margin-top: 1.25rem;
    width: min(280px, 90vw);
    flex-shrink: 0;
}

/* ============================================================
   Mobile (< 540px) — Handy-optimiertes Layout
   ============================================================ */
@media (max-width: 539px) {

    /* Header kompakter */
    .drinks-header { padding: .5rem .6rem; gap: .3rem; }
    .drinks-hd-logo { width: 26px; height: 26px; }
    .drinks-hd-title { font-size: .82rem; }
    .drinks-hd-user  { font-size: .72rem; }
    .user-balance    { font-size: .72rem; }
    .btn-hd { padding: .3rem .5rem; font-size: .75rem; min-height: 30px; }

    /* Getränkekarten kompakter auf Mobile */
    .drinks-grid {
        padding: .5rem;
        gap: .4rem;
    }
    .drink-card { padding: .5rem .65rem; min-height: 56px; gap: .6rem; }
    .drink-card-img { width: 46px; height: 46px; }
    .drink-name  { font-size: .85rem; }
    .drink-price { font-size: .88rem; }

    /* Bestell-Leiste kompakter */
    .order-bar { padding: .5rem .6rem; gap: .4rem; }
    .btn-book  { min-width: 100px; min-height: 48px; font-size: .95rem; }
    .order-summary { font-size: .82rem; }
    .order-total   { font-size: 1rem; }

    /* Idle Screen */
    .logo-wrap img { width: min(160px, 45vw); }
    .idle-buttons  { width: min(300px, 92vw); }
}

/* ============================================================
   Login-Screens: blauer Hintergrund (wie Admin-Login)
   ============================================================ */
#screen-idle,
#screen-pin,
#screen-guest {
    background: radial-gradient(ellipse at center, #f0f1f3 0%, #7aa3d4 100%);
}

/* Texte auf hellem Verlauf */
#screen-idle .logo-wrap h1,
#screen-pin .pin-greeting,
#screen-guest .pin-greeting {
    color: var(--color-primary);
}

#screen-idle .idle-intro {
    color: #333;
}

/* Ghost-Buttons (Abbrechen) auf blauem Hintergrund */
#screen-pin  .btn-ghost,
#screen-guest .btn-ghost {
    color: rgba(255,255,255,.8);
}
