/* ============================================================
   UI-PAGES.CSS — Sistema visual unificado (todas las vistas)
   Responsivo, amigable, coherente con app.css + theme-mono
   ============================================================ */

/* --- Animación de entrada --- */
.app-content {
  animation: uiFadeIn 0.35s ease-out;
}
@keyframes uiFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Contenedor de página (todas las vistas con .container) --- */
.app-content > .container,
.page-app {
  max-width: 1400px;
}

.app-content > .container {
  padding-top: 0.75rem !important;
  padding-bottom: 1.5rem !important;
}

@media (min-width: 768px) {
  .app-content > .container {
    padding-top: 1rem !important;
    padding-bottom: 2rem !important;
  }
}

/* --- Encabezado unificado (.ui-page-header y alias .page-h) --- */
.ui-page-header,
.page-h,
.page-list-toolbar,
.page-header-ventas,
.page-split-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.35rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.ui-page-header-main,
.page-h > .d-flex:first-child,
.page-header-ventas > .d-flex:first-child {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1 1 220px;
  min-width: 0;
}

.ui-page-icon,
.page-h .ico,
.page-header-ventas .title-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.35);
}

.ui-page-subtitle,
.page-h .subtitle,
.page-header-ventas .subtitle {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  margin-bottom: 0.15rem;
}

.ui-page-title,
.page-h h3,
.page-list-toolbar > h1,
.page-list-toolbar > .h4,
.page-header-ventas h3 {
  margin: 0;
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.25;
}

.ui-page-meta,
.page-h .text-muted {
  font-size: 0.88rem;
  color: #64748b !important;
  margin-top: 0.25rem;
}

.ui-page-actions,
.page-h .ms-md-auto,
.page-list-toolbar .toolbar-actions,
.page-header-ventas .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .ui-page-actions,
  .page-h .ms-md-auto,
  .page-list-toolbar .toolbar-actions {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }
}

/* Botones compactos en barras de herramientas */
.ui-page-actions .btn,
.page-list-toolbar .btn,
.page-h .btn,
.page-header-ventas .btn,
.toolbar-actions .btn,
.quick-actions .btn {
  min-height: 42px !important;
  padding: 0.45rem 1rem !important;
  font-size: 0.88rem !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08) !important;
}

.ui-page-actions .btn-sm,
.page-list-toolbar .btn-sm,
.table .btn-sm {
  min-height: 34px !important;
  padding: 0.3rem 0.65rem !important;
  font-size: 0.8rem !important;
}

/* --- KPI cards --- */
.ui-kpi-card,
.page-app .row.g-3 > .col-12 > .card.p-3,
.page-app .row.g-3 > [class*="col-"] > .card.p-3.h-100 {
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.1rem 1.2rem;
  background: #fff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
  height: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
  .ui-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  }
}

.ui-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.ui-kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.ui-kpi-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.ui-kpi-value {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.ui-kpi-indigo .ui-kpi-ico { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.ui-kpi-emerald .ui-kpi-ico { background: rgba(16, 185, 129, 0.12); color: #059669; }
.ui-kpi-amber .ui-kpi-ico { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.ui-kpi-rose .ui-kpi-ico { background: rgba(244, 63, 94, 0.12); color: #e11d48; }
.ui-kpi-sky .ui-kpi-ico { background: rgba(14, 165, 233, 0.12); color: #0284c7; }

/* --- Filtros --- */
.ui-filter-card,
.card-f,
.card-ventas-filtros {
  border: 1px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04) !important;
  overflow: visible !important;
}

.ui-filter-card .form-label,
.card-f .form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.35rem;
}

.ui-filter-card .form-control,
.ui-filter-card .form-select,
.card-f .form-control,
.card-f .form-select {
  min-height: 44px !important;
  padding: 0.55rem 0.85rem !important;
  font-size: 0.92rem !important;
  border-radius: 0.65rem !important;
}

/* --- Tablas / datos --- */
.ui-data-card,
.card-config,
.page-app > .card:not(.ui-filter-card):not(.ui-form-card) {
  border: 1px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06) !important;
  overflow: hidden;
}

.ui-table-scroll {
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.ui-table-scroll.is-scrollable::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.06));
}

html[data-theme="mono"] .ui-data-card .table thead th,
.ui-data-card .table thead th,
.page-app .table thead th {
  background: #f8fafc !important;
  color: #0f172a !important;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e2e8f0 !important;
  padding: 0.85rem 0.75rem !important;
  white-space: nowrap;
}

.ui-data-card .table tbody td,
.page-app .table tbody td {
  padding: 0.8rem 0.75rem !important;
  font-size: 0.9rem;
  vertical-align: middle;
  border-color: #f1f5f9 !important;
}

.ui-data-card .table tbody tr:hover,
.page-app .table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04) !important;
}

