/* ══════════════════════════════════════════════════════════════════
   APP.OSCORP.INK · COMPONENTES BASE
   ------------------------------------------------------------------
   Todo lo que una sección nueva del panel necesita para verse parte
   de la misma familia sin reinventar nada: layout de sidebar/topbar,
   botones, inputs, cards, tabla densa, badges de estado, modal, toast,
   tabs, dropdown, empty state, tooltip.

   Convención de nombres: BEM simple, prefijo por componente
   (.btn, .input, .card, .table, .badge, .modal, .toast, .tabs...).
   Ver /styleguide/ para la referencia visual de cada uno.
   ══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────── LAYOUT ─────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: var(--z-sidebar);
}

.sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
}
.sidebar-brand img { width: 26px; height: 26px; }
.sidebar-brand .name { font-size: 15px; font-weight: var(--fw-bold); letter-spacing: -0.3px; }
.sidebar-brand .biz { font-size: var(--fs-micro); color: var(--ink-3); font-weight: var(--fw-medium); margin-top: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-3); display: flex; flex-direction: column; gap: 2px; }

.sidebar-section-label {
  font-size: 10.5px; font-weight: var(--fw-bold); letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--ink-3); padding: var(--sp-4) var(--sp-3) var(--sp-1);
}

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: var(--fw-medium); color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
.nav-item.is-active { background: var(--surface-active); color: var(--ink); font-weight: var(--fw-semi); }
.nav-item.is-active svg { opacity: 1; color: var(--acc-ink); }
.nav-item.is-active::before {
  content: ''; position: absolute; left: -12px; top: 50%; translate: 0 -50%;
  width: 3px; height: 16px; border-radius: var(--r-full); background: var(--acc);
}
.nav-item.is-disabled { color: var(--ink-3); cursor: default; pointer-events: none; }
.nav-item .soon {
  margin-left: auto; font-size: 10px; font-weight: var(--fw-bold); letter-spacing: 0.3px;
  color: var(--ink-3); background: var(--surface-sunken); padding: 2px 6px; border-radius: var(--r-full);
}
.nav-item .count {
  margin-left: auto; font-size: 11.5px; font-weight: var(--fw-semi); color: var(--ink-3);
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-5); border-top: 0.5px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3);
}
.sidebar-footer .avatar {
  width: 32px; height: 32px; border-radius: var(--r-full); background: var(--surface-sunken);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: var(--fw-bold); color: var(--ink-2); flex-shrink: 0;
}
.sidebar-footer .who { min-width: 0; }
.sidebar-footer .who .n { font-size: 13px; font-weight: var(--fw-semi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who .r { font-size: 11.5px; color: var(--ink-3); }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-5); padding: 0 var(--content-pad);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  z-index: var(--z-topbar);
}
.topbar-title { font-size: 17px; font-weight: var(--fw-bold); letter-spacing: -0.3px; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.content { flex: 1; padding: var(--content-pad); max-width: var(--content-max); width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-5); margin-bottom: var(--sp-6); }
.page-title { font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: -0.6px; line-height: var(--lh-tight); }
.page-sub { font-size: var(--fs-small); color: var(--ink-2); margin-top: var(--sp-1); }

/* ─────────────────────────── BOTONES ─────────────────────────── */
/* El acento lima se reserva para selección/foco/indicadores — un botón
   primario lima repetido 40 veces en una tabla de 600 filas se siente
   a landing page, no a herramienta. El primario "serio" es tinta sólida. */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 38px; padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: var(--fw-semi); letter-spacing: -0.1px;
  white-space: nowrap; border: 0.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: #000; }

.btn-accent { background: var(--acc); color: var(--acc-ink); }
.btn-accent:hover { filter: brightness(0.96); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: 12.5px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ─────────────────────────── INPUTS ─────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12.5px; font-weight: var(--fw-semi); color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.field-label .opt { font-weight: var(--fw-regular); color: var(--ink-3); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--danger); font-weight: var(--fw-medium); }

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 var(--sp-3);
  background: var(--surface); border: 0.5px solid var(--border-strong);
  border-radius: var(--r-md); font-size: var(--fs-body); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 88px; padding: var(--sp-3); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--acc); box-shadow: var(--shadow-focus);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-sunken); color: var(--ink-3); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }

