/* ===================================================================
   QRLens — Balanced Dark Slate Theme (Elegant Mid-Dark)
   =================================================================== */
:root {
    --bg: #111622;
    --surface: rgba(26, 32, 44, 0.85);
    --surface-solid: #1a202c;
    --surface-2: #242c3d;
    --surface-2-solid: #202736;
    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(49, 151, 149, 0.5);
    --text: #f7fafc;
    --text-muted: #a0aec0;
    --text-dim: #718096;

    /* Brand Accent Colors */
    --accent: #319795;
    --accent-secondary: #3182ce;
    --accent-gradient: linear-gradient(135deg, #319795 0%, #3182ce 100%);
    --accent-soft: rgba(49, 151, 149, 0.15);
    --accent-glow: 0 4px 20px rgba(49, 151, 149, 0.35);

    --gold: #f6ad55;
    --gold-glow: 0 0 16px rgba(246, 173, 85, 0.35);
    --danger: #fc8181;
    --danger-soft: rgba(252, 129, 129, 0.15);

    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;

    --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "JetBrains Mono", monospace;

    --shadow-main: 0 20px 45px -12px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
    --backdrop: blur(16px) saturate(180%);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Background Ambient Glow Blobs */
.bg-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    pointer-events: none;
    z-index: -1;
    opacity: 0.4;
}

.blob-1 {
    top: -100px;
    left: 15%;
    width: 600px;
    height: 450px;
    background: radial-gradient(circle, rgba(49, 151, 149, 0.25) 0%, rgba(49, 130, 206, 0.05) 70%, transparent 100%);
    animation: blob-float 16s ease-in-out infinite alternate;
}

.blob-2 {
    top: 250px;
    right: 5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(128, 90, 213, 0.18) 0%, rgba(49, 151, 149, 0.04) 70%, transparent 100%);
    animation: blob-float 20s ease-in-out infinite alternate-reverse;
}

@keyframes blob-float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(30px, 40px) scale(1.08);
    }

    100% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

h1,
h2,
h3,
.logo-text,
.average-number {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

a {
    color: #4fd1c5;
    transition: color 0.15s ease;
}

a:hover {
    color: #63b3ed;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ===================================================================
   Toast Notifications
   =================================================================== */
.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #1a202c;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    backdrop-filter: var(--backdrop);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.toast-success {
    border-color: rgba(49, 151, 149, 0.6);
}

.toast.toast-error {
    border-color: rgba(252, 129, 129, 0.6);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===================================================================
   Header & Badge
   =================================================================== */
.site-header {
    padding: 48px 24px 32px;
    display: flex;
    justify-content: center;
}

.header-inner {
    max-width: 720px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-soft);
    border: 1px solid rgba(49, 151, 149, 0.3);
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    font-weight: 600;
    color: #4fd1c5;
    margin-bottom: 20px;
    letter-spacing: 0.3px;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #4fd1c5;
    box-shadow: 0 0 8px #4fd1c5;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(1.3);
    }
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.logo-mark {
    position: relative;
    width: 32px;
    height: 32px;
}

.logo-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2.5px solid #319795;
}

.logo-corner.tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 4px;
}

.logo-corner.tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 4px;
}

.logo-corner.bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 4px;
}

.logo-corner.br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 4px;
}

