/* ═══════════════════════════════════════════════════════════════
   BADEIGTS GARAGE — style.css
   Diseño Bahco: negro industrial + naranja de advertencia
   Mobile-first · Tarea 0.3
═══════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ──────────────────────────────────────────── */
:root {
  /* Paleta Bahco */
  --clr-bg:          #0a0a0a;
  --clr-surface:     #141414;
  --clr-surface-2:   #1c1c1c;
  --clr-surface-3:   #242424;
  --clr-border:      #2a2a2a;
  --clr-border-light:#333333;

  --clr-orange:      #f5620a;
  --clr-orange-dim:  #c44e07;
  --clr-orange-glow: rgba(245, 98, 10, 0.18);
  --clr-orange-glow-strong: rgba(245, 98, 10, 0.35);

  --clr-text-primary:   #f0f0f0;
  --clr-text-secondary: #888888;
  --clr-text-muted:     #555555;

  --clr-ok:    #22c55e;
  --clr-warn:  #eab308;
  --clr-error: #ef4444;

  /* Tipografía */
  --font-brand: 'Courier New', 'Courier', monospace;
  --font-body:  -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Espaciado */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;

  /* Layout */
  --header-h:    56px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Misc */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 160ms ease;
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--clr-bg);
  color: var(--clr-text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100dvh;
  /* Evitar scroll del body mientras el contenido scrollea */
  overflow: hidden;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
}

input {
  font-family: inherit;
  color: inherit;
}

/* ─── HEADER ─────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  z-index: 100;
  /* Línea naranja superior — identidad Bahco */
  box-shadow: 0 -3px 0 var(--clr-orange) inset;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-md);
  max-width: 768px;
  margin: 0 auto;
}

/* Logo */
.logo-block {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  font-size: 20px;
  color: var(--clr-orange);
  line-height: 1;
  /* Hexágono — referencia a tuercas */
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-brand {
  font-family: var(--font-brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--clr-text-primary);
  text-transform: uppercase;
}

.logo-sub {
  font-family: var(--font-brand);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--clr-orange);
  text-transform: uppercase;
}

/* Header acciones */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--clr-text-secondary);
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover,
.btn-icon:focus-visible {
  color: var(--clr-text-primary);
  background: var(--clr-surface-2);
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: 20px;
  padding: 3px 10px 3px 7px;
  font-size: 11px;
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
  color: var(--clr-text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clr-ok);
  flex-shrink: 0;
  /* Pulso suave cuando OK */
  animation: pulse-ok 2.4s ease-in-out infinite;
}

.status-pill.warn .status-dot   { background: var(--clr-warn); animation: none; }
.status-pill.error .status-dot  { background: var(--clr-error); animation: none; }

@keyframes pulse-ok {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── SEARCH BAR ─────────────────────────────────────────────── */
.search-bar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  z-index: 99;
  padding: var(--space-sm) var(--space-md);
}

.search-inner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-md);
  padding: 0 var(--space-sm);
  max-width: 768px;
  margin: 0 auto;
  transition: border-color var(--transition);
}
.search-inner:focus-within {
  border-color: var(--clr-orange);
  box-shadow: 0 0 0 3px var(--clr-orange-glow);
}

.search-ico {
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

#global-search {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 10px 0;
  font-size: 15px;
  color: var(--clr-text-primary);
}
#global-search::placeholder {
  color: var(--clr-text-muted);
}

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.app-main {
  position: fixed;
  top: var(--header-h);
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ─── VISTAS (módulos) ───────────────────────────────────────── */
.view {
  display: none;
  min-height: 100%;
  padding: var(--space-lg) var(--space-md);
  padding-bottom: calc(var(--space-lg) + 8px);
  max-width: 768px;
  margin: 0 auto;
  animation: view-in 180ms ease both;
}

.view.active {
  display: block;
}

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

/* ─── VIEW HEADER ────────────────────────────────────────────── */
.view-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--clr-border);
  position: relative;
}

/* Barra naranja lateral izquierda — acento Bahco */
.view-header::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-md));
  top: 0;
  bottom: var(--space-md);
  width: 3px;
  background: var(--clr-orange);
  border-radius: 0 2px 2px 0;
}

.view-title {
  font-family: var(--font-brand);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--clr-text-primary);
  text-transform: uppercase;
  line-height: 1.1;
}

.view-desc {
  margin-top: 4px;
  font-size: 13px;
  color: var(--clr-text-secondary);
  letter-spacing: 0.01em;
}

/* ─── PLACEHOLDER (módulos en desarrollo) ────────────────────── */
.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 200px;
  background: var(--clr-surface);
  border: 1px dashed var(--clr-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
}

.placeholder-icon {
  font-size: 40px;
  opacity: 0.4;
}

.placeholder-label {
  font-family: var(--font-brand);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--clr-text-secondary);
  text-transform: uppercase;
}

.placeholder-sub {
  font-size: 12px;
  color: var(--clr-text-muted);
  font-family: var(--font-brand);
}

/* ─── BOTTOM NAV ─────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  /* Línea naranja superior de la nav */
  box-shadow: 0 -1px 0 var(--clr-border), 0 -3px 0 transparent;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-sm) var(--space-xs);
  color: var(--clr-text-muted);
  border-radius: 0;
  position: relative;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}

