/* ===========================
   Dashboard Pro — Tema Naranja + Blanco
   (drop-in replacement)
   =========================== */

/* Paleta local al contenedor del dashboard para no afectar al resto */
#dashboardProContainer {
  --brand-50: #FFF7ED;
  /* Orange 50 */
  --brand-100: #FFEDD5;
  --brand-200: #FED7AA;
  --brand-300: #FDBA74;
  --brand-400: #FB923C;
  --brand-500: #F97316;
  /* acento principal */
  --brand-600: #EA580C;
  --brand-700: #C2410C;
  --brand-800: #9A3412;
  --brand-900: #7C2D12;

  --card-bg: #ffffff;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, .10), 0 2px 4px -1px rgba(0, 0, 0, .06);
  --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, .10), 0 4px 6px -2px rgba(0, 0, 0, .06);
  --ring: 0 0 0 3px rgba(249, 115, 22, .18);
  /* brand-500 alpha */
  --line-muted: #e5e7eb;
  --tooltip-bg: #111827;
  --tooltip-fg: #ffffff;
  --muted-50: #f9fafb;

  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Grid de widgets ===== */
.dashboard-widgets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0 2rem;
}

@media (max-width: 1024px) {
  .dashboard-widgets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-widgets-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Widgets ===== */
.dashboard-widget {
  animation: slideUp 0.5s ease-out both;
  min-height: 200px;
  background: var(--card-bg);
  border: 1px solid #eef2f7;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.dashboard-widget:nth-child(1) {
  animation-delay: .1s;
}

.dashboard-widget:nth-child(2) {
  animation-delay: .2s;
}

.dashboard-widget:nth-child(3) {
  animation-delay: .3s;
}

.dashboard-widget:nth-child(4) {
  animation-delay: .4s;
}

.dashboard-widget:nth-child(5) {
  animation-delay: .5s;
}

.dashboard-widget:nth-child(6) {
  animation-delay: .6s;
}

.dashboard-widget:nth-child(7) {
  animation-delay: .7s;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tamaños de widgets */
.dashboard-widget.col-span-1 {
  grid-column: span 1;
}

.dashboard-widget.col-span-2 {
  grid-column: span 2;
}

.dashboard-widget.col-span-3 {
  grid-column: span 3;
}

@media (max-width: 1024px) {
  .dashboard-widget.col-span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {

  .dashboard-widget.col-span-1,
  .dashboard-widget.col-span-2,
  .dashboard-widget.col-span-3 {
    grid-column: span 1;
  }
}

/* ===== KPI Cards ===== */
.kpi-card {
  position: relative;
  overflow: hidden;
  transition: all .25s ease;
  box-shadow: var(--card-shadow);
  border-top: 3px solid var(--brand-500);
  background: var(--card-bg);
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(closest-side, var(--brand-50), transparent 70%);
  border-radius: 50%;
  opacity: .8;
}

/* ===== Funnel de conversión ===== */
.funnel-stage {
  position: relative;
  margin-bottom: 1rem;
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: 10px;
  padding: .75rem;
  transition: transform .3s ease;
}

.funnel-stage:hover {
  transform: scale(1.02);
}

.funnel-stage:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--brand-200);
}

/* ===== Timeline de actividad ===== */
.activity-timeline {
  position: relative;
}

.activity-timeline>div {
  position: relative;
  padding-left: .5rem;
}

.activity-timeline>div:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 48px;
  bottom: -16px;
  width: 2px;
  background: var(--brand-100);
}

/* ===== Animaciones de carga ===== */
.widget-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.widget-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid #f3f4f6;
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Tooltips personalizados ===== */
.dashboard-tooltip {
  position: relative;
  cursor: help;
}

.dashboard-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  padding: .5rem 1rem;
  border-radius: .375rem;
  font-size: .875rem;
  white-space: nowrap;
  z-index: 10;
  animation: tooltipFadeIn .3s ease;
  border: 1px solid var(--brand-700);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Modal de configuración ===== */
#widgetConfigModal {
  backdrop-filter: blur(4px);
}

#widgetConfigModal .modal-content {
  animation: modalSlideIn .3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Tablas de rendimiento ===== */
.performance-table {
  font-size: .875rem;
}

.performance-table th {
  background-color: #fff7f0;
  /* suave anaranjado */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.performance-table tr:hover {
  background-color: #fff3e8;
  transition: background-color .2s ease;
}

/* ===== Badges / Etiquetas ===== */
.metric-badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  font-size: .75rem;
  font-weight: 500;
  border-radius: 9999px;
  transition: all .2s ease;
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-200);
}

