/* qr-scanner.css — tool-specific styles */

/* ── Main layout ─────────────────────────────────────────────────────────── */
.qrs-main {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Tab switcher ────────────────────────────────────────────────────────── */
.qrs-tabs {
    display: flex;
    gap: 0.4rem;
}

.qrs-tab {
    padding: 0.45rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.qrs-tab.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.qrs-tab:not(.active):hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ── Panel container ─────────────────────────────────────────────────────── */
.qrs-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* ── Video / webcam area ─────────────────────────────────────────────────── */
.qrs-video-wrap {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 4 / 3;
    background: #111;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: 0 auto;
    border: 2px solid var(--color-border);
}

.qrs-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Hidden canvas used for pixel sampling by jsQR */
.qrs-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

/* ── Corner crosshair overlay ────────────────────────────────────────────── */
.qrs-crosshair {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.crosshair-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: rgba(255, 255, 255, 0.85);
    border-style: solid;
}

.crosshair-corner.tl {
    top: 14%;
    left: 14%;
    border-width: 3px 0 0 3px;
    border-top-left-radius: 3px;
}

.crosshair-corner.tr {
    top: 14%;
    right: 14%;
    border-width: 3px 3px 0 0;
    border-top-right-radius: 3px;
}

.crosshair-corner.bl {
    bottom: 14%;
    left: 14%;
    border-width: 0 0 3px 3px;
    border-bottom-left-radius: 3px;
}

.crosshair-corner.br {
    bottom: 14%;
    right: 14%;
    border-width: 0 3px 3px 0;
    border-bottom-right-radius: 3px;
}

/* ── Animated scan line ──────────────────────────────────────────────────── */
.qrs-scan-line {
    position: absolute;
    left: 14%;
    right: 14%;
    top: 14%;
    height: 2px;
    background: linear-gradient(
        to right,
        transparent,
        rgba(74, 144, 226, 0.85) 20%,
        #4a90e2 50%,
        rgba(74, 144, 226, 0.85) 80%,
        transparent
    );
    border-radius: 1px;
    animation: qrs-scan 2.4s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(74, 144, 226, 0.7);
    display: none; /* shown only when camera is active */
}

@keyframes qrs-scan {
    0%   { top: 14%; }
    50%  { top: 81%; }
    100% { top: 14%; }
}

.qrs-video-wrap.scanning .qrs-scan-line {
    display: block;
}

/* ── Camera controls ─────────────────────────────────────────────────────── */
.qrs-cam-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.qrs-btn-stop {
    background-color: #c0392b;
}

.qrs-btn-stop:hover {
    background-color: #a93226;
}

.qrs-cam-select {
    flex: 1;
    min-width: 160px;
    max-width: 280px;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
}

/* ── Hint text below camera ──────────────────────────────────────────────── */
.qrs-hint {
    margin: 0;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* ── Upload drop zone ────────────────────────────────────────────────────── */
.qrs-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    text-align: center;
    min-height: 120px;
    gap: 0.6rem;
}

.qrs-drop:hover,
.qrs-drop.dragover {
    border-color: var(--color-primary);
    background: #f0f8ff;
    color: var(--color-primary);
}

.qrs-drop-icon {
    font-size: 2.2rem;
    line-height: 1;
}

/* Hide the actual file input but keep it functional */
.qrs-drop input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ── Uploaded image preview ──────────────────────────────────────────────── */
.qrs-upload-preview {
    display: flex;
    justify-content: center;
}

.qrs-preview-img {
    max-width: 100%;
    max-height: 320px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    object-fit: contain;
}

/* ── Result box ──────────────────────────────────────────────────────────── */
.qrs-result-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.qrs-result-label {
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f0f4fa;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.qrs-result-box {
    padding: 0.9rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    word-break: break-all;
    line-height: 1.6;
    color: var(--color-text);
    min-height: 2.5rem;
    white-space: pre-wrap;
}

/* Link result styles */
.qrs-result-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    word-break: break-all;
}

.qrs-result-link:hover {
    text-decoration: underline;
    color: var(--color-primary-dk);
}

/* Result type badge */
.qrs-type-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 3px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.qrs-type-url   { background: #d4edda; color: #155724; border: 1px solid #b8dfc8; }
.qrs-type-email { background: #fff3cd; color: #856404; border: 1px solid #f5dba0; }
.qrs-type-phone { background: #cff4fc; color: #0c5460; border: 1px solid #9eeaf9; }
.qrs-type-text  { background: #f8f9fa; color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ── Action buttons under result ─────────────────────────────────────────── */
.qrs-result-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.qrs-action-btn {
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-family: var(--font-main);
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.qrs-action-btn:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.qrs-action-btn.copied {
    background: #28a745;
    color: #fff;
    border-color: #28a745;
}

/* ── Flash effect when a new QR code is detected ─────────────────────────── */
@keyframes qrs-flash {
    0%   { box-shadow: inset 0 0 0 3px rgba(74, 144, 226, 0); }
    30%  { box-shadow: inset 0 0 0 3px rgba(74, 144, 226, 0.8); }
    100% { box-shadow: inset 0 0 0 3px rgba(74, 144, 226, 0); }
}

.qrs-video-wrap.flash {
    animation: qrs-flash 0.5s ease-out;
}

/* ── Success indicator (corner highlight when QR detected) ───────────────── */
.qrs-video-wrap.detected .crosshair-corner {
    border-color: #28a745;
    transition: border-color 0.2s;
}

/* ── Status / error message ──────────────────────────────────────────────── */
.qrs-message {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

.qrs-message.error {
    background: #fff0f0;
    border: 1px solid #f5c2c2;
    color: #c00;
}

.qrs-message.info {
    background: #eef4ff;
    border: 1px solid #c7d9f8;
    color: #1a4a8a;
}

.qrs-message.success {
    background: #d4edda;
    border: 1px solid #b8dfc8;
    color: #155724;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .qrs-video-wrap {
        aspect-ratio: 1 / 1;
    }

    .crosshair-corner {
        width: 20px;
        height: 20px;
    }

    .qrs-cam-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .qrs-cam-select {
        max-width: 100%;
    }
}