.select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2352525B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* Input con prefijo/sufijo (ej. "$" antes del precio, "m²" después) */
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; }
.input-group > *:first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: var(--r-md); }
.input-group > *:last-child { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }
.input-affix {
  display: flex; align-items: center; padding: 0 var(--sp-3);
  background: var(--surface-sunken); border: 0.5px solid var(--border-strong);
  font-size: 13px; color: var(--ink-3); font-weight: var(--fw-medium);
}
.input-group .input-affix:first-child { border-right: none; }
.input-group .input-affix:last-child { border-left: none; }
.input-group .input:not(:first-child) { border-left: none; }
.input-group .input:not(:last-child) { border-right: none; }

/* Búsqueda con ícono */
.search-input { position: relative; }
.search-input svg {
  position: absolute; left: var(--sp-3); top: 50%; translate: 0 -50%;
  width: 15px; height: 15px; color: var(--ink-3); pointer-events: none;
}
.search-input .input { padding-left: 34px; }

/* Checkbox / toggle */
.checkbox { width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--border-strong);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s; }
.checkbox.is-checked { background: var(--ink); border-color: var(--ink); }
.checkbox.is-checked svg { width: 11px; height: 11px; color: var(--bg); }

.toggle { width: 38px; height: 22px; border-radius: var(--r-full); background: var(--border-strong);
  position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: translate 0.2s var(--ease-outBack); }
.toggle.is-on { background: var(--acc); }
.toggle.is-on::after { translate: 16px 0; }

/* ─────────────────────────── CARDS ─────────────────────────── */

.card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6);
}
.card-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease-outExpo); }
.card-clickable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.card-title { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: -0.2px; }

/* Stat card — para KPIs de dashboard */
.stat-card { display: flex; flex-direction: column; gap: var(--sp-2); }
.stat-label { font-size: var(--fs-micro); font-weight: var(--fw-semi); letter-spacing: 0.3px; text-transform: uppercase; color: var(--ink-3); }
.stat-value { font-size: 30px; font-weight: var(--fw-bold); letter-spacing: -0.8px; }
.stat-delta { font-size: 12.5px; font-weight: var(--fw-semi); display: flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--estado-completado); }
.stat-delta.down { color: var(--danger); }

/* ─────────────────────────── BADGES / PILLS ─────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: var(--fw-semi); letter-spacing: 0.1px;
  background: var(--surface-sunken); color: var(--ink-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-2); }
.badge-accent { background: color-mix(in srgb, var(--acc) 18%, var(--surface)); color: var(--acc-ink); }
.badge-pendiente  { background: color-mix(in srgb, var(--estado-pendiente) 16%, var(--surface));  color: color-mix(in srgb, var(--estado-pendiente) 70%, var(--ink)); }
.badge-aceptado   { background: color-mix(in srgb, var(--estado-aceptado) 16%, var(--surface));   color: color-mix(in srgb, var(--estado-aceptado) 60%, var(--ink)); }
.badge-completado { background: color-mix(in srgb, var(--estado-completado) 16%, var(--surface)); color: color-mix(in srgb, var(--estado-completado) 55%, var(--ink)); }
.badge-cancelado  { background: color-mix(in srgb, var(--estado-cancelado) 14%, var(--surface));  color: var(--estado-cancelado); }

/* ─────────────────────────── TABLA ─────────────────────────── */
/* Densa, sin zebra striping (Apple/Finder-like), header pegajoso —
   pensada para las tablas de 600+ filas que trae DESKTOP_PRODUCTOS.md. */

.table-wrap { border: 0.5px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }

.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); text-align: left;
  font-size: 10.5px; font-weight: var(--fw-bold); letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--ink-3); padding: var(--sp-3) var(--sp-4);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { color: var(--ink); }
