@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ══════════════════════════════════════════════════════
   NOTHING × M3 — Dark Theme  |  Dynamic Color Edition
══════════════════════════════════════════════════════ */

:root {
    /* Backgrounds - AMOLED Black */
    --bg-main:          #000000;
    --bg-surface:       #050505;
    --bg-surface-2:     #0a0a0a;
    --bg-surface-3:     #111111;

    /* Dynamic primary — JS updates --primary, --primary-rgb, --primary-hover, --primary-glow */
    --primary:          #ff3b3b;
    --primary-hover:    #ff5c5c;
    --primary-rgb:      255, 59, 59;
    --primary-glow:     rgba(var(--primary-rgb), 0.28);

    /* Static brand neons */
    --neon-blue:        #3d88ff;
    --neon-purple:      #b044ff;
    --neon-green:       #00e5a0;
    --neon-yellow:      #ffe03d;

    /* Text */
    --text-main:        #f0f0f0;
    --text-muted:       #888888;
    --text-subhead:     #444444;

    /* Borders */
    --border:           rgba(255, 255, 255, 0.05);
    --border-hover:     rgba(255, 255, 255, 0.12);

    /* Inputs */
    --input-bg:         #080808;
    --input-border:     rgba(255, 255, 255, 0.08);
    --input-focus:      var(--primary);

    /* Semantic (fixed — not tied to primary) */
    --danger:           #ff4040;
    --danger-bg:        rgba(255, 64, 64, 0.10);
    --success:          #00e5a0;
    --success-bg:       rgba(0, 229, 160, 0.10);
    --warning-color:    #ffe03d;
    --warning-bg:       rgba(255, 224, 61, 0.08);

    /* Shadows */
    --shadow-sm:   0 1px 4px rgba(0,0,0,0.6);
    --shadow-md:   0 4px 20px rgba(0,0,0,0.6);
    --shadow-lg:   0 8px 40px rgba(0,0,0,0.7);

    /* Border Radius */
    --radius-pill:   999px;
    --radius-card:   28px;
    --radius-inner:  18px;
    --radius-btn:    999px;
}

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

/* ══════════════════════════════════════════════════════
   BODY
══════════════════════════════════════════════════════ */
body {
    font-family: 'Outfit', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2.5rem 1.5rem;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Fixed background canvas */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    max-width: 680px;
    position: relative;
    z-index: 1;
}

/* ══════════════════════════════════════════════════════
   BOTÃO VOLTAR
══════════════════════════════════════════════════════ */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.55rem 1.25rem 0.55rem 0.9rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    transition: all 0.25s ease;
    align-self: flex-start;
}

.btn-back:hover {
    color: var(--text-main);
    background: rgba(var(--primary-rgb), 0.08);
    border-color: rgba(var(--primary-rgb), 0.4);
    box-shadow: 0 0 18px rgba(var(--primary-rgb), 0.15);
}

.btn-back svg { transition: transform 0.2s ease; }
.btn-back:hover svg { transform: translateX(-3px); }

/* ══════════════════════════════════════════════════════
   TABS NAV
══════════════════════════════════════════════════════ */
.tabs-nav {
    display: flex;
    background: rgba(5, 5, 5, 0.85);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    padding: 0.35rem;
    border-radius: var(--radius-pill);
    gap: 0.25rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 20px var(--primary-glow), 0 2px 8px rgba(var(--primary-rgb), 0.25);
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════
   CARD / GLASS PANEL  +  Mouse-following grid
══════════════════════════════════════════════════════ */
.glass-panel {
    background: rgba(5, 5, 5, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 2.5rem 2.25rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        var(--shadow-md),
        inset 0 1px 0 rgba(255,255,255,0.03);
    position: relative;
    overflow: hidden;
    /* Updated by JS for mouse/touch grid */
    --mx: -300px;
    --my: -300px;
}

/* Inner corner glow (follows primary color) */
.glass-panel::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transition: background 0.5s ease;
}

/* Mouse/touch-following dot grid spotlight */
.glass-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 2;
    background-image:
        /* Color tint at cursor position */
        radial-gradient(
            circle 200px at var(--mx) var(--my),
            rgba(var(--primary-rgb), 0.08) 0%,
            transparent 100%
        ),
        /* Horizontal grid lines */
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 27px,
            rgba(255,255,255,0.075) 27px,
            rgba(255,255,255,0.075) 28px
        ),
        /* Vertical grid lines */
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 27px,
            rgba(255,255,255,0.075) 27px,
            rgba(255,255,255,0.075) 28px
        );
    /* Spotlight mask — reveals grid only near cursor */
    -webkit-mask-image: radial-gradient(
        circle 240px at var(--mx) var(--my),
        black    0%,
        rgba(0,0,0,0.6) 40%,
        rgba(0,0,0,0.1) 75%,
        transparent 100%
    );
    mask-image: radial-gradient(
        circle 240px at var(--mx) var(--my),
        black    0%,
        rgba(0,0,0,0.6) 40%,
        rgba(0,0,0,0.1) 75%,
        transparent 100%
    );
}

