/* ═══════════════════════════════════════════════════════
   Mosca Taller ERP — shared.css
   Design system base para todos los módulos
   ═══════════════════════════════════════════════════════ */

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

/* ── Variables — Tema claro ── */
:root {
  --bg:          #f2f1ee;
  --surface:     #ffffff;
  --border:      #e0ded9;
  --text:        #1a1a1a;
  --muted:       #999;
  --accent:      #c8880a;
  --accent-dim:  #fff4e0;
  --input-bg:    #ebebea;
  --overlay-bg:  rgba(0,0,0,0.45);
  --danger:      #c93030;
  --danger-dim:  #ffeaea;
  --danger-border: #d05050;
  --success:     #166038;
  --success-dim: #e8f5ee;
  --warn:        #c07020;
  --warn-dim:    #fff4e0;
  --warn-border: #d08040;
  --radius-sm:   6px;
  --radius-md:   9px;
  --radius-lg:   14px;
}

/* ── Variables — Tema oscuro ── */
body.dark {
  --bg:          #0f0f0f;
  --surface:     #1a1a1a;
  --border:      #282828;
  --text:        #f0f0f0;
  --muted:       #777;
  --accent:      #e8a020;
  --accent-dim:  #221500;
  --input-bg:    #111;
  --overlay-bg:  rgba(0,0,0,0.8);
  --danger:      #ff6060;
  --danger-dim:  #2e0000;
  --danger-border: #7a1010;
  --success:     #40b060;
  --success-dim: #002a10;
  --warn:        #ff9030;
  --warn-dim:    #2e1400;
  --warn-border: #6a3000;
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  min-height: 100vh;
}