.metric-badge:hover {
  transform: scale(1.05);
  box-shadow: var(--ring);
}

/* ===== Gráficos responsivos ===== */
canvas {
  max-width: 100% !important;
  height: auto !important;
}

/* ===== Estado de refresco ===== */
.refreshing {
  position: relative;
  pointer-events: none;
  opacity: .6;
}

.refreshing::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid var(--brand-500);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

/* ===== Estados vacíos ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6b7280;
}

.empty-state svg {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  opacity: .4;
  fill: var(--brand-300);
}

/* ===== Botones (ripple suave) ===== */
.dashboard-btn {
  position: relative;
  overflow: hidden;
  transition: all .3s ease;
  background: var(--card-bg);
  border: 1px solid #eaeef4;
}

.dashboard-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .35);
  transform: translate(-50%, -50%);
  transition: width .6s, height .6s;
}

.dashboard-btn:hover::before {
  width: 300px;
  height: 300px;
}

.dashboard-btn:hover {
  box-shadow: var(--card-shadow-hover);
}

/* ===== Scrollbar personalizada ===== */
.dashboard-widgets-grid::-webkit-scrollbar,
.activity-timeline::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.dashboard-widgets-grid::-webkit-scrollbar-track,
.activity-timeline::-webkit-scrollbar-track {
  background: #fff2e6;
  /* brand-50 intenso */
  border-radius: 4px;
}

.dashboard-widgets-grid::-webkit-scrollbar-thumb,
.activity-timeline::-webkit-scrollbar-thumb {
  background: var(--brand-300);
  border-radius: 4px;
}

.dashboard-widgets-grid::-webkit-scrollbar-thumb:hover,
.activity-timeline::-webkit-scrollbar-thumb:hover {
  background: var(--brand-400);
}

/* ===== Print ===== */
@media print {

  .dashboard-pro-header,
  .widget-actions,
  #widgetConfigModal {
    display: none !important;
  }

  .dashboard-widgets-grid {
    grid-template-columns: 1fr !important;
  }

  .dashboard-widget {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* ===== Alturas de contenedores de charts ===== */
#pipelineChart,
#forecastChart,
#typeMetricsChart {
  max-height: 300px !important;
}

/* ===== Utilidades mínimas necesarias (respetamos tus clases existentes) ===== */
.mb-6 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-1 {
  margin-bottom: .25rem;
}

.mt-2 {
  margin-top: .5rem;
}

.mt-1 {
  margin-top: .25rem;
}

.mt-20 {
  margin-top: 5rem;
}

.mr-2 {
  margin-right: .5rem;
}

.gap-3 {
  gap: .75rem;
}

.gap-2 {
  gap: .5rem;
}

.p-6 {
  padding: 1.5rem;
}

.p-3 {
  padding: .75rem;
}