.logo-text {
    font-size: 36px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.tagline {
    margin: 0;
    color: var(--text-muted);
    font-size: 16.5px;
    max-width: 580px;
}

/* ===================================================================
   Layout Shell
   =================================================================== */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 80px;
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* ===================================================================
   Tab Switcher
   =================================================================== */
.tab-switch {
    position: relative;
    display: inline-flex;
    gap: 6px;
    background: #1a202c;
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: var(--radius-pill);
    margin: 0 auto 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.tab-btn {
    position: relative;
    z-index: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14.5px;
    padding: 10px 28px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.is-active {
    color: #ffffff;
}

.tab-icon {
    transition: stroke 0.2s ease;
}

.tab-indicator {
    position: absolute;
    top: 6px;
    left: 6px;
    height: calc(100% - 12px);
    width: calc(50% - 6px);
    background: var(--accent-gradient);
    border-radius: var(--radius-pill);
    box-shadow: var(--accent-glow);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-switch[data-active="scan"] .tab-indicator {
    transform: translateX(100%);
}

/* ===================================================================
   Tool Panels & Controls
   =================================================================== */
.tool-section {
    display: flex;
    flex-direction: column;
}

.tool-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px;
    box-shadow: var(--shadow-main);
    backdrop-filter: var(--backdrop);
}

.panel-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 36px;
    align-items: start;
}

.control-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.label-hint {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 400;
}

textarea,
input[type="text"],
input[type="email"],
select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

textarea::placeholder,
input::placeholder {
    color: var(--text-dim);
}

textarea:focus,
input:focus,
select:focus {
    border-color: #319795;
    box-shadow: 0 0 0 3px rgba(49, 151, 149, 0.2);
    background: #1a202c;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

.select-wrapper::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 6px;
    background-color: var(--text-muted);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    pointer-events: none;
}

.option-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.option-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: var(--radius-md);
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.color-val-label {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14.5px;
    border-radius: var(--radius-pill);
    padding: 13px 26px;
    cursor: pointer;
    border: 1px solid transparent;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(49, 151, 149, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(49, 151, 149, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #4fd1c5;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-danger-soft {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(252, 129, 129, 0.3);
}

.btn-danger-soft:hover {
    background: rgba(252, 129, 129, 0.25);
    border-color: var(--danger);
    color: #ffffff;
}

.upload-label {
    margin: 0;
}

.hint-text {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===================================================================
   Viewfinder — High Tech Canvas Frame
   =================================================================== */
.viewfinder-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.viewfinder {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 320px;
    background: var(--surface-2-solid);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2.5px solid #319795;
    opacity: 0.9;
    z-index: 2;
    pointer-events: none;
}

.corner.tl {
    top: 12px;
    left: 12px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 6px;
}

.corner.tr {
    top: 12px;
    right: 12px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 6px;
}

.corner.bl {
    bottom: 12px;
    left: 12px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 6px;
}

.corner.br {
    bottom: 12px;
    right: 12px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 6px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
}

.empty-icon {
    color: var(--text-dim);
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 13.5px;
    margin: 0;
    line-height: 1.4;
}

.qr-output {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px;
}

.qr-output img,
.qr-output canvas {
    border-radius: 12px;
    max-width: 100% !important;
    height: auto !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: zoom-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes zoom-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#scan-reader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#scan-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scan-line {
    position: absolute;
    left: 6%;
    right: 6%;
    height: 3px;
    background: var(--accent-gradient);
    box-shadow: 0 0 16px 2px #319795;
    z-index: 3;
    animation: scan-sweep 2s ease-in-out infinite;
    border-radius: 2px;
}

@keyframes scan-sweep {
    0% {
        top: 10%;
    }

    50% {
        top: 88%;
    }

    100% {
        top: 10%;
    }
}

.scan-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.result-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.result-heading {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.status-badge {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.status-badge.is-success {
    background: var(--accent-soft);
    color: #4fd1c5;
}

.scan-result-box {
    background: var(--surface-2-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    min-height: 110px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
    display: flex;
    align-items: center;
    color: #4fd1c5;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

/* ===================================================================
   Ratings & Feedback Section
   =================================================================== */
.rating-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.rating-heading-text h2 {
    margin: 0 0 6px;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

.rating-heading-text p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
}

.average-display {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--backdrop);
}

.average-display .corner.tl,
.average-display .corner.br {
    width: 12px;
    height: 12px;
    border-width: 2px;
    opacity: 0.5;
}

.average-display .corner.tl {
    top: 6px;
    left: 6px;
}

.average-display .corner.br {
    bottom: 6px;
    right: 6px;
}

.average-number {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    color: var(--gold);
}

.average-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.average-stars {
    color: var(--gold);
    font-size: 16px;
    letter-spacing: 2px;
}

.rating-count-text {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.firebase-warning {
    background: rgba(252, 129, 129, 0.12);
    border: 1px solid rgba(252, 129, 129, 0.3);
    color: #feb2b2;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.firebase-warning code {
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.rating-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-main);
    backdrop-filter: var(--backdrop);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.star-picker-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.star-picker {
    display: flex;
    gap: 6px;
}

.star {
    background: none;
    border: none;
    font-size: 34px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    padding: 2px;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), color 0.15s ease;
}

.star:hover {
    transform: scale(1.2);
}

.star.is-filled {
    color: var(--gold);
    filter: drop-shadow(0 2px 6px rgba(246, 173, 85, 0.4));
}

.star-hint-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
}

.form-error {
    color: var(--danger);
    font-size: 13.5px;
    margin: 0;
    font-weight: 500;
}

#submit-rating-btn {
    align-self: flex-start;
}

/* Ratings List & Cards */
.ratings-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ratings-list-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.ratings-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.ratings-list .placeholder-text {
    grid-column: 1 / -1;
    text-align: left;
    padding: 16px 0;
}

.rating-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--backdrop);
    animation: card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.rating-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.4);
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rating-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(49, 151, 149, 0.35);
    flex-shrink: 0;
}

.rating-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.rating-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rating-stars {
    color: var(--gold);
    font-size: 13.5px;
    letter-spacing: 1.5px;
}

.rating-date {
    color: var(--text-dim);
    font-size: 12px;
    margin-left: auto;
    font-weight: 500;
}

/* ===================================================================
   Footer
   =================================================================== */
.site-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    padding: 32px 20px 48px;
    border-top: 1px solid var(--border);
}

/* ===================================================================
   Responsive Breakpoints
   =================================================================== */
@media (max-width: 768px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }

    .viewfinder-col {
        order: -1;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .option-row {
        grid-template-columns: 1fr;
    }

    .tool-panel,
    .rating-form {
        padding: 24px;
    }

    .rating-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .average-display {
        width: 100%;
    }

    .star-picker-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}