/* ═══════════════════════════════════════════════
   GLOVO PRINT v3 — 5 pestañas
   ═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&display=swap');

:root {
    --bg:          #000;
    --surface:     #111;
    --border:      #222;
    --green:       #00c853;
    --pink:        #e91e8c;
    --blue:        #3d5afe;
    --red:         #f44336;
    --key-bg:      #1c1c1c;
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
}

html, body { margin: 0; padding: 0; background: #0a0a0a; font-family: 'Arial Black', Arial, sans-serif; min-height: 100%; overscroll-behavior: none; }
body { display: flex; justify-content: center; align-items: flex-start; }

.app {
    width: 100%; max-width: 400px; min-height: 100dvh;
    display: flex; flex-direction: column;
    padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
    background: var(--bg);
}

@media (min-width: 480px) {
    body { justify-content: center; align-items: center; min-height: 100vh; padding: 30px 20px; }
    .app { min-height: auto; border-radius: 28px; border: 1.5px solid #1a1a1a; box-shadow: 0 24px 80px rgba(0,0,0,0.9); overflow: hidden; }
    .tab-content { max-height: 650px; overflow-y: auto; }
}

/* ── TABS ─────────────────────────────────────── */
.tabs {
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: #0a0a0a; border-bottom: 1.5px solid #1a1a1a; flex-shrink: 0;
}
.tab {
    padding: 8px 4px 6px; background: none; border: none; color: #444;
    font-size: clamp(22px, 6.5vw, 28px); cursor: pointer;
    border-bottom: 3px solid transparent; transition: color 0.2s, border-color 0.2s;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }

.tab-content { display: none; flex-direction: column; align-items: center; flex: 1; overflow-y: auto; padding: 10px 14px calc(10px + var(--safe-bottom)); gap: 10px; }
.tab-content.active { display: flex; }

/* ═══════════════════════════════════════════════
   TICKET
   ═══════════════════════════════════════════════ */
