/* Balli kohvik – kioskivaade (10" ekraan laiuti, ~1280×800) */

:root {
    --bg: #17121b;
    --surface: #241c29;
    --surface-2: #2f2535;
    --line: #3d3244;
    --text: #f5efe6;
    --muted: #b3a7b8;
    --gold: #e7c26b;
    --accent: #c8414e;
    --accent-press: #a8333f;
    --ok: #39b56a;
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* Ekraanid */
.screen { position: fixed; inset: 0; display: none; }
.screen.is-active { display: flex; }

/* ---------- 1. Pood ---------- */
.screen-shop { display: none; }
.screen-shop.is-active { display: grid; grid-template-columns: 1fr 360px; }

.products {
    overflow-y: auto;
    padding: 24px 24px 40px;
    -webkit-overflow-scrolling: touch;
}

.group-title {
    margin: 8px 0 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--gold);
}
.group-title:not(:first-child) { margin-top: 28px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.product {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    padding: 18px 18px 16px;
    text-align: left;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--radius);
    transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.product:active { transform: scale(.97); background: var(--surface-2); }
.product.in-cart { border-color: var(--gold); }

.product-name { font-size: 23px; font-weight: 700; line-height: 1.15; }
.product-desc { margin-top: 6px; font-size: 14px; line-height: 1.3; color: var(--muted); }
.product-price { margin-top: 14px; font-size: 20px; font-weight: 700; color: var(--gold); }

.product-qty {
    position: absolute;
    top: -10px;
    right: -10px;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 18px;
    background: var(--gold);
    color: #1b1408;
    font-weight: 800;
    font-size: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,.4);
}
.product.in-cart .product-qty { display: flex; }

/* Ostukorv */
.cart {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--line);
    padding: 24px 20px 20px;
    min-height: 0;
}
.cart h2 { margin: 0 0 12px; font-size: 22px; }

.cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}
.cart-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.cart-item-name { font-size: 17px; font-weight: 600; }
.cart-item-sum { font-size: 17px; font-weight: 600; text-align: right; }
.qty-controls { display: flex; align-items: center; gap: 12px; }
.qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: var(--surface-2);
    font-size: 24px;
    line-height: 1;
}
.qty-btn:active { background: var(--line); }
.qty-value { min-width: 24px; text-align: center; font-size: 19px; font-weight: 700; }

.cart-empty { flex: 1; color: var(--muted); font-size: 16px; line-height: 1.4; margin: 0; }
.cart-items:not(:empty) + .cart-empty { display: none; }

.cart-footer { padding-top: 14px; border-top: 1px solid var(--line); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; font-size: 18px; }
.cart-total strong { font-size: 30px; color: var(--gold); }

/* Nupud */
.btn {
    display: block;
    width: 100%;
    padding: 18px;
    border: 0;
    border-radius: 14px;
    font-size: 21px;
    font-weight: 700;
}
.btn-primary { background: var(--accent); color: #fff; letter-spacing: .04em; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); }
.btn-ghost { margin-top: 10px; background: transparent; color: var(--muted); font-size: 17px; font-weight: 600; }
.btn-ghost:active { color: var(--text); }

/* ---------- Ühised paneelid ---------- */
.screen-method, .screen-qr, .screen-success { align-items: center; justify-content: center; padding: 24px; }

.panel {
    width: 100%;
    max-width: 980px;
    background: var(--surface);
    border-radius: 24px;
    padding: 32px;
}
.panel h2 { margin: 0; font-size: 30px; }
.sub { margin: 8px 0 0; color: var(--muted); font-size: 17px; }

/* ---------- 2. Makseviis ---------- */
.methods {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-top: 24px;
}
.method {
    height: 88px;
    border: 0;
    border-radius: 14px;
    background: #fff;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    font-size: 18px;
    font-weight: 700;
}
.method:active { transform: scale(.97); }
.method-cash {
    grid-column: 1 / -1;
    height: 72px;
    background: var(--gold);
    color: #1b1408;
    font-size: 21px;
}
.check.is-cash { background: var(--gold); color: #1b1408; font-weight: 800; }
.cash-due {
    margin: 18px 0 6px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface-2);
    font-size: 19px;
    color: var(--muted);
}
.cash-due strong { display: block; margin-top: 4px; font-size: 44px; color: var(--gold); }
.method img { max-width: 100%; max-height: 44px; object-fit: contain; }
.screen-method .btn-ghost { width: auto; margin: 20px auto 0; }
.error { color: #ff8a8a; min-height: 1.4em; margin: 14px 0 0; font-size: 17px; }

/* ---------- 3. QR ---------- */
.panel-qr { display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: center; }
.qr {
    width: 420px;
    height: 420px;
    background: #fff;
    border-radius: 18px;
    padding: 18px;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr-total { margin-top: 28px; font-size: 52px; font-weight: 800; color: var(--gold); }
.qr-nr { margin-top: 6px; font-size: 20px; color: var(--muted); }
.qr-nr strong { color: var(--text); }
.waiting { display: flex; align-items: center; gap: 12px; margin-top: 28px; font-size: 18px; color: var(--muted); }
.qr-info .btn-ghost { width: auto; padding-left: 0; margin-top: 24px; text-align: left; }

/* ---------- 4. Õnnestus ---------- */
.panel-center { max-width: 560px; text-align: center; }
.check {
    width: 96px;
    height: 96px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--ok);
    color: #fff;
    font-size: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.big-nr { font-size: 96px; font-weight: 800; line-height: 1; margin: 8px 0 18px; color: var(--gold); }
.success-items { list-style: none; margin: 0 0 24px; padding: 0; font-size: 19px; }
.success-items li { padding: 6px 0; }

/* Spinner / laadimine */
.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--gold);
    animation: spin .9s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 12, .6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.loading.is-active { display: flex; }
.loading .spinner { width: 54px; height: 54px; border-width: 5px; }

/* Väiksem ekraan (nt 1024×600) */
@media (max-height: 680px) {
    .screen-shop.is-active { grid-template-columns: 1fr 320px; }
    .product { min-height: 120px; padding: 14px; }
    .product-name { font-size: 20px; }
    .qr { width: 340px; height: 340px; }
    .qr-total { font-size: 42px; }
    .methods { grid-template-columns: repeat(5, 1fr); }
    .method { height: 72px; }
}
