@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-card-hover: #1a1a1a;
    --text: #c0c0c0;
    --text-muted: #555555;
    --accent: #00ff88;
    --accent2: #00cc66;
    --green: #00ff88;
    --red: #ff3333;
    --border: #222222;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

html, body {
    font-family: 'Press Start 2P', monospace;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: none;
}

/* ============ APP SHELL ============ */

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

.fullscreen-map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

/* Match the CartoDB dark_all tile colour so loading tiles don't flash white */
.fullscreen-map,
.leaflet-container {
    background: #14171a !important;
}

/* ============ POPOVER (search form) ============ */

.popover-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    transition: opacity 0.4s, transform 0.4s;
}

.popover-overlay.hiding {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.search-popover {
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--border);
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.popover-title {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.popover-title .accent {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent), 0 0 20px rgba(0, 255, 136, 0.3);
}

.popover-sub {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ============ FORM ============ */

.form-section {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.7rem;
    margin-bottom: 0.6rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.form-input {
    width: 100%;
    padding: 0.9rem 1rem;
    background: #050505;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.7rem;
    font-family: 'Press Start 2P', monospace;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
    font-size: 0.6rem;
}

/* Brand chips */
.brand-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.brand-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    background: #050505;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.55rem;
    transition: all 0.1s;
    user-select: none;
}

.brand-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.chip-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
}

.brand-chip:hover {
    border-color: var(--accent);
}

.brand-chip.selected {
    background: rgba(0, 255, 136, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

/* Range slider */
.range-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: var(--border);
    outline: none;
    margin: 0.6rem 0;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 6px var(--accent);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.55rem;
    color: var(--text-muted);
}

/* Submit button */
.submit-btn {
    width: 100%;
    padding: 1rem;
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    font-size: 0.75rem;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.submit-btn:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.error-msg {
    margin-top: 1rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--red);
    color: var(--red);
    font-size: 0.55rem;
    line-height: 1.8;
}

/* ============ SCAN OVERLAY ============ */

.scan-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.scan-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.scan-content {
    text-align: left;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--border);
    padding: 1.2rem 1.5rem;
    width: 420px;
    max-width: 90vw;
    overflow: hidden;
}

.scan-log {
    max-height: 300px;
    overflow: hidden;
}

.log-line {
    font-size: 0.55rem;
    line-height: 2.2;
    animation: fadeIn 0.1s ease-out;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-spinner {
    color: var(--accent);
    display: inline-block;
    width: 1em;
    text-align: center;
}

.log-done {
    color: var(--accent);
    display: inline-block;
    width: 1em;
    text-align: center;
}

.log-cmd {
    color: #fff;
}

.log-sys {
    color: var(--text-muted);
}

.log-net {
    color: var(--accent);
}

.log-ok {
    color: #00ff88;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============ SIDEBAR ============ */

.deals-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 360px;
    height: 100vh;
    background: rgba(10, 10, 10, 0.95);
    border-right: 1px solid var(--border);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.deals-sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.6rem;
    display: block;
}

.back-btn:hover {
    text-shadow: 0 0 8px var(--accent);
}

.sidebar-header h2 {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.deal-count {
    color: var(--text-muted);
    font-size: 0.55rem;
}

.deals-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.deal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.1s;
}

.deal-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.08);
}

.deal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.brand-badge {
    padding: 3px 8px;
    font-size: 0.5rem;
    color: #fff;
}

.discount-badge {
    background: var(--red);
    color: #fff;
    padding: 3px 7px;
    font-size: 0.5rem;
}

.deal-product {
    font-size: 0.6rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 0.3rem;
}

.deal-description {
    font-size: 0.5rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    line-height: 1.8;
}

.deal-store {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.5rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.store-type {
    background: var(--border);
    padding: 2px 6px;
    font-size: 0.45rem;
}

.deal-price-row {
    display: flex;
    align-items: center;
}

.deal-prices {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.original-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.55rem;
}

.deal-price {
    color: var(--green);
    font-size: 0.7rem;
    text-shadow: 0 0 6px rgba(0, 255, 136, 0.4);
}

.no-deals {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.6rem;
}

.retry-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.6rem;
}

/* ============ MAP PINS ============ */

.sp-wrap {
    background: none !important;
    border: none !important;
}

.sp {
    position: relative;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.sp-price {
    background: var(--c, #00ff88);
    color: #000;
    font-size: 9px;
    font-family: 'Press Start 2P', monospace;
    padding: 4px 6px;
    line-height: 1.4;
    white-space: nowrap;
    position: relative;
}

.sp-price::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--c, #00ff88);
}

.sp-name {
    font-size: 7px;
    font-family: 'Press Start 2P', monospace;
    color: #888;
    margin-top: 3px;
    white-space: nowrap;
    text-shadow: 0 0 2px #000, 0 0 4px #000;
}

/* ============ SCROLLBAR ============ */

.deals-list::-webkit-scrollbar {
    width: 4px;
}

.deals-list::-webkit-scrollbar-track {
    background: var(--bg);
}

.deals-list::-webkit-scrollbar-thumb {
    background: var(--border);
}

.search-popover::-webkit-scrollbar {
    width: 4px;
}

.search-popover::-webkit-scrollbar-track {
    background: transparent;
}

.search-popover::-webkit-scrollbar-thumb {
    background: var(--border);
}

/* ============ LEAFLET OVERRIDES ============ */

.leaflet-control-zoom a {
    background: #111 !important;
    color: var(--accent) !important;
    border-color: var(--border) !important;
    border-radius: 0 !important;
    font-family: 'Press Start 2P', monospace !important;
}

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.9) !important;
    color: var(--text-muted) !important;
    font-family: 'Press Start 2P', monospace !important;
    font-size: 5px !important;
}

.leaflet-control-attribution a {
    color: var(--accent) !important;
}

.leaflet-popup-content-wrapper {
    background: #111 !important;
    color: var(--text) !important;
    border-radius: 0 !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8) !important;
}

.leaflet-popup-tip {
    background: #111 !important;
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .search-popover {
        max-width: 95vw;
        padding: 1.2rem;
    }

    .deals-sidebar {
        width: 100%;
    }

    .popover-title {
        font-size: 1rem;
    }
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: var(--red);
    padding: 1rem;
    color: white;
    font-size: 0.5rem;
}
