/* ============================================================
   MULTI SYSTEM — Layout administrativo (sidebar + header + shell)
   Se agrega a styles.css, no lo reemplaza.
   ============================================================ */

/* -------------------- Shell general -------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* -------------------- Sidebar -------------------- */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.18s ease;
  z-index: 40;
}

.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-business-name,
.sidebar.collapsed .sidebar-business-plan { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar.collapsed .sidebar-logo-icon { display: flex; }

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo-full { height: 34px; }
.sidebar-logo-icon {
  display: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-3), var(--accent), var(--accent-2));
  align-items: center;
  justify-content: center;
  color: #05100e;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.sidebar-collapse-btn {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 4px; display: flex;
}
.sidebar-collapse-btn:hover { color: var(--text); }
.sidebar-collapse-btn svg { width: 16px; height: 16px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.sidebar-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}
.sidebar-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}

.nav-item:hover { background: var(--surface-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent-3), var(--accent-2));
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 18px;
}

.sidebar-business {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-business-avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-3), var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #05100e; font-family: var(--font-display); font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.sidebar-business-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-business-plan { font-size: 11px; color: var(--text-faint); }

/* -------------------- Header -------------------- */
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  gap: 16px;
  position: sticky;
  top: 0;
  background: rgba(10, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.topbar-search {
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-faint);
  font-size: 13px;
  cursor: pointer;
}
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-search kbd {
  margin-left: auto;
  font-size: 10.5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--text-faint);
  font-family: var(--font-body);
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.notif-badge {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg);
  display: none;
}
.notif-badge.show { display: block; }

.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-3), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #05100e; font-family: var(--font-display); font-weight: 700; font-size: 13px;
  cursor: pointer;
  margin-left: 4px;
  border: none;
}

/* -------------------- Main content -------------------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 26px 28px 60px;
}

.page-header { margin-bottom: 22px; }
.page-header .greeting { font-size: 22px; margin-bottom: 4px; }
.page-header .greeting-sub { font-size: 13.5px; }

/* -------------------- KPI cards -------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 14px; height: 14px; }

.kpi-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.kpi-delta {
  font-size: 12px;
  color: var(--text-faint);
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* -------------------- Panels -------------------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-title {
  font-size: 15px;
  margin-bottom: 4px;
}
.panel-subtitle {
  font-size: 12.5px;
  margin-bottom: 16px;
}

/* -------------------- Empty state -------------------- */
.empty-state {
  text-align: center;
  padding: 34px 16px;
  color: var(--text-faint);
}
.empty-state svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: 0.6; }
.empty-state-title { font-size: 13.5px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.empty-state-sub { font-size: 12.5px; }

/* -------------------- Simple list rows -------------------- */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.list-row:last-child { border-bottom: none; }
.list-row-title { color: var(--text); font-weight: 600; }
.list-row-sub { color: var(--text-faint); font-size: 12px; }
.list-row-value { color: var(--text); font-weight: 700; font-family: var(--font-display); }

/* -------------------- Skeleton loading -------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--surface-hover) 37%, var(--bg-elevated) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* -------------------- Mobile responsive -------------------- */
@media (max-width: 960px) {
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: 20px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 39;
  }
  .sidebar-backdrop.show { display: block; }
  .topbar-search { display: none; }
  .main-content { padding: 18px 16px 50px; }
  .mobile-menu-btn { display: flex !important; }
}

.mobile-menu-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ============================================================
   Componentes compartidos por las pantallas de administración
   (Productos, Clientes, Compras, etc.)
   ============================================================ */

/* -------------------- Modal genérico -------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3, 5, 9, 0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box.wide { max-width: 620px; }

.modal-title { font-size: 18px; margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; margin-bottom: 20px; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* -------------------- Barra de acciones de página -------------------- */
.page-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-actions-row .btn { width: auto; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}

.table-search {
  flex: 1;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.table-search svg { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; }
.table-search input {
  border: none; background: transparent; outline: none;
  color: var(--text); font-family: var(--font-body); font-size: 13.5px; width: 100%;
}
.table-search input::placeholder { color: var(--text-faint); }

/* -------------------- Data table -------------------- */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-hover); }

.cell-primary { color: var(--text); font-weight: 600; }
.cell-thumb {
  width: 36px; height: 36px;
  border-radius: 7px;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.cell-thumb img { width: 100%; height: 100%; object-fit: cover; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.status-pill.active { background: rgba(61, 220, 151, 0.14); color: var(--success); }
.status-pill.inactive { background: rgba(139, 148, 167, 0.14); color: var(--text-faint); }
.status-pill.warning { background: rgba(255, 180, 84, 0.14); color: var(--warning); }
.status-pill.danger { background: rgba(255, 92, 114, 0.14); color: var(--danger); }

.row-actions { display: flex; gap: 6px; }
.row-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.row-action-btn:hover { border-color: var(--border-strong); color: var(--text); }
.row-action-btn svg { width: 14px; height: 14px; }

/* -------------------- Toggle switch -------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.toggle-row-label { font-size: 13.5px; color: var(--text); }
.toggle-row-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--accent-3), var(--accent-2));
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* -------------------- Form grid (2 columnas en modales anchos) -------------------- */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
@media (max-width: 560px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* -------------------- Filas de ítems editables (compras, ventas manuales, etc.) -------------------- */
.line-items {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.line-item-row {
  display: grid;
  grid-template-columns: 2fr 80px 110px 90px 30px;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
.line-item-row:last-child { border-bottom: none; }
.line-item-row select,
.line-item-row input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
}
.line-item-remove {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.line-item-remove:hover { color: var(--danger); }
.line-item-add {
  padding: 10px;
  text-align: center;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-elevated);
}
.line-item-add:hover { background: var(--surface-hover); }
.line-items-total {
  text-align: right;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.line-items-total strong { color: var(--text); font-family: var(--font-display); font-size: 15px; }

/* -------------------- Tabs (Configuración) -------------------- */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
}
.settings-tab {
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.settings-tab:hover { color: var(--text-muted); }
.settings-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.settings-section { max-width: 640px; }
.settings-section-title { font-size: 15px; margin-bottom: 4px; }
.settings-section-sub { font-size: 13px; margin-bottom: 20px; }

.module-toggle-list { display: flex; flex-direction: column; gap: 2px; }
.module-toggle-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.module-toggle-item .name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.module-toggle-item .desc { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.permission-group { margin-bottom: 14px; }
.permission-group-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 8px; }
.permission-checkbox-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; color: var(--text-muted); }
.permission-checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }
