/* ---------------------------------------------------------------------------
   Reset + layout base + Device Frame (handheld POS simulado)
   --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-6);
  background:
    radial-gradient(circle at 30% 20%, rgba(24, 87, 184, 0.06), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(24, 169, 87, 0.04), transparent 60%),
    var(--bg);
}

[data-theme='light'] body {
  background:
    radial-gradient(circle at 30% 20%, rgba(15, 63, 142, 0.05), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(17, 122, 62, 0.03), transparent 60%),
    #e9edf3;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------------------------
   Device Frame
   --------------------------------------------------------------------------- */

#frame {
  position: relative;
  width: var(--term-w);
  height: var(--term-h);
  padding: var(--term-bezel);
  background: var(--device-bezel);
  border-radius: var(--term-radius);
  box-shadow: var(--shadow-frame);
  overflow: hidden;
  isolation: isolate;
}

#frame::before {
  /* Banda superior con "altavoz" sobrio */
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: var(--device-bezel-trim);
  border-radius: 2px;
  z-index: 4;
}

#screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
  border-radius: calc(var(--term-radius) - var(--term-bezel));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Modo full-bleed (?fullbleed=1 o viewport pequeño) */
body[data-fullbleed='1'] {
  padding: 0;
  background: var(--bg);
}
body[data-fullbleed='1'] #frame {
  width: 100vw;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}
body[data-fullbleed='1'] #frame::before { display: none; }
body[data-fullbleed='1'] #screen { border-radius: 0; }

@media (max-width: 480px), (max-height: 900px) {
  body { padding: 0; }
  #frame {
    width: 100vw;
    height: 100vh;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }
  #frame::before { display: none; }
  #screen { border-radius: 0; }
}

/* ---------------------------------------------------------------------------
   App: status bar + app bar + screen body
   --------------------------------------------------------------------------- */

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  animation: screenIn var(--t-base) var(--ease-snappy);
}

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

.screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-5);
}

.screen-body--noPad { padding: 0; }

.screen-footer {
  flex-shrink: 0;
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Status bar (top of device) */
.statusbar {
  flex-shrink: 0;
  height: 28px;
  padding: 0 var(--sp-4);
  background: var(--status-bar-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  color: var(--status-icon);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.statusbar-left,
.statusbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.statusbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10px;
}

.statusbar-pill[data-tone='ok']      { background: var(--success-fade); color: var(--success); }
.statusbar-pill[data-tone='warn']    { background: var(--warning-fade); color: var(--warning); }
.statusbar-pill[data-tone='offline'] { background: var(--danger-fade);  color: var(--danger);  }

.statusbar-icon { font-size: 12px; line-height: 1; }
.statusbar-icon--off { color: var(--danger); }
.statusbar-icon--warn { color: var(--warning); }

/* App bar */
.appbar {
  flex-shrink: 0;
  height: 56px;
  padding: 0 var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.appbar-back {
  width: var(--tap-min);
  height: var(--tap-min);
  border: 0;
  background: transparent;
  border-radius: var(--r-md);
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast) var(--ease-snappy);
}
.appbar-back:hover { background: var(--surface-2); }

.appbar-title {
  flex: 1;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Logo institucional */
.crest {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 30%, var(--primary) 0%, transparent 60%),
    linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 2px solid var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: -0.05em;
  box-shadow: 0 0 0 6px var(--primary-fade);
}

/* Disclaimer footer mini */
.demo-strip {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.02em;
  padding: var(--sp-2);
}

/* Útiles globales */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }
.center-y { display: flex; align-items: center; }
.center { display: flex; align-items: center; justify-content: center; }
.text-c { text-align: center; }
.text-r { text-align: right; }
.text-2 { color: var(--text-2); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.fw-medium { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold { font-weight: var(--fw-bold); }
.fs-xs { font-size: var(--fs-xs); }
.fs-sm { font-size: var(--fs-sm); }
.fs-md { font-size: var(--fs-md); }
.fs-lg { font-size: var(--fs-lg); }
.fs-xl { font-size: var(--fs-xl); }
.fs-2xl { font-size: var(--fs-2xl); }
.fs-3xl { font-size: var(--fs-3xl); }
.mono { font-family: var(--font-mono); letter-spacing: 0.01em; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.flex-1 { flex: 1; }
.no-shrink { flex-shrink: 0; }

/* Scroll bonito (oscuro/claro) */
.screen-body::-webkit-scrollbar { width: 6px; }
.screen-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.screen-body::-webkit-scrollbar-track { background: transparent; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}