.ticket { width: 100%; max-width: 300px; border-radius: 6px; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.9); border: 1px solid #1a1a1a; }
.ticket-logo { background: linear-gradient(to bottom, #f0f0f0, #000); padding: 10px 0 8px; display: flex; justify-content: center; }
.ticket-logo img { width: 150px; height: auto; }
.ticket-display { background: linear-gradient(to bottom, #e8e8e8, #b8b8b8); padding: 6px 0 10px; display: flex; flex-direction: column; align-items: center; }
.ticket-number { font-family: 'Orbitron', monospace; font-size: clamp(68px, 21vw, 105px); font-weight: 900; line-height: 0.9; color: #111; -webkit-text-stroke: 1.5px rgba(255,255,255,0.9); letter-spacing: 2px; transition: transform 0.1s; }
.ticket-number.pulse { transform: scale(1.04); }
.ticket-info { font-family: 'Orbitron', monospace; font-size: clamp(34px, 10vw, 54px); font-weight: 700; line-height: 1; color: #111; -webkit-text-stroke: 1px rgba(255,255,255,0.8); letter-spacing: 3px; }


/* ── KEYPAD ───────────────────────────────────── */
.keypad { width: 100%; max-width: 300px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key { aspect-ratio: 1.75; min-height: 50px; background: var(--key-bg); border: 1.5px solid #2a2a2a; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-family: 'Arial Black', Arial, sans-serif; font-size: clamp(17px, 5vw, 23px); font-weight: 900; color: #fff; cursor: pointer; box-shadow: 0 3px 0 #0a0a0a, 0 4px 8px rgba(0,0,0,0.5); transition: transform 0.07s, box-shadow 0.07s, background 0.07s; -webkit-user-select: none; user-select: none; }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0a0a; background: var(--red); border-color: #7f0000; }
.key-ac { background: #180010; border-color: #3a0028; color: var(--pink); box-shadow: 0 3px 0 #0a0008, 0 4px 8px rgba(0,0,0,0.5); }
.key-ac:active { background: var(--pink); color: #fff; }
.key-x  { background: #00061a; border-color: #0d1a4a; color: #7b8fff; box-shadow: 0 3px 0 #000510, 0 4px 8px rgba(0,0,0,0.5); }
.key-x:active  { background: var(--blue); color: #fff; }

/* Botón X con valor actual — ocupa 2 columnas */
.key-send-x {
    grid-column: span 3;
    aspect-ratio: 1.75;
    min-height: 50px;
    background: #00061a;
    border: 1.5px solid #0d1a4a;
    border-radius: 8px;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: clamp(17px, 5vw, 23px);
    font-weight: 900;
    color: #7b8fff;
    cursor: pointer;
    box-shadow: 0 3px 0 #000510, 0 4px 8px rgba(0,0,0,0.5);
    transition: transform 0.07s, box-shadow 0.07s, background 0.07s;
    -webkit-user-select: none; user-select: none;
}
.key-send-x:active { background: var(--blue); color: #fff; transform: translateY(2px); box-shadow: 0 1px 0 #000510; }

.key-send { grid-column: span 3; min-height: 52px; background: #001a08; border: 1.5px solid #004d1a; border-radius: 8px; display: flex; justify-content: center; align-items: center; gap: 10px; font-family: 'Arial Black', Arial, sans-serif; font-size: clamp(14px, 4vw, 17px); font-weight: 900; color: var(--green); cursor: pointer; box-shadow: 0 3px 0 #001005, 0 4px 12px rgba(0,200,83,0.12); transition: transform 0.07s, box-shadow 0.07s, background 0.07s, color 0.07s; -webkit-user-select: none; user-select: none; }
.key-send:active { transform: translateY(2px); background: var(--green); color: #000; box-shadow: 0 1px 0 #001005; }
.key-send.loading { opacity: 0.6; pointer-events: none; }

/* ═══════════════════════════════════════════════
   ETIQUETAS
   ═══════════════════════════════════════════════ */
.labels-grid { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.label-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }

/* Frágil */
.label-preview { width: 100%; display: flex; flex-direction: column; }
.lp-stripe { height: 12px; background: repeating-linear-gradient(-45deg,#000 0,#000 7px,#fff 7px,#fff 14px); flex-shrink: 0; }
.lp-row { display: flex; justify-content: center; align-items: center; padding: 8px 0; }
.lp-black { background: #000; }
.lp-white { background: #fff; border: 2px solid #000; margin: 0 8px; border-radius: 4px; }
.lp-black span { font-size: clamp(24px, 7.5vw, 36px); font-weight: 900; color: #fff; letter-spacing: 4px; }
.lp-white span { font-size: clamp(20px, 6.5vw, 30px); font-weight: 900; color: #000; letter-spacing: 3px; }

/* POR INGRESAR */
.lp-single-black { background: #000; display: flex; justify-content: center; align-items: center; padding: 16px; }
.lp-single-black span { font-family: 'Arial Black', Arial, sans-serif; font-size: clamp(18px, 5.5vw, 26px); font-weight: 900; color: #fff; letter-spacing: 3px; text-align: center; }

/* BCNF */
.lp-bcnf { display: flex; flex-direction: column; }
.lp-bcnf-code { background: #fff; color: #000; font-size: clamp(22px, 7vw, 32px); font-weight: 900; letter-spacing: 4px; text-align: center; padding: 8px 0; border-bottom: 2px solid #000; }
.lp-bcnf-addr { background: #000; color: #fff; font-size: clamp(14px, 4.5vw, 20px); font-weight: 900; letter-spacing: 2px; text-align: center; padding: 6px 8px; }
.lp-bcnf-addr2 { background: #000; color: #fff; font-size: clamp(12px, 3.8vw, 17px); font-weight: 900; letter-spacing: 1px; text-align: center; padding: 0 8px 6px; }

.label-controls { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #0a0a0a; }
.qty-btn { width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid #333; background: #1a1a1a; color: #fff; font-size: 20px; font-weight: 900; cursor: pointer; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.qty-btn:active { background: #333; }
.qty-val { font-size: 20px; font-weight: 900; color: var(--green); min-width: 32px; text-align: center; }
.btn-send-label { flex: 1; height: 40px; background: #001a08; border: 1.5px solid #004d1a; border-radius: 8px; color: var(--green); font-family: 'Arial Black', Arial, sans-serif; font-size: 13px; font-weight: 900; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 6px; box-shadow: 0 2px 0 #001005; transition: background 0.1s, color 0.1s, transform 0.07s; }
.btn-send-label:active { background: var(--green); color: #000; transform: translateY(1px); box-shadow: none; }
.btn-send-label.loading { opacity: 0.6; pointer-events: none; }

/* ═══════════════════════════════════════════════
   PO
   ═══════════════════════════════════════════════ */
.po-preview { width: 100%; max-width: 300px; border-radius: 6px; overflow: hidden; border: 1px solid #1a1a1a; box-shadow: 0 6px 24px rgba(0,0,0,0.7); flex-shrink: 0; }
.po-row { padding: 10px 16px; display: flex; justify-content: center; align-items: center; }
.black-row { background: #000; }
.white-row { background: #fff; border-top: 2px solid #000; border-bottom: 2px solid #000; }
.po-label-text { font-size: clamp(22px, 7vw, 32px); font-weight: 900; color: #fff; letter-spacing: 4px; }
.po-number-text { font-family: 'Orbitron', monospace; font-size: clamp(24px, 7.5vw, 36px); font-weight: 900; color: #000; letter-spacing: 2px; }
.po-date-bar { background: #000; padding: 6px 14px; display: flex; justify-content: space-between; }
.po-date-bar span { font-size: 11px; font-weight: 900; color: #fff; }
.po-form { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 6px; }
.po-field-label { font-size: 11px; font-weight: 900; color: #444; letter-spacing: 1px; text-transform: uppercase; }
.po-input-row { display: flex; align-items: center; background: var(--key-bg); border: 1.5px solid #2a2a2a; border-radius: 8px; overflow: hidden; }
.po-prefix { padding: 0 12px; font-size: 18px; font-weight: 900; color: var(--green); border-right: 1.5px solid #2a2a2a; height: 48px; display: flex; align-items: center; flex-shrink: 0; }
.po-input { flex: 1; background: none; border: none; outline: none; color: #fff; font-family: 'Orbitron', monospace; font-size: 20px; font-weight: 700; padding: 0 12px; height: 48px; letter-spacing: 2px; }
.po-input::placeholder { color: #333; font-size: 14px; font-family: Arial; }
.po-qty-row { display: flex; align-items: center; gap: 16px; }
.qty-btn.big { width: 44px; height: 44px; font-size: 24px; }
.qty-val.big { font-size: 28px; min-width: 44px; }
.po-send { grid-column: unset; margin-top: 6px; width: 100%; }

/* ═══════════════════════════════════════════════
   PRODUCTOS
   ═══════════════════════════════════════════════ */
.search-box { width: 100%; display: flex; align-items: center; background: #1a1a1a; border: 1.5px solid #2a2a2a; border-radius: 10px; padding: 0 12px; gap: 8px; flex-shrink: 0; }
.search-icon { font-size: 16px; flex-shrink: 0; }
.search-input { flex: 1; background: none; border: none; outline: none; color: #fff; font-family: 'Arial Black', Arial, sans-serif; font-size: 14px; font-weight: 700; height: 46px; }
.search-input::placeholder { color: #333; font-weight: 400; font-family: Arial; }
.search-clear { background: none; border: none; color: #444; font-size: 16px; cursor: pointer; padding: 4px; display: none; }
.search-clear.show { display: block; }
.search-results { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.search-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 20px; color: #2a2a2a; }
.search-empty-icon { font-size: 48px; }
.search-empty-text { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.5; }
.search-loading { text-align: center; padding: 20px; color: #444; font-size: 12px; font-weight: 700; }
.result-card { width: 100%; background: #111; border: 1.5px solid #1e1e1e; border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.result-card:active, .result-card.selected { border-color: var(--green); background: #001a08; }
.result-img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #1a1a1a; flex-shrink: 0; }
.result-img-placeholder { width: 44px; height: 44px; border-radius: 6px; background: #1a1a1a; display: flex; justify-content: center; align-items: center; font-size: 20px; flex-shrink: 0; }
.result-info { flex: 1; min-width: 0; }
.result-name { font-size: 12px; font-weight: 900; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sku  { font-size: 11px; font-weight: 700; color: var(--green); margin-top: 2px; }
.product-selected { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.product-selected-info { background: #0a0a0a; border: 1.5px solid var(--green); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; }
.product-thumb { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.product-selected-text { flex: 1; min-width: 0; }
.product-sel-name { font-size: 12px; font-weight: 900; color: #fff; line-height: 1.3; }
.product-sel-sku  { font-size: 11px; font-weight: 700; color: var(--green); margin-top: 3px; }
.product-label-preview { width: 100%; background: #fff; border-radius: 6px; border: 1.5px solid #2a2a2a; display: flex; align-items: stretch; overflow: hidden; aspect-ratio: 2/1; max-height: 120px; }
.plp-left { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 4px 6px; gap: 2px; min-width: 0; border-right: 1px solid #ddd; }
.plp-name { font-family: 'Arial Black', Arial, sans-serif; font-size: 9px; font-weight: 900; color: #000; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.plp-sku  { font-family: monospace; font-size: 8px; font-weight: 700; color: #333; }
.plp-right { width: 80px; display: flex; justify-content: center; align-items: center; padding: 4px; flex-shrink: 0; }
.plp-qr canvas, .plp-qr img { width: 70px !important; height: 70px !important; }
.product-controls { display: flex; align-items: center; gap: 10px; width: 100%; }
.btn-send-product { flex: 1; height: 48px; background: #001a08; border: 1.5px solid #004d1a; border-radius: 8px; color: var(--green); font-family: 'Arial Black', Arial, sans-serif; font-size: 14px; font-weight: 900; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; box-shadow: 0 3px 0 #001005; transition: background 0.1s, color 0.1s, transform 0.07s; }
.btn-send-product:active { background: var(--green); color: #000; transform: translateY(2px); box-shadow: none; }
.btn-send-product.loading { opacity: 0.6; pointer-events: none; }

/* ═══════════════════════════════════════════════
   UBICACIONES
   ═══════════════════════════════════════════════ */
.loc-preview { width: 100%; max-width: 300px; background: #fff; border-radius: 6px; border: 1.5px solid #1a1a1a; display: flex; align-items: stretch; overflow: hidden; aspect-ratio: 2/1; max-height: 100px; flex-shrink: 0; box-shadow: 0 4px 16px rgba(0,0,0,0.7); }
.loc-left { flex: 1; display: flex; justify-content: center; align-items: center; padding: 4px 6px; border-right: 1px solid #ddd; }
.loc-code { font-family: 'Arial Black', Arial, sans-serif; font-size: clamp(14px, 4.5vw, 20px); font-weight: 900; color: #000; letter-spacing: 1px; text-align: center; }
.loc-right { width: 80px; display: flex; justify-content: center; align-items: center; padding: 6px; flex-shrink: 0; }
.loc-qr-placeholder { width: 60px; height: 60px; border: 2px dashed #ccc; border-radius: 4px; display: flex; justify-content: center; align-items: center; font-size: 11px; color: #aaa; font-weight: 700; }

.loc-section { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.loc-mode-tabs { display: flex; gap: 8px; }
.loc-mode { flex: 1; padding: 10px; background: #111; border: 1.5px solid #222; border-radius: 8px; color: #444; font-family: 'Arial Black', Arial, sans-serif; font-size: 13px; font-weight: 900; cursor: pointer; transition: all 0.15s; }
.loc-mode.active { border-color: var(--green); color: var(--green); background: #001a08; }

.loc-textarea { width: 100%; min-height: 100px; background: var(--key-bg); border: 1.5px solid #2a2a2a; border-radius: 8px; color: #fff; font-family: 'Orbitron', monospace; font-size: 13px; font-weight: 700; padding: 10px 12px; outline: none; resize: vertical; letter-spacing: 1px; line-height: 1.8; }
.loc-textarea::placeholder { color: #333; font-family: Arial; font-size: 12px; }

.loc-input { width: 100%; background: var(--key-bg); border: 1.5px solid #2a2a2a; border-radius: 8px; color: #fff; font-family: 'Orbitron', monospace; font-size: 16px; font-weight: 700; padding: 0 14px; height: 48px; outline: none; letter-spacing: 2px; text-transform: uppercase; }
.loc-input::placeholder { color: #333; font-family: Arial; font-size: 13px; text-transform: none; letter-spacing: 0; }

.loc-count { font-size: 11px; font-weight: 900; color: var(--green); text-align: right; padding: 2px 4px; }
.loc-send { grid-column: unset; margin-top: 4px; width: 100%; }

/* ═══════════════════════════════════════════════
   SPINNER / TOAST / LANDSCAPE
   ═══════════════════════════════════════════════ */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(0,200,83,0.25); border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite; display: none; flex-shrink: 0; }
.loading .spinner     { display: block; }
.loading .send-label,
.loading .send-label-txt { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: calc(20px + var(--safe-bottom)); left: 50%; transform: translateX(-50%) translateY(16px); background: #111; color: #fff; padding: 11px 24px; border-radius: 30px; font-family: 'Arial Black', Arial, sans-serif; font-size: 13px; font-weight: 900; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s; border: 1.5px solid #333; white-space: nowrap; box-shadow: 0 4px 20px rgba(0,0,0,0.6); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok  { border-color: var(--green); color: var(--green); }
.toast.err { border-color: var(--red);  color: var(--red);  }

.rotate-screen { display: none; position: fixed; inset: 0; background: #000; z-index: 9999; flex-direction: column; justify-content: center; align-items: center; gap: 12px; color: #fff; font-family: 'Arial Black', Arial, sans-serif; }
.rotate-screen .rotate-icon { font-size: 52px; animation: rotPhone 2s ease-in-out infinite; }
.rotate-screen p { font-size: 15px; font-weight: 900; color: #555; margin: 0; }
@keyframes rotPhone { 0%,100%{transform:rotate(0)} 50%{transform:rotate(90deg)} }
@media (orientation: landscape) and (max-height: 480px) { .rotate-screen { display: flex; } .app { display: none; } }

/* ═══════════════════════════════════════════════
   SELECTOR DE TIENDA
   ═══════════════════════════════════════════════ */
.store-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.store-box {
    width: 100%;
    max-width: 380px;
    background: #111;
    border: 1.5px solid #222;
    border-radius: 16px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 85vh;
}
.store-title {
    font-size: 18px;
    font-weight: 900;
    color: #00c853;
    text-align: center;
    letter-spacing: 1px;
}
.store-subtitle {
    font-size: 11px;
    font-weight: 700;
    color: #444;
    text-align: center;
}
.store-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 60vh;
}
.store-btn {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 1.5px solid #2a2a2a;
    border-radius: 10px;
    color: #fff;
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: 13px;
    font-weight: 900;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    letter-spacing: 0.5px;
}
.store-btn:active {
    background: #001a08;
    border-color: #00c853;
    color: #00c853;
}

/* ── STORE BADGE ──────────────────────────────── */
#storeBadge {
    font-size: 13px !important;
    font-weight: 900 !important;
    color: #00c853 !important;
    text-align: center !important;
    padding: 6px 12px !important;
    background: #001a08 !important;
    letter-spacing: 1px !important;
    cursor: pointer !important;
    border-bottom: 1px solid #004d1a !important;
    font-family: 'Arial Black', Arial, sans-serif !important;
}
#storeBadge:active { background: #004d1a !important; }