.p-1 {
  padding: .25rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-2 {
  padding-top: .5rem;
  padding-bottom: .5rem;
}

.py-3 {
  padding-top: .75rem;
  padding-bottom: .75rem;
}

.pr-3 {
  padding-right: .75rem;
}

.px-2\.5 {
  padding-left: .625rem;
  padding-right: .625rem;
}

.py-0\.5 {
  padding-top: .125rem;
  padding-bottom: .125rem;
}

.rounded-lg {
  border-radius: .5rem;
}

.rounded-full {
  border-radius: 9999px;
}

.rounded {
  border-radius: .25rem;
}

.border {
  border-width: 1px;
}

.border-2 {
  border-width: 2px;
}

.border-b-2 {
  border-bottom-width: 2px;
}

.border-t {
  border-top-width: 1px;
}

.border-gray-300 {
  border-color: #d1d5db;
}

.border-gray-200 {
  border-color: #e5e7eb;
}

.border-red-200 {
  border-color: #fecaca;
}

.bg-white {
  background-color: #ffffff;
}

.bg-gray-50 {
  background-color: #f9fafb;
}

.bg-gray-200 {
  background-color: #e5e7eb;
}

.bg-gray-300 {
  background-color: #d1d5db;
}

.bg-gray-400 {
  background-color: #9ca3af;
}

.bg-red-50 {
  background-color: #fef2f2;
}

.bg-black {
  background-color: #000;
}

/* Gradientes útiles (por si los usas en headers de widget) */
.bg-gradient-to-br {
  background-image: linear-gradient(to bottom right, var(--tw-gradient-stops));
}

.from-orange-500 {
  --tw-gradient-from: var(--brand-500);
}

.to-orange-600 {
  --tw-gradient-to: var(--brand-600);
}

.text-white {
  color: #ffffff;
}

/* Texto */
.text-3xl {
  font-size: 1.875rem;
  line-height: 2.25rem;
}

.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.text-xl {
  font-size: 1.25rem;
  line-height: 1.75rem;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.text-sm {
  font-size: .875rem;
  line-height: 1.25rem;
}

.text-xs {
  font-size: .75rem;
  line-height: 1rem;
}

.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

.font-medium {
  font-weight: 500;
}

.text-gray-500 {
  color: #6b7280;
}

.text-gray-400 {
  color: #9ca3af;
}

.text-gray-600 {
  color: #4b5563;
}

.text-gray-700 {
  color: #374151;
}

.text-gray-900 {
  color: #111827;
}

.text-orange-100 {
  color: var(--brand-100);
}

.text-blue-600 {
  color: #2563eb;
}

/* mantenemos por compatibilidad puntual */
.text-green-600 {
  color: #16a34a;
}

.text-blue-800 {
  color: #1e40af;
}

.text-green-800 {
  color: #166534;
}

.text-purple-800 {
  color: #6b21a8;
}

.bg-blue-400 {
  background-color: #60a5fa;
}

/* compat */
.bg-green-400 {
  background-color: #4ade80;
}

.bg-purple-400 {
  background-color: #c084fc;
}

.bg-orange-400 {
  background-color: var(--brand-400);
}

.bg-blue-500 {
  background-color: #3b82f6;
}

/* compat */
.bg-green-500 {
  background-color: #22c55e;
}

.bg-yellow-500 {
  background-color: #eab308;
}

.bg-purple-500 {
  background-color: #a855f7;
}

.bg-blue-600 {
  background-color: #2563eb;
}

/* compat */
.bg-blue-100 {
  background-color: #dbeafe;
}

/* compat */
.bg-green-100 {
  background-color: #dcfce7;
}

/* compat */
.bg-purple-100 {
  background-color: #f3e8ff;
}

/* compat */

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.uppercase {
  text-transform: uppercase;
}

.tracking-wider {
  letter-spacing: .05em;
}

.shadow-sm {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);
}

.shadow-xl {
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);
}

.transition {
  transition-property: all;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: 150ms;
}

.transition-all {
  transition-property: all;
}

.duration-500 {
  transition-duration: 500ms;
}

.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.inline {
  display: inline;
}

.inline-block {
  display: inline-block;
}

.grid {
  display: grid;
}

.hidden {
  display: none;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.space-y-4>*+* {
  margin-top: 1rem;
}

.space-y-3>*+* {
  margin-top: .75rem;
}

.divide-y>*+* {
  border-top-width: 1px;
}

.divide-gray-200>*+* {
  border-color: #e5e7eb;
}

.overflow-x-auto {
  overflow-x: auto;
}

.overflow-y-auto {
  overflow-y: auto;
}

.overflow-hidden {
  overflow: hidden;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whitespace-nowrap {
  white-space: nowrap;
}

.h-full {
  height: 100%;
}

.h-32 {
  height: 8rem;
}

.h-8 {
  height: 2rem;
}

.h-10 {
  height: 2.5rem;
}

.h-12 {
  height: 3rem;
}

.h-64 {
  height: 16rem;
}

.w-full {
  width: 100%;
}

.w-5 {
  width: 1.25rem;
}

.w-6 {
  width: 1.5rem;
}

.w-8 {
  width: 2rem;
}

.w-10 {
  width: 2.5rem;
}

.w-12 {
  width: 3rem;
}

.max-w-2xl {
  max-width: 42rem;
}

.max-w-4xl {
  max-width: 56rem;
}

.max-h-96 {
  max-height: 24rem;
}

.min-w-full {
  min-width: 100%;
}

.min-w-0 {
  min-width: 0;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.fixed {
  position: fixed;
}

.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.relative {
  position: relative;
}

.z-50 {
  z-index: 50;
}

.flex-1 {
  flex: 1 1 0%;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

/* ===== Micro-interacciones para lista de configuración ===== */
#widgetConfigList>div {
  transition: transform .3s ease, opacity .3s ease;
}

#widgetConfigList>div.moving-up {
  transform: translateY(-10px);
  opacity: .7;
}

#widgetConfigList>div.moving-down {
  transform: translateY(10px);
  opacity: .7;
}

/* === Remapeo a naranja dentro del Dashboard Pro === */
#dashboardProContainer .text-blue-600 {
  color: var(--brand-600) !important;
}

#dashboardProContainer .bg-blue-600 {
  background-color: var(--brand-600) !important;
}

#dashboardProContainer .hover\:bg-blue-700:hover {
  background-color: var(--brand-700) !important;
}

