/* ============================================================
   SubGrid Pro — estilos base (chat-centric layout)
   ============================================================ */

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; }

/* Ocultar spinners en inputs numéricos */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* Iconify inline */
.iconify { display: inline-block; vertical-align: middle; }

/* Tab panels */
.tab-panel { animation: sgFadeIn .2s ease-out; }

/* Chat overlay — floating panel when opened from customers */
.chat-overlay {
  position: fixed !important;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95vw;
  max-width: 700px;
  height: 85vh;
  z-index: 50;
  border-radius: 1.5rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
  overflow: hidden;
  animation: sgSlideUp .25s ease-out;
}
.chat-overlay .context-panel-desktop { display: none !important; }
@keyframes sgSlideUp {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes sgFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Form classes */
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
  background: #fff;
}

.form-input::placeholder { color: #cbd5e1; font-weight: 500; }

/* Select arrow */
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='m7 10l5 5l5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Modal backdrop transition */
.modal-backdrop { transition: opacity .28s ease; }

/* Safe area para notch en iOS */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

/* Modal animation */
.modal-inner {
  transition: transform .3s cubic-bezier(.32,.72,0,1), opacity .28s ease, scale .28s ease;
}

/* Link sin subrayado */
a.no-underline { text-decoration: none; }

/* ── Desktop nav pill active state ──────────────────────────── */
.nav-btn[data-tab].nav-active {
  background: white;
  color: #4f46e5;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── Chat message bubbles ───────────────────────────────────── */
.chat-bubble-in {
  background: white;
  border: 1px solid #f1f5f9;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.chat-bubble-out {
  background: #4f46e5;
  color: white;
  border-radius: 18px 18px 4px 18px;
}

/* ── Chat background pattern ────────────────────────────────── */
#chat-messages {
  background-color: #efeae2;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d5cfc6' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── Conversation item hover ────────────────────────────────── */
.conv-item { transition: background-color .15s ease; }
.conv-item:hover { background-color: #f8fafc; }
.conv-item.active { background-color: #eef2ff; }

/* ── Context panel — always fixed on xl+ ──────────────────── */
.context-panel-desktop {
  display: none;
  flex-direction: column;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  flex-basis: 280px !important;
  width: 280px !important;
  min-width: 280px !important;
  max-width: 280px !important;
  border-left: 1px solid #f1f5f9;
  background: white;
  overflow: hidden;
}
@media (min-width: 1280px) {
  .context-panel-desktop { display: flex !important; }
}
@media (min-width: 1440px) {
  .context-panel-desktop {
    flex-basis: 320px !important;
    width: 320px !important;
    min-width: 320px !important;
    max-width: 320px !important;
  }
}
#context-content {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  width: 100% !important;
}
.ctx-section {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  overflow: hidden;
}
.ctx-section h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-section .ctx-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ctx-section .ctx-label { flex-shrink: 0; font-size: 11px; color: #64748b; }
.ctx-section .ctx-value { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }

/* ── Context panel mobile overlay ────────────────────────────── */
#context-panel.context-overlay {
  display: flex !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 40 !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  flex-basis: 100% !important;
}

/* ── Typing indicator animation ─────────────────────────────── */
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typingBounce .6s infinite alternate;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  from { opacity: .4; transform: translateY(0); }
  to   { opacity: 1; transform: translateY(-4px); }
}

/* ── Sync spin ──────────────────────────────────────────────── */
.spin-animation { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Message context menu ────────────────────────────────────── */
.msg-ctx-menu {
  position: fixed;
  z-index: 200;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
  border: 1px solid #f1f5f9;
  padding: 4px;
  min-width: 160px;
  animation: ctxIn .15s ease-out;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}
.msg-ctx-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  transition: background .15s;
}
.msg-ctx-menu button:hover { background: #f1f5f9; }
.msg-ctx-menu button.danger { color: #ef4444; }
.msg-ctx-menu button.danger:hover { background: #fef2f2; }

/* ── Chat modal animations (edit/delete message) ───────────── */
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(.97); }
}
.animate-modal-in { animation: modalIn .2s ease-out; }
.animate-modal-out { animation: modalOut .15s ease-in forwards; }

/* ── Settings tabs ─────────────────────────────────────────── */
.stab-btn { color: #94a3b8; }
.stab-btn:hover { background: #f1f5f9; color: #475569; }
.stab-btn.stab-active { background: #eef2ff; color: #4f46e5; }
.funnel-step { transition: all .2s; }
.funnel-step.locked { opacity: .5; pointer-events: none; }
.funnel-step .step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
.funnel-step .step-dot.pending { background: #f1f5f9; color: #94a3b8; }
.funnel-step .step-dot.active { background: #eef2ff; color: #4f46e5; border: 2px solid #4f46e5; }
.funnel-step .step-dot.done { background: #10b981; color: white; }
.funnel-line { width: 2px; height: 24px; margin-left: 15px; background: #e2e8f0; }
.funnel-line.done { background: #10b981; }

/* ── AI Suggestion preview ──────────────────────────────────── */
#ai-suggestion-preview { animation: sgFadeIn .2s ease-out; }
@keyframes sgFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
#ai-wand-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Search highlight ────────────────────────────────────────── */
.search-highlight { background: #fef08a; border-radius: 2px; padding: 0 1px; }

/* ── Emoji picker grid ───────────────────────────────────────── */
#emoji-grid button {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer;
  transition: background .1s, transform .1s;
}
#emoji-grid button:hover { background: #f1f5f9; transform: scale(1.2); }

/* ── Mobile: hide chat area on mobile, show contacts ────────── */
@media (max-width: 767px) {
  #chat-contacts-sidebar.mobile-hidden { display: none; }
  #chat-area.mobile-show { display: flex !important; }
}

/* ── Context panel overlay on small screens ──────────────────── */
#context-panel.context-overlay {
  min-width: 100% !important;
  max-width: 100% !important;
  background: white;
  z-index: 40;
}