/* Panel content above the grid overlay */
.glass-panel > * {
    position: relative;
    z-index: 3;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.header h2 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #ffffff 0%, #888888 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p { color: var(--text-muted); font-size: 0.925rem; }
.mt-2     { margin-top: 1.5rem; }
.hidden   { display: none !important; }

/* ══════════════════════════════════════════════════════
   FILE UPLOAD
══════════════════════════════════════════════════════ */
.file-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(5, 5, 5, 0.6);
    border: 2px dashed rgba(255, 255, 255, 0.08);
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-inner);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    -webkit-tap-highlight-color: transparent;
}

.file-upload-btn:hover {
    background: rgba(var(--primary-rgb), 0.06);
    border-color: rgba(var(--primary-rgb), 0.45);
    color: var(--text-main);
    box-shadow: 0 0 24px rgba(var(--primary-rgb), 0.10);
}

.file-upload-btn svg {
    color: var(--primary);
    transition: transform 0.2s ease;
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

.file-upload-btn:hover svg { transform: translateY(-3px); }

.drop-active-label { display: none; }

.file-upload-btn.dragover {
    background: rgba(var(--primary-rgb), 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.2);
}

.file-upload-btn.dragover .drop-label { display: none; }
.file-upload-btn.dragover .drop-active-label {
    display: inline;
    color: var(--primary);
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════
   FORMS & INPUTS
══════════════════════════════════════════════════════ */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
}

.input-row { display: flex; gap: 1rem; }
.number-group { flex: 1; }

label {
    font-size: 0.83rem;
    font-weight: 500;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

input[type="text"] {
    width: 100%;
    padding: 0.875rem 1.125rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-inner);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18), 0 0 20px rgba(var(--primary-rgb), 0.08);
    background: #121212;
}

input[type="text"]::placeholder { color: var(--text-subhead); }

.hint { font-size: 0.75rem; color: var(--text-subhead); margin-top: 0.35rem; }

/* ══════════════════════════════════════════════════════
   BOTÕES
══════════════════════════════════════════════════════ */
button {
    width: 100%;
    padding: 0.9rem 1.5rem;
    border: none;
    border-radius: var(--radius-btn);
    font-family: inherit;
    font-size: 0.925rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button:active { transform: scale(0.96) translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 12px var(--primary-glow), 0 0 30px rgba(var(--primary-rgb), 0.08);
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 22px rgba(var(--primary-rgb), 0.5), 0 0 50px rgba(var(--primary-rgb), 0.15);
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: rgba(5, 5, 5, 0.6);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn-zip {
    background: #00c48c;
    box-shadow: 0 2px 12px rgba(0, 196, 140, 0.3);
}

.btn-zip:hover {
    background: #00d69a;
    box-shadow: 0 4px 22px rgba(0, 196, 140, 0.5);
}

.btn-zip .zip-loading { display: none; }
.btn-zip.loading .zip-label { display: none; }
.btn-zip.loading .zip-loading { display: inline; }
.btn-zip.loading { pointer-events: none; opacity: 0.7; }

.btn-danger-outline {
    border-color: rgba(255, 59, 59, 0.5);
    color: #ff3b3b;
}

.btn-danger-outline:hover {
    background: rgba(255, 59, 59, 0.1);
    border-color: rgba(255, 59, 59, 0.7);
    color: #ff6b6b;
}

/* ══════════════════════════════════════════════════════
   PREVIEW WRAPPER
══════════════════════════════════════════════════════ */
.preview-wrapper {
    background: #000000;
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
    box-shadow: var(--shadow-lg);
}

/* ══════════════════════════════════════════════════════
   CONTROLS
══════════════════════════════════════════════════════ */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.control-box {
    background: rgba(5, 5, 5, 0.6);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius-inner);
}

.control-box h3 {
    font-size: 0.75rem;
    color: var(--primary);
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    font-weight: 700;
    border-left: 2px solid var(--primary);
    padding-left: 0.6rem;
    text-shadow: 0 0 10px var(--primary-glow);
    transition: color 0.5s ease, text-shadow 0.5s ease;
}

.range-group { margin-bottom: 1.25rem; }
.range-group:last-child { margin-bottom: 0; }

.range-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.83rem;
    margin-bottom: 0.5rem;
    text-transform: none;
}

