/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
    --bg:        #0f0f1a;
    --surface:   #1a1a2e;
    --border:    #2a2a4a;
    --accent:    #e94560;
    --success:   #00c853;
    --warn:      #e65100;
    --error:     #b71c1c;
    --purple:    #6a1b9a;
    --text:      #e0e0e0;
    --muted:     #8888aa;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    -webkit-appearance: none;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

/* ============================================================
   SCREEN BASE
   ============================================================ */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.center-screen {
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
    padding-top: max(2rem, env(safe-area-inset-top));
    text-align: center;
}

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ============================================================
   CONNECTING SCREEN
   ============================================================ */
.connecting-logo {
    width: 80px;
    height: 80px;
}

.connecting-logo svg {
    width: 100%;
    height: 100%;
}

.connecting-title {
    font-size: 1.6rem;
    font-weight: 700;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.home-screen {
    justify-content: space-between;
}

.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    padding-top: max(1.25rem, env(safe-area-inset-top));
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.brand-row .app-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.home-header-right {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.conn-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.2);
    flex-shrink: 0;
}

.home-buttons {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    color: var(--text);
    text-align: left;
    transition: background 0.12s, transform 0.1s;
    width: 100%;
}

.mode-btn:active {
    background: #232338;
    transform: scale(0.975);
}

.btn-icon-wrap {
    width: 56px;
    height: 56px;
    background: rgba(233, 69, 96, 0.12);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.btn-icon-wrap svg {
    width: 30px;
    height: 30px;
}

.btn-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.btn-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-desc {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-btn-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.mode-btn-active {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.07);
}

.clear-event-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    width: 100%;
    transition: background 0.1s, color 0.1s;
}

.clear-event-btn:active {
    background: var(--border);
    color: var(--text);
}

.clear-event-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.scanner-change-btn {
    color: rgba(255,255,255,0.7);
    flex-shrink: 0;
}

.scanner-change-btn:active {
    background: rgba(255,255,255,0.15);
}

.app-version {
    font-size: 0.68rem;
    color: var(--muted);
    text-align: center;
    opacity: 0.6;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    letter-spacing: 0.04em;
}

.ios-banner {
    margin: 0 1.5rem;
    margin-bottom: max(1rem, env(safe-area-inset-bottom));
    padding: 0.7rem 1rem;
    background: rgba(233, 69, 96, 0.08);
    border: 1px solid rgba(233, 69, 96, 0.25);
    border-radius: 12px;
    font-size: 0.82rem;
    text-align: center;
    color: var(--muted);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
    flex-shrink: 0;
}

.top-bar-title {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text);
    border-radius: 10px;
    flex-shrink: 0;
}

.icon-btn:active {
    background: var(--border);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
}

.icon-btn.torch-on {
    color: #ffd600;
    background: rgba(255, 214, 0, 0.2);
    box-shadow: 0 0 12px rgba(255, 214, 0, 0.4);
}

.top-bar-spacer {
    width: 44px;
    flex-shrink: 0;
}

/* ============================================================
   EVENT LIST
   ============================================================ */
.events-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-msg {
    text-align: center;
    color: var(--muted);
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

.event-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.event-card:active {
    background: #232338;
}

.event-card-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.event-card-main {
    flex: 1;
    min-width: 0;
}

.event-name {
    font-size: 0.98rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.event-time {
    color: var(--accent);
    font-weight: 600;
}

.event-kind {
    background: rgba(106, 27, 154, 0.25);
    color: #ce93d8;
    border-radius: 4px;
    padding: 0 5px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.capacity-badge {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.capacity-badge .cap-num {
    font-size: 1.2rem;
    font-weight: 700;
}

.capacity-badge .cap-label {
    font-size: 0.62rem;
    font-weight: 400;
    opacity: 0.75;
    margin-top: 2px;
}

.badge-remaining { background: rgba(230, 81, 0, 0.22); color: #ff8a50; }

.event-stats {
    display: flex;
    align-items: center;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 3px;
    white-space: nowrap;
}

.stat-checked   { color: var(--success); }
.stat-remaining { color: #ff8a50; }

.stat-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

.checkin-bar {
    margin-top: 0.55rem;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.checkin-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--success);
    transition: width 0.3s ease;
}

/* ============================================================
   SCANNER SCREEN
   ============================================================ */
.scanner-screen {
    background: #000;
}

.scanner-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
    pointer-events: none;
}

.scanner-top-bar .icon-btn {
    color: #fff;
    background: rgba(0,0,0,0.45);
    pointer-events: all;
    flex-shrink: 0;
}

.scanner-top-bar .icon-btn:active {
    background: rgba(255,255,255,0.15);
}

.event-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Override html5-qrcode styles for full-screen coverage */
#qr-reader {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    border: none !important;
}

#qr-reader video {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    top: 0 !important;
    left: 0 !important;
}

#qr-reader__scan_region {
    position: absolute !important;
    inset: 0 !important;
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    height: 100% !important;
}

#qr-reader__scan_region > img {
    display: none !important;
}

