/* ============================================================
   Inbox Sales — Estilos globales
   ============================================================ */

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--surface-0);
  color: var(--text-1);
}

/* ── Material Symbols alineación ─────────────────────────── */
.material-symbols-rounded {
  display: inline-flex !important;
  align-items: center !important;
  vertical-align: middle !important;
  font-size: inherit;
}

/* ── Botones con iconos ───────────────────────────────────── */
.btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
}

.btn-user-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 1.25rem;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-user-primary:hover { background: var(--brand-dark, var(--brand-700, var(--brand))); opacity: 0.9; }
.btn-user-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-user-primary .material-symbols-rounded { font-size: 1.125rem; }

/* ── Shared form select ──────────────────────────────────── */
.form-filter-select {
  height: 36px;
  padding: 0 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--text-1);
  cursor: pointer;
  outline: none;
}
.form-filter-select:focus {
  border-color: var(--brand);
}

/* ── Focus accesible ──────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ── Scrollbar discreta ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-0); }
::-webkit-scrollbar-thumb { background: var(--neutral-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral-600); }

/* ============================================================
   Shared — Admin page layout
   ============================================================ */

/* .admin-page removida: chocaba con el max-width global (1280px) del
   workspace-content > *. Las clases hijas (.admin-page-header, -title,
   -sub, -actions, -header-row) se conservan y siguen funcionando. */

.admin-page-header { margin-bottom: 1.75rem; }

.admin-page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 4px;
}

.admin-page-title .material-symbols-rounded { font-size: 1.5rem; color: var(--brand); }

.admin-page-sub {
  font-size: 0.875rem;
  color: var(--text-3);
  margin: 0;
}

/* ============================================================
   Shared — Filters & Tabs
   ============================================================ */

.admin-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.admin-filter-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.admin-tab {
  padding: 0.5rem 1rem;
  background: var(--surface-1);
  border: none;
  border-right: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
}

.admin-tab:last-child { border-right: none; }

.admin-tab:hover { background: var(--state-hover); color: var(--text-1); }

.admin-tab.active {
  background: var(--brand);
  color: #fff;
}

.admin-search {
  height: 38px;
  padding: 0 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--text-1);
  min-width: 200px;
  outline: none;
}

.admin-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring, rgba(37,99,235,.15));
}

.admin-search::placeholder { color: var(--text-3); }

/* ============================================================
   Shared — Table
   ============================================================ */

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.12s;
}

.admin-table tbody tr:last-child { border-bottom: none; }

.admin-table tbody tr:hover { background: var(--state-hover); }

.admin-table tbody td {
  padding: 0.75rem 1rem;
  color: var(--text-1);
  vertical-align: middle;
}

.admin-empty-row td {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--text-3);
}

.admin-empty-row .material-symbols-rounded {
  font-size: 2.5rem;
  opacity: 0.35;
  display: block;
  margin: 0 auto 0.5rem;
}

.admin-empty-row p {
  margin: 0;
  font-size: 0.875rem;
}

/* ============================================================
   Shared — Row actions
   ============================================================ */

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.btn-row-action {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
}

.btn-row-action:hover {
  border-color: var(--border-strong, var(--border));
  color: var(--text-1);
}

.btn-row-action .material-symbols-rounded { font-size: 1rem; }

.btn-row-info:hover  { color: var(--brand); border-color: var(--brand); }
.btn-row-suspend:hover { color: var(--danger); border-color: var(--danger); }
.btn-row-activate:hover { color: var(--success); border-color: var(--success); }

/* ── Shared icon button ──────────────────────────────────── */
.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
}
.btn-icon:hover { background: var(--state-hover); color: var(--brand); }
.btn-icon .material-symbols-rounded { font-size: 1.125rem; }

/* ============================================================
   Shared — Status badges
   ============================================================ */

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.status-active {
  background: rgba(16,185,129,0.12);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.25);
}

.status-suspended {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.25);
}

/* ============================================================
   Shared — ws-page layout
   ============================================================ */

.ws-page { padding: 2rem; max-width: 1200px; }
.ws-page-header { margin-bottom: 1.75rem; }
.ws-page-title  {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 4px;
}
.ws-page-sub { font-size: 0.875rem; color: var(--text-3); margin: 0; }

/* ============================================================
   Shared — Dashboard cards & grids
   ============================================================ */

.dsh-grid { display: grid; gap: 1rem; }
.dsh-grid--4 { grid-template-columns: repeat(4, 1fr); }
.dsh-grid--3 { grid-template-columns: repeat(3, 1fr); }
.dsh-grid--2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 768px) {
  .dsh-grid--4, .dsh-grid--3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .dsh-grid--4, .dsh-grid--3, .dsh-grid--2 { grid-template-columns: 1fr; }
}

