/* Door Scanner PWA — Styles */

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --text: #e8e8e8;
    --text-muted: #777;
    --accent: #4a90d9;
    --green: #00c853;
    --red: #ff1744;
    --yellow: #ffc107;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-text-size-adjust: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

/* ── Status bar ─────────────────────────────────── */

#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--surface);
    border-bottom: 1px solid #222;
    z-index: 10;
    flex-shrink: 0;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
}

.indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.indicator.online::before { background: var(--green); }
.indicator.offline::before { background: var(--red); }
.indicator.on::before { background: var(--green); }
.indicator.off::before { background: var(--text-muted); }

/* ── Camera viewport ────────────────────────────── */

#viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 0; /* flex child shrink fix */
}

#reader {
    width: 100%;
    height: 100%;
}

/* Force html5-qrcode video to fill viewport */
#reader video {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
}

/* Hide library's default file-scan UI elements */
#reader img[alt="Info"],
#reader span:has(> a[href*="scanapp"]) {
    display: none !important;
}

#placeholder {
    position: absolute;
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

#placeholder .placeholder-icon {
    font-size: 64px;
    margin-bottom: 12px;
    opacity: 0.5;
}

#placeholder p {
    font-size: 18px;
    line-height: 1.5;
}

#placeholder.hidden {
    display: none;
}

/* ── Feedback overlay ───────────────────────────── */

#feedback {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: feedbackIn 0.12s ease-out;
}

@keyframes feedbackIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

#feedback.hidden {
    display: none;
}

#feedback.ok      { background: rgba(0, 200, 83, 0.94); }
#feedback.error   { background: rgba(255, 23, 68, 0.94); }
#feedback.warning { background: rgba(255, 193, 7, 0.94); color: #1a1a00; }
#feedback.checking { background: rgba(20, 20, 40, 0.92); }

#feedback-status {
    font-size: 80px;
    font-weight: 700;
    line-height: 1;
}

#feedback-message {
    font-size: 28px;
    font-weight: 600;
    margin-top: 10px;
    text-align: center;
    padding: 0 20px;
    max-width: 400px;
    word-break: break-word;
}

#feedback-name {
    font-size: 22px;
    font-weight: 500;
    margin-top: 14px;
    opacity: 0.9;
    text-align: center;
    padding: 0 20px;
}

#feedback-name:empty {
    display: none;
}

/* ── Controls ───────────────────────────────────── */

#controls {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid #222;
    z-index: 10;
    flex-shrink: 0;
}

.btn {
    flex: 1;
    padding: 14px 6px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.btn:active {
    opacity: 0.8;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-secondary { background: #2a2a3e; color: var(--text); }

/* ── Settings modal ─────────────────────────────── */

#settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#settings-overlay.hidden {
    display: none;
}

#settings-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
}

#settings-panel h2 {
    font-size: 20px;
    margin-bottom: 18px;
}

#settings-panel label {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.required {
    color: var(--red);
}

#settings-panel input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #333;
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 16px; /* >=16px prevents iOS zoom on focus */
    margin-bottom: 8px;
    outline: none;
}

#settings-panel input:focus {
    border-color: var(--accent);
}

#key-warning {
    color: var(--yellow);
    font-size: 13px;
    margin-bottom: 8px;
}

#key-warning.hidden {
    display: none;
}

.settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.settings-actions .btn {
    padding: 12px;
}
