@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-color: #f5f5f7;
  --panel-bg: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --accent-color: #0071e3;
  --accent-hover: #0077ed;
  --success: #34c759;
  --border-color: rgba(0, 0, 0, 0.03);
  --border-radius: 14px;
  --shadow-subtle: 0 8px 24px rgba(0, 0, 0, 0.01), 0 2px 8px rgba(0, 0, 0, 0.01);
  --shadow-medium: 0 12px 36px rgba(0, 0, 0, 0.03), 0 4px 12px rgba(0, 0, 0, 0.02);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

/* Base fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-pane, .subview-pane {
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Centered Login screen style Apple */
.container {
  background: var(--panel-bg);
  padding: 48px 40px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  width: 100%;
  max-width: 400px;
  margin: 120px auto;
  display: none;
  border: 1px solid var(--border-color);
}
.container.active {
  display: block;
}
.container h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 24px 0;
  text-align: center;
}

/* Sidebar Navigation */
.admin-wrapper {
  display: none;
  min-height: 100vh;
}
.admin-wrapper.active {
  display: flex !important;
}
.sidebar {
  width: 260px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
  box-sizing: border-box;
  position: fixed;
  height: 100vh;
  z-index: 100;
}
.sidebar-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 40px;
  color: var(--text-primary);
}
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}
.menu-item {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.menu-item:hover {
  background: rgba(0, 0, 0, 0.02);
  color: var(--text-primary);
}
.menu-item.active {
  background: rgba(0, 113, 227, 0.06);
  color: var(--accent-color);
  font-weight: 600;
}

.main-content {
  margin-left: 260px;
  padding: 48px;
  width: calc(100% - 260px);
  box-sizing: border-box;
}

/* Headers */
.view-header-premium {
  margin-bottom: 32px;
}
.view-header-premium h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin: 0;
}

/* Cards Grid Layout */
.cards-grid, .companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-subtle);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.card.full-width {
  grid-column: 1 / -1;
}
.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text-primary);
}
.card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Big metrics styling */
.big-metric {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 10px !important;
  letter-spacing: -0.5px;
}

/* Apple Company Card styling */
.company-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-subtle);
}
.company-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
  border-color: rgba(0, 0, 0, 0.08);
}
.company-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.company-metrics {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Forms styling */
.apple-form label {
  display: block;
  margin-top: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
}
.apple-form input, .apple-form select, .apple-form textarea {
  width: 100%;
  padding: 12px 16px;
  margin-top: 6px;
  background: #f5f5f7;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  box-sizing: border-box;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.apple-form input:focus, .apple-form select:focus, .apple-form textarea:focus {
  border-color: var(--accent-color);
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

/* Upload zones */
.upload-zone {
  margin-top: 16px;
  padding: 28px;
  border: 2px dashed rgba(0, 0, 0, 0.06);
  border-radius: var(--border-radius);
  text-align: center;
  background: #f5f5f7;
  transition: all 0.25s ease;
}
.upload-zone:hover {
  border-color: var(--accent-color);
  background: rgba(0, 113, 227, 0.01);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  margin-top: 24px;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-primary:hover {
  background-color: var(--accent-hover);
}
.btn-primary:disabled {
  background-color: var(--text-secondary);
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-logout {
  width: 100%;
  background-color: #f5f5f7;
  color: var(--text-primary);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-logout:hover {
  background-color: #e8e8ed;
}

/* Badges */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(0, 113, 227, 0.06);
  color: var(--accent-color);
}

/* Result and consoles */
.result {
  margin-top: 24px;
  padding: 20px;
  background-color: #f5f5f7;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  line-height: 1.6;
}
.result h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 600;
}

/* Placeholder */
.placeholder-text {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  width: 100%;
  grid-column: 1 / -1;
  padding: 24px;
}

/* Sub-Tab Bar */
.sub-tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  white-space: nowrap;
}
.sub-tab-bar .menu-item {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}

/* Apple Switch Toggle style */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e8e8ed;
  transition: .3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
input:checked + .slider {
  background-color: #34c759;
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 24px;
}
.slider.round:before {
  border-radius: 50%;
}

/* Kanban / Kommo style */
.kanban-column {
  transition: background-color 0.2s ease;
}
.kanban-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kanban-card:active {
  cursor: grabbing;
  transform: scale(0.98);
  box-shadow: var(--shadow-medium);
}

/* Visual automation nodes */
.node-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color) !important;
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.08) !important;
}

/* System Heartbeat fixed bottom bar */
.system-heartbeat-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 1000;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.005);
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
.pulse-dot, #ia-status-dot {
  animation: pulseGreen 2.5s infinite;
}

/* Extra margin-bottom to avoid overlay from heartbeat bar */
.main-content {
  padding-bottom: 90px !important;
}

/* Google Sign-in button */
.btn-google {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-bg);
  color: var(--text-primary);
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease;
}
.btn-google:hover {
  background: #f5f5f7;
}

/* Facebook Sign-in button premium hover effects */
#btnFacebook {
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s ease, box-shadow 0.25s ease !important;
}
#btnFacebook:hover {
  background-color: #166fe5 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.15);
}
#btnFacebook:active {
  transform: translateY(0);
}


/* --- ESTILOS DE LIENZO DE NODOS COGNITIVOS MOONCORE --- */

@keyframes neon-pulse-purple {
  0% {
    box-shadow: 0 0 6px rgba(191, 90, 242, 0.15), inset 0 0 3px rgba(191, 90, 242, 0.08);
  }
  100% {
    box-shadow: 0 0 14px rgba(191, 90, 242, 0.5), inset 0 0 6px rgba(191, 90, 242, 0.25);
  }
}