.dsh-card {
  display: flex;
  align-items: center;
  gap: 1.125rem;
  border-radius: 16px;
  padding: 1.375rem 1.5rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.dsh-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  flex-shrink: 0;
  font-size: 24px;
}

.dsh-card-body { display: flex; flex-direction: column; gap: 4px; }

.dsh-card-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.01em;
}

.dsh-card-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Card icon tints */
.dsh-card--teal   .dsh-card-icon { background: rgba(37,99,235,0.25); color: #2563eb; }
.dsh-card--blue   .dsh-card-icon { background: rgba(59,130,246,0.25); color: #60a5fa; }
.dsh-card--green  .dsh-card-icon { background: rgba(16,185,129,0.25); color: #34d399; }
.dsh-card--purple .dsh-card-icon { background: rgba(168,85,247,0.25); color: #c084fc; }
.dsh-card--yellow .dsh-card-icon { background: rgba(217,119,6,0.30);  color: #fbbf24; }
.dsh-card--orange .dsh-card-icon { background: rgba(249,115,22,0.25); color: #fb923c; }
.dsh-card--red    .dsh-card-icon { background: rgba(239,68,68,0.25);  color: #f87171; }

/* ============================================================
   Shared — Dashboard sections & action cards
   ============================================================ */

.dsh-section { margin-top: 2rem; }

.dsh-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 1rem;
}

.dsh-action-card {
  display: flex;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dsh-action-card:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 12px rgba(37,99,235,0.10);
}

.dsh-action-text {
  font-size: 0.9rem;
  color: var(--text-2);
  margin: 0;
  line-height: 1.5;
}

.dsh-action-link { font-weight: 700; }
.dsh-action-link--teal  { color: #2563eb; }
.dsh-action-link--blue  { color: #60a5fa; }
.dsh-action-link--green { color: #10b981; }

/* ============================================================
   Shared — User cell styles (used in tables)
   ============================================================ */

.user-cell-name { font-weight: 600; color: var(--text-1); }
.user-cell-login { color: var(--text-2); font-size: 0.875rem; }

/* ============================================================
   Shared — Modal + Form (usados por todas las vistas CRUD)
   Aunque conserven el prefijo `user-*` por compatibilidad, son
   estilos genéricos para modales de creación/edición.
   ============================================================ */

/* ── Modal container ────────────────────────────────────────── */
.user-modal-content {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.user-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.user-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.user-modal-body { padding: 1.25rem 1.5rem; }

.user-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

/* ── Form groups ────────────────────────────────────────────── */
.user-form-group { margin-bottom: 1rem; }
.user-form-group:last-child { margin-bottom: 0; }

.user-form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

.user-form-group .form-control {
  height: 40px;
  padding: 0 12px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 0.875rem;
  width: 100%;
}
.user-form-group .form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring, rgba(37,99,235,.15));
}
.user-form-group .form-control:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.user-form-group select.form-control { cursor: pointer; }

/* Placeholders visibles (aplica a todos los .form-control del proyecto). */
.form-control::placeholder {
  color: var(--text-3);
  opacity: 1; /* Firefox por defecto lo baja a 0.54 */
}
.form-control::-webkit-input-placeholder { color: var(--text-3); opacity: 1; }
.form-control::-moz-placeholder          { color: var(--text-3); opacity: 1; }
.form-control:-ms-input-placeholder      { color: var(--text-3); opacity: 1; }

.user-form-group textarea.form-control {
  min-height: 90px;
  padding: 10px 12px;
  height: auto;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.user-form-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-3);
}

/* Marca de campo obligatorio: usar <span class="required-mark">*</span>
   dentro del <label> para resaltar el asterisco. */
.required-mark {
  color: var(--danger);
  font-weight: 700;
  font-size: 1.1em;
  margin-left: 2px;
  line-height: 1;
}

/* Encabezado de sección dentro de un formulario (Contacto, Ubicación, etc.) */
.user-form-section {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Cancel button ──────────────────────────────────────────── */
.btn-user-cancel {
  height: 38px;
  padding: 0 1rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-user-cancel:hover {
  border-color: var(--border-strong, var(--border));
  color: var(--text-1);
}

/* Variante del btn-user-primary en rojo, para confirmaciones destructivas. */
.btn-user-primary.btn-danger-primary,
.btn-danger-primary {
  background: var(--danger) !important;
}
.btn-user-primary.btn-danger-primary:hover,
.btn-danger-primary:hover {
  background: #b91c1c !important;
}

/* Modal global de confirmación (invocado con window.appConfirm) */
.app-confirm-message {
  margin: 0;
  color: var(--text-1);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Modal global de resolución de duplicados (window.appDuplicateClient) */
.app-dup-intro {
  padding: 0.75rem 1rem;
  margin: 1.25rem 1.5rem 0;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.30);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 0.9rem;
  line-height: 1.5;
}
.app-dup-intro strong { color: var(--warning); }

.app-dup-list {
  padding: 0.5rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-dup-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.app-dup-item:hover {
  border-color: var(--brand-400);
}

.app-dup-info { flex: 1; min-width: 0; }
.app-dup-name {
  font-weight: 700;
  color: var(--text-1);
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.app-dup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-3);
  align-items: center;
}
.app-dup-meta .material-symbols-rounded {
  font-size: 14px;
  margin-right: 3px;
  vertical-align: -2px;
}

.app-dup-select {
  flex-shrink: 0;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.85rem;
}

/* ============================================================
   Botón de cerrar de Bootstrap (X) — visible en dark mode
   Bootstrap 5 usa un SVG negro por defecto que se pierde sobre
   nuestros fondos oscuros. Aplicamos el filtro que ellos usan
   para `.btn-close-white` a todos los `.btn-close` del app.
   ============================================================ */
.btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
  opacity: 0.7;
  transition: opacity 0.15s ease-in-out, transform 0.15s ease;
}
.btn-close:hover {
  opacity: 1;
  transform: scale(1.1);
}
.btn-close:focus {
  box-shadow: 0 0 0 3px var(--focus-ring-color);
  opacity: 1;
}

/* ============================================================
   Animaciones globales
   Deben vivir aquí (no en CSS de módulo) porque Titan Framework
   scopea el CSS del módulo con un atributo host, y @keyframes
   no soporta scoping — desde el módulo el nombre queda huérfano.
   ============================================================ */

/* Flash azul para resaltar un elemento agregado o actualizado.
   Usa `inset box-shadow` en vez de outline/box-shadow externo
   para evitar clipping cuando el padre tiene overflow:auto. */
@keyframes app-flash-blue {
  0% {
    background-color: rgba(37, 99, 235, 0.28);
    box-shadow: inset 0 0 0 2px var(--brand);
    transform: scale(1.01);
  }
  30% {
    background-color: rgba(37, 99, 235, 0.28);
    box-shadow: inset 0 0 0 2px var(--brand);
    transform: scale(1);
  }
  100% {
    background-color: transparent;
    box-shadow: inset 0 0 0 0 transparent;
    transform: scale(1);
  }
}

/* Clase utilitaria — cualquier elemento que reciba `.app-flash-blue`
   parpadea en azul durante 1200ms. */
.app-flash-blue {
  animation: app-flash-blue 1200ms ease-out !important;
  position: relative;
  z-index: 2;
}

/* Fade-in con pequeño slide horizontal, útil para errores inline
   que aparecen al lado de un label o campo. */
@keyframes app-fade-in-x {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Chips de método de pago (usados en POS + modal de abono en
   cuentas de crédito). Se comparte para no duplicar y para que
   funcione en cualquier vista (Titan scopea el CSS de módulo).
   Cada chip usa --method-accent (color del payment_method.color).
   ============================================================ */

.pos-method-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pos-method-chip {
  --method-accent: var(--brand);
  /* Reset del rendering nativo de <button> (Chrome/Safari) */
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  background: var(--surface-0);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.pos-method-chip:hover:not(.active) {
  border-color: var(--method-accent);
  color: var(--text-1);
}
.pos-method-chip.active {
  background: color-mix(in srgb, var(--method-accent) 15%, transparent);
  border-color: var(--method-accent);
  color: var(--method-accent);
  font-weight: 600;
}
.pos-method-chip.active .pos-method-chip-icon { color: var(--method-accent); }
.pos-method-chip-icon { font-size: 16px; }

/* Número flotante que sube y se desvanece (para deltas de cantidad, etc.).
   Uso: crea un <span class="app-float-number app-float-pos">+1</span>
   dentro de un contenedor con position:relative, se autodestruye. */
@keyframes app-float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -4px) scale(1.15);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -26px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -42px) scale(0.95);
  }
}

.app-float-number {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translate(-50%, 0);
  font-family: 'Sora', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 10;
  animation: app-float-up 900ms ease-out forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.app-float-pos { color: var(--success); }
.app-float-neg { color: var(--danger); }
