/* ============================================================
   PosNegocios · Diseño Mobile-First / Responsive Total
   ============================================================ */

:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e1e5eb;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-danger: #dc2626;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --header-h: 56px;
  --sidebar-w: 220px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

button, input, select { font-family: inherit; font-size: 1rem; }

/* ---------- Header ---------- */
.app-header {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 .75rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header__brand { font-weight: 700; font-size: 1.1rem; color: var(--color-primary); }
.app-header__session { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.badge {
  background: var(--color-primary);
  color: #fff;
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 999px;
}
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 1.2rem;
  padding: .25rem .5rem; border-radius: 6px; color: var(--color-text);
}
.icon-btn:hover { background: var(--color-bg); }

/* ---------- Shell layout ---------- */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.app-sidebar {
  width: var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
  transition: transform .2s ease;
}
.menu-list { list-style: none; margin: 0; padding: .5rem 0; }
.menu-list li a {
  display: block;
  padding: .65rem 1rem;
  text-decoration: none;
  color: var(--color-text);
  font-size: .92rem;
  border-left: 3px solid transparent;
}
.menu-list li a:hover { background: var(--color-bg); }
.menu-list li a.active {
  border-left-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
  background: #eef2ff;
}

.app-content {
  flex: 1;
  padding: 1rem;
  min-width: 0;
}

/* Mobile: sidebar becomes an off-canvas drawer */
@media (max-width: 860px) {
  .app-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 40;
    box-shadow: var(--shadow);
  }
  .app-sidebar.open { transform: translateX(0); }
}

/* ---------- Generic components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 8px; padding: .55rem 1rem; cursor: pointer;
  font-weight: 600; font-size: .92rem;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

.cards-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.cards-grid > div {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem;
}

/* ---------- Login ---------- */
.view-login { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-card {
  background: var(--color-surface); padding: 2rem; border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: .75rem;
}
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; }
.login-card input { padding: .55rem; border: 1px solid var(--color-border); border-radius: 6px; }
.form-error { color: var(--color-danger); font-size: .85rem; min-height: 1.2em; }

/* ---------- POS ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 960px) {
  .pos-layout { grid-template-columns: 1fr 340px; }
}
.pos-tabs { display: flex; gap: .5rem; margin-bottom: .75rem; overflow-x: auto; }
.pos-tab {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px;
  padding: .4rem .9rem; cursor: pointer; white-space: nowrap; font-size: .85rem;
}
.pos-tab.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.pos-search-bar { display: flex; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.pos-search-bar input, .pos-search-bar select {
  flex: 1; min-width: 200px; padding: .55rem; border: 1px solid var(--color-border); border-radius: 8px;
}

.pos-results-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.pos-item-card {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .75rem; cursor: pointer; font-size: .85rem;
}
.pos-item-card:hover { outline: 2px solid var(--color-primary); }
.pos-item-card .price { font-weight: 700; color: var(--color-primary); }

.pos-cart {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; display: flex; flex-direction: column; gap: .75rem; height: fit-content;
}
.client-chip {
  padding: .5rem; border-radius: 8px; background: #eef2ff; font-size: .85rem;
}
.client-chip--empty { background: #fef2f2; color: var(--color-danger); }
#pos-client-search { width: 100%; padding: .5rem; border: 1px solid var(--color-border); border-radius: 8px; }
.client-results { max-height: 140px; overflow-y: auto; }
.client-results div { padding: .4rem; cursor: pointer; font-size: .82rem; border-bottom: 1px solid var(--color-border); }

.cart-items { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.cart-items li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem 0; border-bottom: 1px solid var(--color-border); font-size: .85rem;
}
.cart-items input[type="number"] { width: 90px; padding: .3rem; border: 1px solid var(--color-border); border-radius: 6px; }

.pos-cart__totals { display: flex; flex-direction: column; gap: .25rem; font-size: .95rem; }
.pos-cart__totals div { display: flex; justify-content: space-between; }

.pos-pagos-fila { display: flex; gap: .4rem; margin-bottom: .4rem; }
.pos-pagos-fila select { flex: 2; padding: .4rem; border-radius: 6px; border: 1px solid var(--color-border); }
.pos-pagos-fila input { flex: 1; padding: .4rem; border-radius: 6px; border: 1px solid var(--color-border); }
.pos-pagos-resumen { display: flex; justify-content: space-between; font-size: .85rem; margin-top: .3rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-card {
  background: var(--color-surface); border-radius: var(--radius); padding: 1.5rem;
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .75rem;
}
.modal-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; }
.modal-card input { padding: .5rem; border: 1px solid var(--color-border); border-radius: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- Tables ---------- */
.data-table-wrap { overflow-x: auto; margin-top: .75rem; }
table.data-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; }
table.data-table th, table.data-table td { padding: .6rem .75rem; text-align: left; font-size: .85rem; border-bottom: 1px solid var(--color-border); }
table.data-table th { background: var(--color-bg); }

/* ---------- ODS / Soporte ---------- */
.soporte-header { display: flex; justify-content: space-between; align-items: center; }
.ods-lista { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 1rem; }
.ods-lista > div { background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; cursor: pointer; }

.ods-detalle-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 960px) {
  .ods-detalle-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.ods-info-card, .ods-evidencias-card, .ods-repuestos-card {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem;
}
.evidencia-fase { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.evidencia-galeria { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.evidencia-galeria img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; }
.ods-acciones { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

/* ---------- Config roles ---------- */
.config-roles-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 860px) {
  .config-roles-grid { grid-template-columns: 220px 1fr; }
}
.roles-lista { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.roles-lista li { padding: .6rem .9rem; cursor: pointer; border-bottom: 1px solid var(--color-border); font-size: .88rem; }
.roles-lista li.active { background: #eef2ff; color: var(--color-primary); font-weight: 600; }
.permisos-matriz { background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; overflow-x: auto; }

.loading-placeholder { padding: 2rem; text-align: center; color: var(--color-text-muted); }