/* Indicador activo: pequeño trazo naranja arriba */
.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--clr-orange);
  border-radius: 0 0 2px 2px;
  opacity: 0;
  transform: scaleX(0);
  transition: opacity var(--transition), transform var(--transition);
}

.nav-item.active {
  color: var(--clr-orange);
}
.nav-item.active::before {
  opacity: 1;
  transform: scaleX(1);
}

.nav-item:not(.active):active {
  color: var(--clr-text-secondary);
  background: var(--clr-surface-2);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  stroke-width: 1.8;
  transition: stroke-width var(--transition);
}
.nav-item.active .nav-icon {
  stroke-width: 2.4;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-brand);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54px;
}

/* ─── COMPONENTES GLOBALES ────────────────────────────────────── */

/* Card genérica */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.card + .card {
  margin-top: var(--space-sm);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-orange  { background: var(--clr-orange-glow); color: var(--clr-orange); border: 1px solid var(--clr-orange-dim); }
.badge-ok      { background: rgba(34,197,94,.12);    color: var(--clr-ok);     border: 1px solid rgba(34,197,94,.3); }
.badge-warn    { background: rgba(234,179,8,.12);    color: var(--clr-warn);   border: 1px solid rgba(234,179,8,.3); }
.badge-error   { background: rgba(239,68,68,.12);    color: var(--clr-error);  border: 1px solid rgba(239,68,68,.3); }
.badge-muted   { background: var(--clr-surface-2);   color: var(--clr-text-secondary); border: 1px solid var(--clr-border); }

/* Botón primario */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--clr-orange);
  color: #fff;
  font-family: var(--font-brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 11px var(--space-lg);
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
  touch-action: manipulation;
}
.btn-primary:active {
  background: var(--clr-orange-dim);
  transform: scale(0.98);
}

/* Botón secundario */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: transparent;
  color: var(--clr-text-secondary);
  font-family: var(--font-brand);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px var(--space-lg);
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-sm);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  touch-action: manipulation;
}
.btn-secondary:active {
  color: var(--clr-text-primary);
  border-color: var(--clr-text-muted);
  background: var(--clr-surface-2);
}

/* Input de texto */
.input-field {
  width: 100%;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-sm);
  padding: 10px var(--space-md);
  font-size: 15px;
  color: var(--clr-text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-field::placeholder { color: var(--clr-text-muted); }
.input-field:focus {
  border-color: var(--clr-orange);
  box-shadow: 0 0 0 3px var(--clr-orange-glow);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--clr-border);
  margin: var(--space-md) 0;
}

/* ─── UTILIDADES ─────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.text-orange   { color: var(--clr-orange); }
.text-muted    { color: var(--clr-text-muted); }
.text-secondary{ color: var(--clr-text-secondary); }

.mono { font-family: var(--font-brand); }

/* ─── RESPONSIVE: PC / TABLET ────────────────────────────────── */
@media (min-width: 640px) {
  .nav-label { max-width: 70px; font-size: 11px; }
  .view-title { font-size: 26px; }
}

@media (min-width: 768px) {
  /* En pantallas anchas la nav queda en la izquierda */
  .bottom-nav {
    top: var(--header-h);
    bottom: 0;
    left: 0;
    right: auto;
    width: 72px;
    height: auto;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--clr-border);
    padding-bottom: 0;
  }

  .nav-item {
    padding: var(--space-md) var(--space-sm);
    gap: 5px;
  }

  /* El indicador activo pasa a ser una barra derecha */
  .nav-item::before {
    top: 20%;
    bottom: 20%;
    left: auto;
    right: 0;
    width: 3px;
    height: auto;
    border-radius: 2px 0 0 2px;
    transform: scaleY(0);
  }
  .nav-item.active::before {
    transform: scaleY(1);
  }

  .nav-label { max-width: none; font-size: 9px; }
  .nav-icon  { width: 20px; height: 20px; }

  .app-main {
    left: 72px;
    bottom: 0;
  }

  :root { --bottom-nav-h: 0px; }
}

@media (min-width: 1024px) {
  /* Nav lateral más ancha con labels legibles */
  .bottom-nav {
    width: 200px;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-sm);
    padding: 14px var(--space-md);
  }

  .nav-label { font-size: 12px; }
  .nav-icon  { width: 18px; height: 18px; }

  .app-main {
    left: 200px;
  }

  /* El indicador activo: barra derecha en nav lateral */
  .nav-item::before {
    top: 15%;
    bottom: 15%;
  }
}

/* ─── SCROLLBAR (WebKit) ─────────────────────────────────────── */
.app-main::-webkit-scrollbar {
  width: 4px;
}
.app-main::-webkit-scrollbar-track {
  background: transparent;
}
.app-main::-webkit-scrollbar-thumb {
  background: var(--clr-border-light);
  border-radius: 2px;
}
.app-main::-webkit-scrollbar-thumb:hover {
  background: var(--clr-text-muted);
}

.app-main::-webkit-scrollbar { display:none; }
.app-main { scrollbar-width:none; }