#dashboardProContainer .border-blue-600 {
  border-color: var(--brand-600) !important;
}

/* “Ring” de foco equivalente en naranja */
#dashboardProContainer .focus\:ring-blue-500:focus {
  box-shadow: var(--ring);
  outline: none;
}

/* Checkboxes / radios con acento naranja */
#dashboardProContainer input[type="checkbox"],
#dashboardProContainer input[type="radio"] {
  accent-color: var(--brand-600);
}

/* === Tokens de marca (por si no existen) === */
:root {
  --brand-50: #fff7ed;
  --brand-100: #ffedd5;
  --brand-200: #fed7aa;
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --brand-800: #9a3412;
  --ring: 0 0 0 3px rgba(234, 88, 12, .35);
}

/* === Botones del dashboard (naranja/blanco) === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-radius: .75rem;
  font-weight: 600;
  transition: transform .15s, box-shadow .2s, background-color .2s, border-color .2s
}

.btn:active {
  transform: translateY(1px)
}

.btn svg {
  width: 1.25rem;
  height: 1.25rem
}

.btn-primary--orange {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  box-shadow: 0 8px 16px -6px rgba(234, 88, 12, .45)
}

.btn-primary--orange:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700))
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb
}

.btn-secondary:hover {
  background: #f9fafb
}

.btn-ghost {
  background: transparent;
  border: 1px dashed #e5e7eb;
  color: #374151
}

.btn-ghost:hover {
  background: #f9fafb
}

/* Checkboxes/radios con acento naranja */
#dashboardProContainer input[type="checkbox"],
#dashboardProContainer input[type="radio"] {
  accent-color: var(--brand-600)
}

#dashboardProContainer .focus\:ring-blue-500:focus {
  box-shadow: var(--ring);
  outline: none
}

/* Remapeo de utilidades “azules” a naranja dentro del dashboard */
#dashboardProContainer .text-blue-600 {
  color: var(--brand-600) !important
}

#dashboardProContainer .bg-blue-600 {
  background-color: var(--brand-600) !important
}

#dashboardProContainer .hover\:bg-blue-700:hover {
  background-color: var(--brand-700) !important
}

#dashboardProContainer .border-blue-600 {
  border-color: var(--brand-600) !important
}

/* === Vista de una sola columna para editar widgets === */
#widgetsContainer.one-column {
  grid-template-columns: 1fr !important;
  gap: 1rem !important;
}

#widgetsContainer.one-column .dashboard-widget {
  grid-column: span 1 !important
}

/* Botones del modal en estilo naranja */
#widgetConfigModal .btn-primary--orange {
  color: #fff
}

/* ===========================
   AJUSTES DE LAYOUT PARA THOR
   (compactar y encajar en viewport)
   =========================== */

/* Contenedor general del Dashboard Pro:
   - ancho máximo centrado
   - scroll vertical propio
   - relleno más contenido
*/
#dashboardProContainer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  box-sizing: border-box;
  max-height: calc(100vh - 130px);
  /* ajusta 130px si tu header es más alto/bajo */
  overflow-y: auto;
  overflow-x: hidden;
}

/* Grid más fluida y con menos separación para que no “explote” el layout */
#dashboardProContainer .dashboard-widgets-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

/* Widgets un poco más compactos */
#dashboardProContainer .dashboard-widget {
  min-height: 160px;
}

/* Paddings algo más pequeños dentro del dashboard
   (sin afectar al resto de la app) */
#dashboardProContainer .p-6 {
  padding: 1.25rem;
}

/* Margen superior grande dentro del dashboard, lo reducimos
   para que no quede todo tan “abajo” */
#dashboardProContainer .mt-20 {
  margin-top: 2rem;
}

/* Gaps algo más contenidos en layout interno */
#dashboardProContainer .gap-3 {
  gap: 0.5rem;
}

/* Tipografías más pequeñas solo dentro del dashboard
   (fuera se mantienen como estaban) */
#dashboardProContainer .text-3xl {
  font-size: 1.5rem;
  line-height: 1.9rem;
}

#dashboardProContainer .text-2xl {
  font-size: 1.25rem;
  line-height: 1.7rem;
}

#dashboardProContainer .text-xl {
  font-size: 1.1rem;
  line-height: 1.5rem;
}

/* Charts más contenidos en altura */
#dashboardProContainer #pipelineChart,
#dashboardProContainer #forecastChart,
#dashboardProContainer #typeMetricsChart {
  max-height: 240px !important;
}

/* Canvas solo del dashboard responsivos
   (ya no tocamos todos los canvas globales) */
#dashboardProContainer canvas {
  max-width: 100% !important;
  height: auto !important;
}