/* =========================================================
   Can I Sell This? — Mobile-first PWA styles
   ========================================================= */

:root {
    --bg: #0b1220;
    --bg-2: #111a2e;
    --card: #172238;
    --card-2: #1e2a44;
    --text: #f4f6fb;
    --text-muted: #97a3bd;
    --accent: #3b82f6;
    --accent-2: #2563eb;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --border: rgba(255,255,255,0.08);
    --radius: 16px;
    --radius-lg: 22px;
    --shadow: 0 10px 30px rgba(0,0,0,0.35);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: linear-gradient(180deg, #0b1220 0%, #0f1a33 100%);
}

.app-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ---------- Screens ---------- */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    background: var(--bg);
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.screen.screen-active {
    transform: translateX(0);
    z-index: 5;
}

.screen.screen-prev {
    transform: translateX(-30%);
    opacity: 0.4;
    z-index: 1;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 18, 32, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header.dark {
    background: rgba(0,0,0,0.5);
    border-bottom-color: rgba(255,255,255,0.06);
}

.app-header h1, .app-header h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    flex: 1;
    text-align: center;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.app-brand i {
    font-size: 22px;
    color: var(--accent);
}

.app-brand h1 {
    text-align: left;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s;
}

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

.header-spacer {
    width: 40px;
}

/* ---------- Home screen ---------- */
.home-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 40px;
    -webkit-overflow-scrolling: touch;
}

.hero-card {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.hero-title {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.hero-sub {
    margin: 10px 0 0;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--card);
    font-size: 14px;
}

.legend-row i {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.legend-green i { color: var(--green); }
.legend-yellow i { color: var(--yellow); }
.legend-red i { color: var(--red); }

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 700;
    font-size: 16px;
    padding: 14px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
    width: 100%;
}

.primary-btn.big {
    padding: 18px;
    font-size: 17px;
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.primary-btn:active {
    transform: scale(0.98);
    background: var(--accent-2);
}

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

.home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.tab-btn {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tab-btn i {
    font-size: 18px;
    color: var(--accent);
}

.disclaimer {
    margin-top: 20px;
    padding: 14px;
    background: var(--card);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    border: 1px solid var(--border);
}

.disclaimer i {
    color: var(--accent);
    margin-right: 6px;
}

.disclaimer strong {
    color: var(--text);
}

/* ---------- Scan screen ---------- */
#scan-screen {
    background: #000;
}

.camera-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: #000;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-reticle {
    width: 78%;
    max-width: 320px;
    aspect-ratio: 1;
    border: 3px solid rgba(255,255,255,0.8);
    border-radius: 24px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
    position: relative;
    animation: reticle-pulse 2s infinite;
}

.scan-reticle::before,
.scan-reticle::after {
    content: '';
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: var(--accent);
    border-style: solid;
    border-width: 0;
}

.scan-reticle::before {
    top: -3px; left: -3px;
    border-top-width: 4px; border-left-width: 4px;
    border-top-left-radius: 24px;
}

.scan-reticle::after {
    bottom: -3px; right: -3px;
    border-bottom-width: 4px; border-right-width: 4px;
    border-bottom-right-radius: 24px;
}

@keyframes reticle-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.45; }
}

.scan-hint {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

.live-signals {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    pointer-events: none;
}

.signal-chip {
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.15);
}

.signal-chip i {
    color: var(--accent);
}

.scan-actions {
    padding: 16px;
    background: rgba(0,0,0,0.85);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.scan-tip {
    margin: 10px 0 0;
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

/* ---------- Analyzing screen ---------- */
.analyzing-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.pulse-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    margin-bottom: 24px;
    animation: pulse-ring 1.6s infinite;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55);
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55); }
    70% { box-shadow: 0 0 0 24px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.analyzing-body h2 {
    margin: 0 0 24px;
    font-size: 22px;
    font-weight: 700;
}

.progress-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-steps li {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--card);
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.progress-steps li i {
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.progress-steps li.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--text);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.progress-steps li.done {
    color: var(--green);
}

.progress-steps li.done i::before {
    content: '\f058'; /* solid check-circle */
}

/* ---------- Result screen ---------- */
.result-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.decision-badge {
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.decision-badge::before {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0.12;
    z-index: 0;
}

.decision-badge.green { color: var(--green); }
.decision-badge.yellow { color: var(--yellow); }
.decision-badge.red { color: var(--red); }

.decision-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    font-size: 26px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.decision-icon i {
    color: white;
}

.decision-text {
    position: relative;
    z-index: 1;
}

.decision-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}

.decision-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.result-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.result-section h3 {
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.item-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}

.item-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.item-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.item-meta i {
    color: var(--accent);
}

.price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.price-cell {
    background: var(--card-2);
    border-radius: 12px;
    padding: 12px;
}

.price-cell-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.price-cell-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}

.price-source {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
    font-style: italic;
}

.explanation-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.explanation-list li {
    padding: 8px 0;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.explanation-list li:last-child { border-bottom: none; }

.explanation-list li i {
    color: var(--accent);
    margin-top: 3px;
}

.vero-matched {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.vero-clear {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.secondary-btn {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

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

/* ---------- History screen ---------- */
.history-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.history-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.history-dot.green { background: var(--green); }
.history-dot.yellow { background: var(--yellow); }
.history-dot.red { background: var(--red); }

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

.history-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

/* ---------- Brands screen ---------- */
.brands-search {
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.brands-search i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.brands-search input {
    width: 100%;
    padding: 12px 14px 12px 38px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.brands-search input:focus {
    border-color: var(--accent);
}

.brands-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 40px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.brand-letter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

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

.brand-name {
    font-weight: 600;
    font-size: 15px;
}

.brand-notes {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.risk-pill {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.risk-pill.high { background: rgba(239,68,68,0.18); color: #fca5a5; }
.risk-pill.medium { background: rgba(245,158,11,0.18); color: #fcd34d; }
.risk-pill.low { background: rgba(34,197,94,0.18); color: #86efac; }

/* ---------- Settings ---------- */
.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.setting-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.setting-card.info-card {
    flex-direction: column;
    align-items: flex-start;
}

.setting-card.info-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.setting-card.info-card p {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
}

.setting-card.info-card a {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.setting-label {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.setting-card select {
    background: var(--card-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--card-2);
    transition: 0.2s;
    border-radius: 999px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: white;
    transition: 0.2s;
    border-radius: 50%;
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------- Empty states ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 16px;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

.loading-text {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--card-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
    max-width: 86%;
    text-align: center;
}

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

/* ---------- Scrollbar hide on mobile ---------- */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ---------- Extra-small screens ---------- */
@media (max-height: 640px) {
    .hero-title { font-size: 22px; }
    .hero-card { padding: 18px; }
}