/* ── Layout ── */
.container      { max-width: 480px; margin: 0 auto; padding: 0 12px; }
.container-wide { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ── App header ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 13px 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.app-header h1 { font-size: 17px; font-weight: 700; color: var(--accent); }
.header-right  { display: flex; align-items: center; gap: 8px; }
.version       { font-size: 11px; color: var(--muted); }

/* ── Section title ── */
.section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: opacity .12s;
  -webkit-tap-highlight-color: transparent; text-decoration: none;
}
.btn:active           { opacity: 0.7; }
.btn-primary          { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover    { opacity: 0.88; }
.btn-block            { display: block; width: 100%; text-align: center; }
.btn-lg               { padding: 14px 18px; font-size: 15px; font-weight: 700; }
.btn-sm               { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  background: none; border: 1px solid var(--border);
  color: var(--muted); padding: 4px 10px;
  border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active   { opacity: 0.5; }
.btn-save {
  display: block; width: 100%; padding: 14px;
  background: var(--accent); border: none; border-radius: var(--radius-md);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; margin-bottom: 8px;
  font-family: inherit;
}
.btn-save:active   { opacity: 0.7; }
.btn-save.saving   { opacity: 0.5; pointer-events: none; }
.btn-cancel {
  display: block; width: 100%; padding: 14px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--muted); font-size: 15px; cursor: pointer;
  font-family: inherit;
}
.btn-cancel:active { opacity: 0.6; }

/* ── Chips ── */
.chips-wrap {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 0 0 12px; scrollbar-width: none;
}
.chips-wrap::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 5px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--muted); -webkit-tap-highlight-color: transparent;
  transition: all 0.12s; white-space: nowrap;
}
.chip.active       { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.chip.chip-danger  { }
.chip.chip-danger.active { border-color: var(--danger); background: var(--danger-dim); color: var(--danger); }
.chip.chip-warn.active   { border-color: var(--warn);   background: var(--warn-dim);   color: var(--warn); }

/* ── Search ── */
.search-input {
  width: 100%; background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 15px;
  padding: 9px 12px 9px 34px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus        { border-color: var(--accent); }

/* ── Card / Surface ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px;
}

/* ── Inputs ── */
.field-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 6px; display: block;
}
.field-input, .field-textarea, .field-select {
  width: 100%; background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 15px;
  padding: 10px 12px; outline: none;
  font-family: inherit;
}
.field-textarea { resize: vertical; min-height: 72px; line-height: 1.4; }
.field-input:focus, .field-textarea:focus, .field-select:focus { border-color: var(--accent); }
.field-input::placeholder, .field-textarea::placeholder { color: var(--muted); }

/* ── Spinner / Loading ── */
.loading { text-align: center; padding: 60px 20px; color: var(--muted); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── States ── */
.empty     { text-align: center; padding: 50px 20px; color: var(--muted); font-size: 15px; }
.error-box {
  background: var(--danger-dim); border: 1px solid var(--danger-border);
  border-radius: var(--radius-md); padding: 16px; font-size: 14px; color: var(--danger);
}

/* ── Modal / Overlay ── */
.overlay {
  position: fixed; inset: 0; background: var(--overlay-bg);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
}
.overlay.hidden  { display: none; }
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 480px;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.drag-handle {
  width: 36px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 0 auto 14px;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.modal-sub   { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ── Status badges — Items_Pedido.estado ── */
.ebadge {
  flex-shrink: 0; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 5px;
  max-width: 120px; text-align: center; white-space: nowrap;
}
.eb-Nuevo          { background: #efefef; color: #777; }
.eb-Revisado       { background: #e0eeff; color: #1050a0; }
.eb-A_comprar      { background: #fff5e0; color: #a06000; }
.eb-Pendiente      { background: #fefbe0; color: #806010; }
.eb-En_herreria    { background: #fff0e0; color: #b05800; }
.eb-En_carpinteria { background: #e8f0ff; color: #1a48b0; }
.eb-En_pintura     { background: #f5e8ff; color: #6020a8; }
.eb-Control        { background: #e8ffe8; color: #106830; }
.eb-Para_entregar  { background: #e0f5e8; color: #166038; }
.eb-Entregado      { background: #eaf4ea; color: #2e6030; }
.eb-PosEntrega     { background: #d0f0d8; color: #0a4a20; }
.eb-En_Stock       { background: #e0f5f5; color: #125858; }
.eb-Vendido        { background: #f5f5e0; color: #605820; }
.eb-Cancelado      { background: #f0f0f0; color: #aaa; }
body.dark .eb-Nuevo          { background: #242424; color: #999; }
body.dark .eb-Revisado       { background: #001428; color: #5090e0; }
body.dark .eb-A_comprar      { background: #2a1800; color: #f0a040; }
body.dark .eb-Pendiente      { background: #221800; color: #c0a040; }
body.dark .eb-En_herreria    { background: #2e1800; color: #f0a050; }
body.dark .eb-En_carpinteria { background: #00102e; color: #5080d0; }
body.dark .eb-En_pintura     { background: #1e0030; color: #b070e0; }
body.dark .eb-Control        { background: #001800; color: #40c060; }
body.dark .eb-Para_entregar  { background: #002a10; color: #40b060; }
body.dark .eb-Entregado      { background: #0f1f0f; color: #509050; }
body.dark .eb-PosEntrega     { background: #071a0e; color: #30a050; }
body.dark .eb-En_Stock       { background: #002828; color: #30b0b0; }
body.dark .eb-Vendido        { background: #1e1e00; color: #b0b030; }
body.dark .eb-Cancelado      { background: #181818; color: #444; }

/* ── Urgencia badges ── */
.urg-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 4px; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.urg-Urgente { background: #fff0e0; color: #b05800; border: 1px solid #d08040; }
.urg-Critico { background: #ffe8e8; color: #b02828; border: 1px solid #d05050; }
body.dark .urg-Urgente { background: #2e1400; color: #f09030; border-color: #6a3000; }
body.dark .urg-Critico { background: #2e0000; color: #f05050; border-color: #7a1010; }

/* ── Pills ── */
.pill {
  display: inline-block; padding: 2px 8px;
  border-radius: 100px; font-size: 11px; font-weight: 500;
}
.pill-danger  { background: var(--danger-dim);  color: var(--danger); }
.pill-success { background: var(--success-dim); color: var(--success); }
.pill-warn    { background: var(--warn-dim);    color: var(--warn); }
.pill-neutral { background: var(--input-bg);    color: var(--muted); }

/* ── Highlight (búsqueda) ── */
mark { background: #ffe066; color: #5a3a00; border-radius: 2px; padding: 0 1px; }
body.dark mark { background: #5a3a00; color: #f0c060; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.93);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.lightbox.hidden { display: none; }
.lightbox-img {
  max-width: 94vw; max-height: 90vh;
  object-fit: contain; border-radius: 6px; display: block;
}
.lightbox-close {
  position: absolute; top: 14px; right: 14px;
  color: #fff; font-size: 20px; cursor: pointer;
  background: rgba(255,255,255,0.15); border: none;
  border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.lightbox-close:active { opacity: 0.6; }

/* ── Font size scale ── */
body.fz-lg { font-size: 19px; }
body.fz-xl { font-size: 22px; }

/* ── Module hub — grid de módulos ── */
.mod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 12px 8px;
}
@media (max-width: 360px) { .mod-grid { grid-template-columns: 1fr; } }

.mod-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 14px;
  text-decoration: none; color: var(--text);
  display: block; transition: border-color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.mod-card:hover { border-color: var(--accent); }
.mod-card:active { opacity: 0.8; }
.mod-card.legacy { opacity: 0.5; }
.mod-card.legacy:hover { border-color: var(--border); opacity: 0.7; }

.mod-icon { font-size: 22px; margin-bottom: 8px; line-height: 1; }
.mod-name { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.mod-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.mod-badge {
  display: inline-block; margin-top: 10px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
  padding: 2px 7px; border-radius: 10px;
  background: var(--input-bg); color: var(--muted);
}
.mod-badge.todos { background: var(--accent-dim); color: var(--accent); }
.mod-badge.dev   { background: var(--warn-dim);   color: var(--warn); }

.legacy-section {
  padding: 0 12px 32px;
}
.legacy-row {
  display: flex; gap: 8px;
}