@keyframes neon-pulse-green {
  0% {
    box-shadow: 0 0 6px rgba(48, 209, 88, 0.15), inset 0 0 3px rgba(48, 209, 88, 0.08);
  }
  100% {
    box-shadow: 0 0 14px rgba(48, 209, 88, 0.55), inset 0 0 6px rgba(48, 209, 88, 0.25);
  }
}

@keyframes neon-pulse-red {
  0% {
    box-shadow: 0 0 8px rgba(255, 69, 58, 0.25), inset 0 0 4px rgba(255, 69, 58, 0.15);
  }
  100% {
    box-shadow: 0 0 18px rgba(255, 69, 58, 0.7), inset 0 0 8px rgba(255, 69, 58, 0.35);
  }
}

/* Efecto de Alerta de Desvío (Glow Rojo parpadeante ultra verga para robo de clientes) */
.glow-alert-red {
  border: 1px solid rgba(255, 69, 58, 0.6) !important;
  animation: neon-pulse-red 1.5s infinite alternate !important;
  background: rgba(255, 59, 48, 0.03) !important;
}

/* --- TARJETAS COGNITIVAS GLASSMORPHISM BLANCO PREMIUM DE APPLE --- */

.kanban-card {
  background: rgba(255, 255, 255, 0.88) !important;
  backdrop-filter: blur(16px) !important;
  border: 1px solid rgba(0, 0, 0, 0.04) !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.02) !important;
  padding: 12px !important;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
  color: #1d1d1f !important;
}

/* Efecto de Flotar sobre el Lienzo de n8n al pasar el mouse */
.kanban-card:hover {
  background: #ffffff !important;
  transform: translateY(-4px) scale(1.02) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Tipografía y Textos Finos de Tarjetas */
.kanban-card h5 {
  color: #1d1d1f !important;
  font-weight: 600 !important;
  font-size: 12.5px !important;
  margin: 6px 0 2px 0 !important;
  letter-spacing: -0.2px !important;
}

.kanban-card p {
  color: #86868b !important;
  font-size: 10.5px !important;
  line-height: 1.4 !important;
}

/* Transición suave para las tarjetas del lienzo */
.kanban-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease !important;
}

.kanban-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* --- ANIMACIONES Y ESTILOS DEL LIENZO DE NODOS (NODE GRAPH UI) --- */

@keyframes flowStream {
  0% {
    stroke-dashoffset: 180;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.node-item {
  position: relative;
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  border-radius: 18px !important;
  padding: 16px 20px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.01), 0 8px 24px rgba(0, 0, 0, 0.01) !important;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.node-item:hover {
  transform: translateY(-4px) scale(1.02) !important;
  border-color: var(--accent-color) !important;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.08), 0 16px 36px rgba(0, 113, 227, 0.03) !important;
}

/* Efecto de pulso interactivo para los nodos del Sandbox */
.sandbox-highlight {
  animation: neon-pulse-purple 2s infinite alternate !important;
}


/* Estilos de barra de desplazamiento premium de estilo Figma/Linear para el lienzo de automatizaciones */
#automatizaciones-canvas {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#automatizaciones-canvas::-webkit-scrollbar {
  height: 6px;
}

#automatizaciones-canvas::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.01);
  border-radius: 10px;
}

#automatizaciones-canvas::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  transition: background-color 0.2s ease;
}

#automatizaciones-canvas::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* --- LABORATORIO DE IA - ESTILOS ADICIONALES --- */

/* Contenedor de mensajes de chat con patrón de fondo de alta fidelidad */
#ia-chat-messages-container {
  background-color: #efeae2;
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
  background-size: 20px 20px;
}

/* Burbujas de chat estilo WhatsApp */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 80%;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 2.5px rgba(0,0,0,0.05);
  position: relative;
  word-break: break-word;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mensaje enviado (Administrador / Cliente Simulado - Derecha) */
.chat-bubble.user {
  align-self: flex-end;
  background-color: #e1ffc7;
  color: #1d1d1f;
  border-top-right-radius: 2px;
}

/* Mensaje recibido (Respuesta de la IA - Izquierda) */
.chat-bubble.bot {
  align-self: flex-start;
  background-color: #ffffff;
  color: #1d1d1f;
  border-top-left-radius: 2px;
}

/* Mensajes informativos de confirmación en Modo Aprendizaje (Centro) */
.chat-bubble.system {
  align-self: center;
  background-color: rgba(52, 199, 89, 0.08);
  color: #2e7d32;
  border-radius: 16px;
  text-align: center;
  max-width: 90%;
  font-weight: 600;
  font-size: 12px;
  box-shadow: none;
  border: 1px dashed rgba(52, 199, 89, 0.2);
}

/* Conmutador de Modos */
#subview-ia .menu-item {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#subview-ia .menu-item.active {
  background: #ffffff !important;
  color: var(--accent-color) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
  font-weight: 600;
}

/* Elementos del historial de entrenamiento */
.timeline-item-training {
  padding: 10px 12px;
  background: #ffffff;
  border-left: 3px solid var(--accent-color);
  border-radius: 8px;
  font-size: 11.5px;
  box-shadow: var(--shadow-subtle);
  animation: fadeIn 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-item-training.learned {
  border-left-color: #34c759;
}

/* --- CONTROL DE VISIBILIDAD DE PANTALLAS (SISTEMA INTEGRADO) --- */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Responsividad para dispositivos móviles */
@media (max-width: 768px) {
  .admin-wrapper.active {
    flex-direction: column;
  }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 20px;
  }
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 20px;
  }
}
