/* Scanner PWA styling (Phase 6.7): hotelsuite look based on the Schloss-Elmau palette that the admin
   theme already uses (see Ticketing.AdminTheme/wwwroot/css/hotelsuite-admin.css). Mobile-first — the
   target device is a smartphone at the entrance. Scan results keep hard semantic colors (green/orange/
   red) independent of the brand palette. */
:root {
    /* Brand palette (shared with the admin theme). */
    --hs-ink: #413c3c;
    --hs-beige: #f3eee7;
    --hs-sand: #e7ddcc;
    --hs-sand-soft: #ece4d7;
    --hs-border: #d8cdbb;
    --hs-taupe: #8a7b63;
    --hs-text: #46403a;
    --hs-btn: #6f6250;
    --hs-btn-hover: #5a4f40;
    --hs-btn-active: #4d4336;

    /* Semantic scan-result colors. */
    --ok: #1e7e34;
    --warn: #c05f00;
    --error: #b02a37;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--hs-text);
    background: #faf7f2;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--hs-ink);
    margin: 0 0 1rem;
}

.muted {
    color: var(--hs-taupe);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header (fixed): brand row + counter row. ------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--hs-beige);
    color: var(--hs-ink);
    border-bottom: 1px solid var(--hs-border);
}

.app-header-row {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.app-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--hs-btn);
    text-decoration: underline;
    padding: 0;
    font-size: 0.9rem;
    cursor: pointer;
}

.login-user {
    margin-right: 0.75rem;
    font-size: 0.9rem;
}

/* Counter header (Phase 6.7): event name, not-scanned/scanned, refresh icon. Stale numbers (failed
   refresh/offline) turn red until a refresh succeeds again. */
.scan-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem 0.5rem;
    font-size: 0.85rem;
    background: var(--hs-sand-soft);
    border-top: 1px solid var(--hs-border);
}

.scan-status-event {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hs-ink);
    text-decoration: underline;
    text-decoration-color: var(--hs-taupe);
    cursor: pointer;
    max-width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.scan-status-counters {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-left: auto;
    white-space: nowrap;
}

.counter-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.scan-status.stale .scan-status-counters {
    color: var(--error);
}

.scan-status-refresh {
    background: none;
    border: 1px solid var(--hs-border);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    line-height: 1;
    font-size: 1rem;
    color: var(--hs-ink);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.scan-status-refresh:disabled {
    opacity: 0.5;
}

/* Main + footer ----------------------------------------------------------- */

.app-main {
    padding: 1rem;
    max-width: 40rem;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--hs-taupe);
    background: var(--hs-beige);
    border-top: 1px solid var(--hs-border);
}

.app-footer img {
    height: 1rem;
    width: auto;
    display: block;
}

/* Camera scanner (Phase 6.8) ---------------------------------------------- */

.qr-reader {
    width: 100%;
    margin: 0 0 1rem;
    border: 1px solid var(--hs-border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: #000;
}

/* Invisible while probing (html5-qrcode has not injected the video element yet). */
.qr-reader:empty {
    border: none;
    background: transparent;
}

.qr-reader video {
    display: block;
    width: 100% !important;
}

/* Form + buttons ---------------------------------------------------------- */

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--hs-ink);
}

textarea,
input {
    width: 100%;
    font-size: 1rem;
    font-family: inherit;
    color: var(--hs-text);
    padding: 0.6rem;
    margin: 0.25rem 0 0.75rem;
    border: 1px solid var(--hs-border);
    border-radius: 0.5rem;
    background: #fff;
}

textarea:focus,
input:focus {
    outline: 2px solid var(--hs-taupe);
    outline-offset: 1px;
}

.btn {
    font-size: 1rem;
    font-family: inherit;
    padding: 0.6rem 1.1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.btn-primary {
    background: var(--hs-btn);
    border-color: var(--hs-btn);
    color: #fff;
}

.btn-primary:not(:disabled):hover {
    background: var(--hs-btn-hover);
    border-color: var(--hs-btn-hover);
}

.btn-primary:not(:disabled):active {
    background: var(--hs-btn-active);
    border-color: var(--hs-btn-active);
}

.btn-secondary {
    background: #fff;
    border-color: var(--hs-btn);
    color: var(--hs-btn);
}

.btn-secondary:not(:disabled):hover {
    background: var(--hs-sand-soft);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Scan result: big and glanceable (green/orange/red). --------------------- */

.result {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 1.05rem;
}

.result-ok {
    background: var(--ok);
}

.result-warn {
    background: var(--warn);
}

.result-error {
    background: var(--error);
}

/* Event selection (mandatory entrance screen). ---------------------------- */

.event-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.event-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    color: var(--hs-text);
    background: #fff;
    border: 1px solid var(--hs-border);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
}

.event-card:hover {
    background: var(--hs-sand-soft);
}

.event-card.selected {
    background: var(--hs-sand);
    border-color: var(--hs-taupe);
}

.event-card-name {
    font-weight: 600;
    color: var(--hs-ink);
}

.event-card-performances {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.85rem;
    color: var(--hs-taupe);
}

/* Notes confirmation modal (blocks further scans until decided). ----------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(65, 60, 60, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-dialog {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    width: 100%;
    max-width: 26rem;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(65, 60, 60, 0.35);
}

.modal-dialog h2 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    color: var(--hs-ink);
}

.note-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.note-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: var(--hs-beige);
    border: 1px solid var(--hs-border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
}

.note-source {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--hs-taupe);
}

.note-text {
    white-space: pre-line;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Offline / sync (Phase 6.10) --------------------------------------------- */

.offline-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.offline-banner.offline {
    background: #fbe9d6;
    color: var(--warn);
    border: 1px solid var(--warn);
}

.offline-banner.pending {
    background: var(--hs-sand-soft);
    color: var(--hs-ink);
    border: 1px solid var(--hs-border);
}

.btn-sync {
    flex: 0 0 auto;
    width: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.sync-summary {
    margin-top: 1rem;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    background: var(--hs-sand-soft);
    border: 1px solid var(--hs-border);
    color: var(--hs-ink);
    font-size: 0.9rem;
}

.sync-summary.has-conflicts {
    background: #f7dede;
    border-color: var(--error);
}

.sync-conflicts {
    margin-top: 0.4rem;
    font-weight: 600;
    color: var(--error);
}

/* Misc -------------------------------------------------------------------- */

.loading {
    padding: 2rem;
    text-align: center;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffe0e0;
    padding: 0.75rem 1rem;
}