/* Tabla responsiva: cards en móvil */
@media (max-width: 767.98px) {
  .ui-responsive-table thead {
    display: none;
  }

  .ui-responsive-table tbody tr {
    display: block;
    margin-bottom: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    padding: 0.5rem 0.65rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }

  .ui-responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.45rem 0.35rem !important;
    border: 0 !important;
    text-align: right !important;
  }

  .ui-responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    text-align: left;
    flex: 0 0 42%;
  }

  .ui-responsive-table tbody td.text-end {
    justify-content: flex-end;
  }

  .ui-responsive-table .ui-empty-row td {
    display: block;
    text-align: center !important;
  }

  .ui-responsive-table .ui-empty-row td::before {
    display: none;
  }
}

.ui-empty-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  color: #94a3b8;
}

.ui-empty-inline i {
  font-size: 2rem;
  opacity: 0.65;
}

.ui-empty-state .ui-empty-icon {
  font-size: 2.5rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}

/* --- Formularios --- */
.ui-form-card {
  border-radius: 1.25rem !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.07) !important;
}

.ui-form-card .form-label {
  font-weight: 700;
  font-size: 0.88rem;
  color: #334155;
}

.ui-form-card .form-control,
.ui-form-card .form-select {
  min-height: 46px !important;
  border-radius: 0.7rem !important;
}

.ui-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f1f5f9;
}

@media (max-width: 575.98px) {
  .ui-form-actions .btn {
    flex: 1 1 100%;
  }
}

/* --- Alertas --- */
.ui-alert {
  border: 0;
  border-radius: 0.85rem;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

/* --- Paginación --- */
.page-pagination-bar,
.ui-pagination {
  padding: 1rem 1.15rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 1rem 1rem;
}

/* --- Dashboard hereda card-soft --- */
.dashboard-page .card-soft.kpi {
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.dashboard-page .quick-actions {
  gap: 0.5rem !important;
}

/* --- Badges rol --- */
.badge-rol {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-weight: 700;
}
.badge-admin { background: #eef2ff; color: #4338ca; }
.badge-vendedor { background: #ecfdf5; color: #047857; }

/* --- Info callout --- */
.ui-callout {
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  font-size: 0.88rem;
  color: #475569;
  margin-bottom: 1.25rem;
}

/* --- Accesibilidad táctil --- */
@media (max-width: 991.98px) {
  .table .btn-sm {
    min-height: 38px !important;
    min-width: 38px !important;
  }
}

/* --- Reducir padding global en móvil --- */
/* Formularios en contenedor estrecho */
.app-content .container[style*="max-width"] .card,
.app-content .container-narrow .card {
  border-radius: 1.25rem !important;
}

@media (max-width: 575.98px) {
  .app-content {
    padding: 0.75rem !important;
  }

  .ui-page-header,
  .page-h,
  .page-list-toolbar {
    padding: 1rem;
    border-radius: 1rem;
  }

  .ui-page-icon,
  .page-h .ico {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}
