/* FilAr Logística — Industrial Modern Touch UI
   Aligned with Breva theme palette: dark, glass, neon accents */

:root {
  --bg: #080a12;
  --bg-elev: #0f1320;
  --card: rgba(77, 95, 255, 0.06);
  --card-hover: rgba(77, 95, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(77, 95, 255, 0.40);
  --primary: #4D5FFF;
  --primary-glow: rgba(77, 95, 255, 0.45);
  --secondary: #00E0FF;
  --success: #3DDC97;
  --warn: #FFB547;
  --danger: #FF4F64;
  --text: #F5F5F7;
  --text-muted: #9BA4B4;
  --text-dim: #6B7488;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-lg: 22px;
  --tap: 56px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
               Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

/* Background — radial neón sutil */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(77,95,255,0.18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(0,224,255,0.10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================== Topbar ============================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: rgba(8, 10, 18, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; letter-spacing: 0.3px;
}
.topbar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 12px var(--secondary);
}
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
}
.topbar .user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: #fff;
}

/* ============================== Login ============================== */
.login-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 440px;
  padding: 32px 28px;
  background: rgba(15, 19, 32, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(160%);
}
.login-card h1 {
  font-size: 24px; margin-bottom: 4px;
  background: linear-gradient(90deg, var(--text), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }
.field {
  margin-bottom: 14px;
}
.field label {
  display: block; font-size: 13px; color: var(--text-muted);
  margin-bottom: 6px; letter-spacing: 0.3px;
}
input, select, textarea {
  width: 100%;
  height: var(--tap);
  padding: 0 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 120ms, background 120ms;
}
input:focus, select:focus {
  border-color: var(--primary);
  background: rgba(77,95,255,0.08);
  box-shadow: 0 0 0 4px rgba(77,95,255,0.12);
}

button, .btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  height: var(--tap);
  padding: 0 22px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 80ms, background 120ms, box-shadow 120ms;
  letter-spacing: 0.2px;
}
button:active, .btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6B7DFF);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--primary-glow); }
.btn-secondary {
  background: rgba(0, 224, 255, 0.10);
  color: var(--secondary);
  border: 1px solid rgba(0, 224, 255, 0.30);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger), #FF7080);
  color: #fff;
}
.btn-success {
  background: linear-gradient(135deg, var(--success), #5DFFB1);
  color: #052819;
}
.btn-block { width: 100%; }
.btn-lg { height: 64px; font-size: 17px; }

.alert {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  border-left: 3px solid;
}
.alert-error { background: rgba(255,79,100,0.10); color: #FFD0D6; border-color: var(--danger); }
.alert-warn  { background: rgba(255,181,71,0.10); color: #FFE3BD; border-color: var(--warn); }
.alert-info  { background: rgba(77,95,255,0.08); color: #DDE2FF; border-color: var(--primary); }
.alert-success { background: rgba(61,220,151,0.10); color: #BEFFE0; border-color: var(--success); }

/* ============================== Pickings list ============================== */
.page-header {
  padding: 20px 22px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header .sub { color: var(--text-muted); font-size: 14px; }

.pickings-grid {
  padding: 12px 22px 24px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.picking-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 100ms, background 120ms, border-color 120ms;
  position: relative;
}
.picking-card:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.picking-card .row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.picking-card .name {
  font-weight: 700; font-size: 17px; letter-spacing: 0.3px;
  color: var(--secondary);
}
.picking-card .partner { font-size: 14px; color: var(--text); margin-top: 6px; }
.picking-card .meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.picking-card .pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.4px;
  background: rgba(77,95,255,0.15); color: #B7C0FF;
}

/* ============================== Detail / Scan ============================== */
.detail {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  padding: 18px 22px;
  flex: 1;
}
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
}

.detail-main {
  display: flex; flex-direction: column; gap: 16px;
}
.scanner {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
  border: 1px solid var(--border-strong);
}
.scanner video, .scanner img {
  width: 100% !important; height: 100% !important; object-fit: cover !important;
  display: block !important;
}
#qr-reader { width: 100%; height: 100%; }
#qr-reader__scan_region, #qr-reader__dashboard { background: #000 !important; }
#qr-reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
.scanner canvas { display: none; }
.scanner .overlay {
  position: absolute; inset: 0;
  pointer-events: none;
}
.scanner .crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 60%; height: 60%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--secondary);
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(0, 224, 255, 0.4),
              inset 0 0 20px rgba(0, 224, 255, 0.15);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 224, 255, 0.4),
                          inset 0 0 20px rgba(0, 224, 255, 0.15); }
  50% { box-shadow: 0 0 32px rgba(0, 224, 255, 0.7),
                     inset 0 0 32px rgba(0, 224, 255, 0.30); }
}
.scanner .badge-detect {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(8, 10, 18, 0.85);
  color: var(--secondary);
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--secondary);
}

.scanner-controls {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center;
}
.scanner-controls > * { flex: 1; min-width: 140px; }

.lines-table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lines-table .row-h, .lines-table .row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 36px;
  gap: 8px;
  padding: 12px 14px;
  font-size: 14px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.lines-table .row-h {
  background: rgba(77,95,255,0.08);
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.lines-table .row:last-child { border-bottom: 0; }
.lines-table .row.ok { background: rgba(61,220,151,0.06); }
.lines-table .row.partial { background: rgba(255,181,71,0.06); }
.lines-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.lines-table .check { width: 24px; height: 24px; border-radius: 50%; }
.lines-table .check.ok { background: var(--success); box-shadow: 0 0 8px rgba(61,220,151,0.6); }
.lines-table .check.miss { background: rgba(255,255,255,0.08); }
.lines-table .check.over { background: var(--danger); }

.detail-side {
  display: flex; flex-direction: column; gap: 14px;
}
.summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.summary h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.summary .stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-size: 15px;
}
.summary .stat .v { font-weight: 700; font-size: 18px; }
.summary .stat .v.ok { color: var(--success); }
.summary .stat .v.warn { color: var(--warn); }
.summary .stat .v.bad { color: var(--danger); }

/* PIN dialog */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.pin-display {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 16px;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,0.10);
  border: 2px solid var(--border);
}
.pin-dot.filled {
  background: var(--secondary);
  border-color: var(--secondary);
  box-shadow: 0 0 10px rgba(0,224,255,0.6);
}
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.pin-key {
  height: 64px; font-size: 22px; font-weight: 600;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}
.pin-key:active { background: rgba(77,95,255,0.20); }

/* Loading spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.20);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease-out;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* utils */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
