/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}
body {
  font-family: "Inter", sans-serif;
}

/* ---------- Cards ---------- */
.sion-card {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ---------- Botones ---------- */
.sion-btn-primary {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .2s;
}
.sion-btn-primary:hover {
  background: #b91c1c;
}

.sion-btn-secondary {
  background: transparent;
  color: #93a3b8;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.sion-btn-secondary:hover {
  color: #e5e7eb;
  border-color: #1f2937;
}

/* ---------- Inputs ---------- */
.sion-input {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 12px;
  color: #e5e7eb;
  font-weight: 400;
}
.sion-input:focus {
  outline: none;
  border-color: #dc2626;
}

/* ---------- Chips / Badges ---------- */
.sion-chip {
  background: #334155;
  color: #e5e7eb;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sion-chip.active {
  background: #dc2626;
}

.sion-badge {
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  line-height: 1.4;
}
.sion-badge.success {
  background: #065f46;
  color: #10b981;
}
.sion-badge.warning {
  background: #92400e;
  color: #f59e0b;
}
.sion-badge.error {
  background: #7f1d1d;
  color: #ef4444;
}
.sion-badge.info {
  background: #1e3a8a;
  color: #3b82f6;
}

/* ---------- Tablas ---------- */
.sion-table {
  width: 100%;
  border-collapse: collapse;
}
.sion-table th {
  background: #0f172a;
  color: #93a3b8;
  font-weight: 500;
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  z-index: 10;
}
.sion-table td {
  padding: 12px;
  border-bottom: 1px solid #1f2937;
  color: #e5e7eb;
}
.sion-table tr:hover {
  background: rgba(15, 23, 42, 0.5);
}

/* ---------- Calendario ---------- */
.calendar-event {
  border-radius: 4px;
  padding: 4px 8px;
  margin: 2px 0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.event-fabrica {
  background: #1e3a8a;
  color: #3b82f6;
}
.event-instalacion {
  background: #365314;
  color: #65a30d;
}
.event-preparacion {
  background: #92400e;
  color: #f59e0b;
}

/* ---------- Sidebar (drawer) ---------- */
.sidebar {
  position: fixed;
  right: -400px;
  top: 0;
  width: 400px;
  height: 100%;
  background: #0f172a;
  border-left: 1px solid #334155;
  transition: right .3s ease;
  z-index: 50;
  overflow-y: auto;
}
.sidebar.open {
  right: 0;
}

/* ---------- Modales ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.open {
  display: flex;
}

/* ---------- Toasts ---------- */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  z-index: 200;
  transform: translateX(400px);
  transition: transform .3s ease;
}
.toast.show {
  transform: translateX(0);
}
.toast.success {
  background: #065f46;
}
.toast.error {
  background: #7f1d1d;
}

/* ---------- Etiqueta n8n ---------- */
.n8n-tag {
  background: #4f46e5;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

/* ---------- Navegación / Screens ---------- */
.screen-content {
  display: none;
}
.screen-content.active {
  display: block;
}

.screen-nav {
  color: #93a3b8;
  background: transparent;
  border-radius: 12px;
  transition: color .2s, background .2s;
}
.screen-nav.active {
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.1) !important;
}

/* ---------- Chat Bot Styles ---------- */
#chat-window {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 380px;
  height: 600px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#chat-window.translate-y-full {
  transform: translateY(100%);
}

#chat-window.opacity-0 {
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  padding: 16px;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #0b1220;
  scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: #0f172a;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

#chat-quick-actions {
  padding: 12px 16px;
  background: #0f172a;
  border-top: 1px solid #1f2937;
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}

#chat-quick-actions::-webkit-scrollbar {
  height: 4px;
}

#chat-quick-actions::-webkit-scrollbar-track {
  background: transparent;
}

#chat-quick-actions::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 2px;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f2937;
  border: 1px solid #334155;
  color: #e5e7eb;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 8px;
}

.quick-action-btn:hover {
  background: #334155;
  border-color: #dc2626;
}

#chat-form {
  padding: 16px;
  background: #0f172a;
  border-top: 1px solid #1f2937;
  flex-shrink: 0;
}

#chat-input {
  width: 100%;
  background: #1f2937;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px 16px;
  color: #e5e7eb;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
}

#chat-input:focus {
  border-color: #dc2626;
}

#send-button {
  position: absolute;
  right: 24px;
  bottom: 24px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

#send-button:hover:not(:disabled) {
  background: #b91c1c;
  transform: scale(1.05);
}

#send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
  transition: all 0.3s;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}

.chat-connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #10b981;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.typing-indicator {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #93a3b8;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* ---------- Utilidades ---------- */
.hidden {
  display: none !important;
}