.table thead th .sort-icon { display: inline-block; width: 9px; margin-left: 3px; opacity: 0.5; }
.table thead th.is-sorted { color: var(--ink); }
.table thead th.is-sorted .sort-icon { opacity: 1; }
.table th.num, .table td.num { text-align: right; }

.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 0.5px solid var(--border);
  font-size: 13.5px; vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover td { background: var(--surface-hover); }
.table tbody tr.is-selected td { background: var(--surface-active); }

.table .cell-primary { font-weight: var(--fw-semi); color: var(--ink); }
.table .cell-muted { color: var(--ink-3); }
.table .cell-thumb {
  width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover;
  background: var(--surface-sunken); flex-shrink: 0;
}
.table .cell-with-thumb { display: flex; align-items: center; gap: var(--sp-3); }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.table-toolbar .left { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; }
.table-toolbar .search-input { max-width: 320px; flex: 1; }

.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-top: 0.5px solid var(--border);
  font-size: 12.5px; color: var(--ink-3);
}

/* ─────────────────────────── EMPTY STATE ─────────────────────────── */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--sp-10) var(--sp-6); gap: var(--sp-2);
}
.empty-state .icon {
  width: 44px; height: 44px; color: var(--ink-3); margin-bottom: var(--sp-3); opacity: 0.6;
}
.empty-state .title { font-size: 15px; font-weight: var(--fw-bold); }
.empty-state .desc { font-size: var(--fs-small); color: var(--ink-3); max-width: 340px; }

/* ─────────────────────────── MODAL ─────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 24, 27, 0.32);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal); padding: var(--sp-6);
  animation: fade-in 0.18s var(--ease-outQuint);
}
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 480px;
  max-height: calc(100vh - 80px); overflow-y: auto;
  padding: var(--sp-7);
  animation: modal-in 0.24s var(--ease-outQuint);
}
.modal.modal-lg { max-width: 720px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--sp-5); gap: var(--sp-4); }
.modal-title { font-size: 18px; font-weight: var(--fw-bold); letter-spacing: -0.3px; }
.modal-desc { font-size: var(--fs-small); color: var(--ink-2); margin-top: 4px; }
.modal-body { display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-6); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─────────────────────────── TOAST ─────────────────────────── */

.toast-stack {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-2); z-index: var(--z-toast);
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--ink); color: var(--bg);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: 13px; font-weight: var(--fw-medium); box-shadow: var(--shadow-lg);
  animation: toast-in 0.28s var(--ease-outBack);
  min-width: 240px;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.toast-error { background: var(--danger); }
.toast.toast-success svg { color: var(--acc); }

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

/* ─────────────────────────── TABS ─────────────────────────── */

.tabs { display: flex; align-items: center; gap: var(--sp-1); border-bottom: 0.5px solid var(--border); }
.tab {
  padding: var(--sp-3) var(--sp-2); font-size: 13.5px; font-weight: var(--fw-medium); color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -0.5px; transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: var(--fw-semi); border-color: var(--acc); }

/* ─────────────────────────── DROPDOWN / MENU ─────────────────────────── */

.menu {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  padding: 6px; min-width: 180px; z-index: var(--z-dropdown);
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: 8px var(--sp-2); border-radius: 7px;
  font-size: 13px; font-weight: var(--fw-medium); color: var(--ink);
  text-align: left; transition: background 0.1s;
}
.menu-item svg { width: 15px; height: 15px; color: var(--ink-3); }
.menu-item:hover { background: var(--surface-hover); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger svg { color: var(--danger); }
.menu-sep { height: 0.5px; background: var(--border); margin: 6px 4px; }

/* ─────────────────────────── TOOLTIP ─────────────────────────── */

.tooltip {
  background: var(--ink); color: var(--bg); font-size: 12px; font-weight: var(--fw-medium);
  padding: 5px 9px; border-radius: 6px; box-shadow: var(--shadow-md);
}

/* ─────────────────────────── KBD (atajos de teclado) ─────────────────────────── */

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--surface-sunken); border: 0.5px solid var(--border-strong);
  border-radius: 4px; font-size: 10.5px; font-weight: var(--fw-semi); color: var(--ink-2);
}