#qr-reader__dashboard {
    display: none !important;
}

#qr-reader__header_message {
    display: none !important;
}

#qr-reader__status_span {
    display: none !important;
}

/* ============================================================
   RESULT OVERLAY
   ============================================================ */
.result-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
    pointer-events: none;
}

.result-overlay.visible {
    transform: translateY(0);
    pointer-events: auto;
    touch-action: none;
}

.result-overlay.held {
    filter: brightness(1.12);
}

.result-icon {
    width: 96px;
    height: 96px;
    color: #fff;
}

.result-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.result-main-text {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.25);
    max-width: 22ch;
}

.result-ticket-info {
    text-align: center;
    color: rgba(255, 255, 255, 0.92);
    max-width: 36ch;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* h2 #1 — movie title: subdued */
.result-ticket-info h2:nth-child(1) {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    margin: 0;
    line-height: 1.3;
}

/* h2 #2 — auditorium + datetime: prominent */
.result-ticket-info h2:nth-child(2) {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.35;
}

/* h2 #3 — seat + ticket number */
.result-ticket-info h2:nth-child(3) {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.seat-num {
    font-size: 1.7rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.ticket-num {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.result-extra-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.04em;
}

.result-stats-row {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 14px;
    padding: 0.85rem 1.75rem;
    margin-top: 0.1rem;
}

.result-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.result-stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.result-stat-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 5px;
    white-space: nowrap;
}

.result-stat-divider {
    width: 1px;
    height: 44px;
    background: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
    margin: 0 0.5rem;
}

.rstat-checked   { color: #fff; }
.rstat-remaining { color: rgba(255, 255, 255, 0.85); }

/* ============================================================
   ERROR SCREEN
   ============================================================ */
.error-icon {
    width: 68px;
    height: 68px;
    color: var(--muted);
}

.error-icon svg {
    width: 100%;
    height: 100%;
}

.error-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.error-msg {
    color: var(--muted);
    font-size: 0.9rem;
    max-width: 28ch;
    line-height: 1.6;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    background: var(--accent);
    color: #fff;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.primary-btn:active {
    opacity: 0.82;
}

.primary-btn svg {
    width: 18px;
    height: 18px;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 0.75rem 1.75rem;
    border-radius: 14px;
    font-size: 0.95rem;
}

.secondary-btn:active {
    background: var(--border);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 2.5rem));
    background: rgba(40, 40, 60, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 0.65rem 1.25rem;
    border-radius: 100px;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 999;
    transition: transform 0.25s ease;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   ZOOM BAR  (in scanner screen)
   ============================================================ */
.zoom-bar {
    position: absolute;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    left: 1rem;
    right: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 100px;
    padding: 0.5rem 1rem;
    pointer-events: all;
}

.zoom-label {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.zoom-value {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.zoom-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ============================================================
   SETTINGS SCREEN
   ============================================================ */
.settings-screen {
    background: var(--bg);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Greek locale: remove accents from capital letters via locale-aware capitalisation */
:lang(el) .result-main-text,
:lang(el) .top-bar-title,
:lang(el) .connecting-title,
:lang(el) .btn-title,
:lang(el) .error-title,
:lang(el) .app-version {
    text-transform: capitalize;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.settings-label {
    font-size: 0.95rem;
}

.settings-input-num {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.4rem 0.75rem;
    font-size: 0.88rem;
    width: 110px;
    text-align: right;
    -moz-appearance: textfield;
}

.settings-input-num::-webkit-outer-spin-button,
.settings-input-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.settings-input-num::placeholder {
    color: var(--muted);
}

.settings-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.4rem 0.75rem;
    font-size: 0.88rem;
    max-width: 55%;
    -webkit-appearance: none;
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.4;
}

.seg-control {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.seg-btn {
    flex: 1;
    padding: 0.55rem;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-right: 1px solid var(--border);
}

.seg-btn:last-child {
    border-right: none;
}

.seg-btn.active {
    background: var(--accent);
    color: #fff;
}

.format-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.format-chip {
    padding: 0.45rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.format-chip.active {
    background: rgba(233, 69, 96, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.refresh-app-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.35);
    border-radius: 12px;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.12s;
}

.refresh-app-btn:active {
    background: rgba(233, 69, 96, 0.22);
}

.refresh-app-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