.range-val {
    font-family: 'Outfit', monospace;
    color: var(--primary);
    font-weight: 600;
    text-shadow: 0 0 8px var(--primary-glow);
    transition: color 0.5s ease;
}

/* ══════════════════════════════════════════════════════
   RANGE SLIDER
══════════════════════════════════════════════════════ */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    outline: none;
    cursor: pointer;
    touch-action: pan-x;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid #000000;
    box-shadow: 0 0 10px var(--primary-glow);
    transition: background 0.4s ease, box-shadow 0.4s ease, width 0.15s ease, height 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    width: 22px;
    height: 22px;
    box-shadow: 0 0 18px rgba(var(--primary-rgb), 0.5);
}

/* ══════════════════════════════════════════════════════
   TAB CONTENT
══════════════════════════════════════════════════════ */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-content.active { display: block; }

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

/* ══════════════════════════════════════════════════════
   ALERTAS
══════════════════════════════════════════════════════ */
.warning-alert {
    background: var(--warning-bg);
    border: 1px solid rgba(255, 224, 61, 0.25);
    border-radius: var(--radius-inner);
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    color: var(--warning-color);
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* ══════════════════════════════════════════════════════
   BARRA DE AÇÕES
══════════════════════════════════════════════════════ */
.actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* ══════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 4rem 1rem;
    gap: 1rem;
    text-align: center;
    background: rgba(5, 5, 5, 0.4);
    border: 1px dashed rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-inner);
}

.empty-state svg { color: var(--text-subhead); }
.empty-state p   { font-size: 0.95rem; }

/* ══════════════════════════════════════════════════════
   LISTA DE CADASTROS
══════════════════════════════════════════════════════ */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.25rem;
    -webkit-overflow-scrolling: touch;
}

.products-grid::-webkit-scrollbar { width: 4px; }
.products-grid::-webkit-scrollbar-track { background: transparent; }
.products-grid::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.3);
    border-radius: 999px;
}
.products-grid::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.product-card {
    background: rgba(5, 5, 5, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 0.875rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.product-card:hover, .product-card:active {
    background: rgba(var(--primary-rgb), 0.05);
    border-color: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.07);
    transform: translateY(-1px);
}

.product-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.15rem;
}

.product-info p { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

.product-actions { display: flex; gap: 0.5rem; }

.action-btn {
    background: rgba(5, 5, 5, 0.6);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.55rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
    background: rgba(61, 136, 255, 0.12);
    border-color: rgba(61, 136, 255, 0.4);
    color: #3d88ff;
}

.action-btn.delete:hover {
    background: var(--danger-bg);
    border-color: rgba(255, 64, 64, 0.5);
    color: var(--danger);
}

/* ══════════════════════════════════════════════════════
   MINIATURA PREVIEW
══════════════════════════════════════════════════════ */
.preview-miniature {
    text-align: center;
    background: #000000;
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: var(--radius-inner);
}

.preview-miniature .barcode-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ══════════════════════════════════════════════════════
   REDUCED MOTION
══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #bg-canvas { display: none; }

    .glass-panel::after { display: none; }

    .tab-content { animation: none; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    body { padding: 1.5rem 1rem; }
    .glass-panel { padding: 1.75rem 1.25rem; }
    .input-row { flex-direction: column; gap: 0; }
    .actions-bar { flex-direction: column; }
    .tabs-nav { border-radius: var(--radius-inner); }
    .tab-btn { font-size: 0.78rem; padding: 0.6rem 0.5rem; gap: 0.3rem; }
    .tab-btn svg { display: none; }
}