/* ============================================================
   PIXEL COTIZADOR — Estilos
   Archivo: assets/css/cotizador.css
   ============================================================ */

:root {
  --bg:        #0a0e1a;
  --surface:   #111827;
  --surface2:  #1e293b;
  --border:    #334155;
  --accent:    #3b82f6;
  --accent2:   #60a5fa;
  --text:      #f8fafc;
  --muted:     #94a3b8;
  --green:     #22c55e;
  --red:       #ef4444;
  --radius:    20px;
  --card-bg:   linear-gradient(180deg, #0f172a 0%, #1e3a5f 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(96, 165, 250, 0.1) 0%, transparent 50%);
}

/* ── Wrapper ─────────────────────────────────────────────────── */
.chat-wrapper {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-panel {
  display: flex;
  gap: 0;
  align-items: stretch;
  width: 100%;
  min-height: 600px;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 0 10px;
}

.header-left { display: flex; flex-direction: column; gap: 8px; }

.header-center { flex: 1; display: flex; justify-content: center; }

.header-center-logo {
  height: 60px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.header-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.header-back-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── Side Card ───────────────────────────────────────────────── */
.chat-side-card {
  flex-shrink: 0;
  width: 300px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-side-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(59, 130, 246, 0.2) 0%, transparent 60%);
  pointer-events: none;
}

.chat-side-card-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
  position: relative;
  z-index: 1;
  gap: 16px;
}

.bot-image-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-side-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  position: relative;
  z-index: 2;
  animation: gentle-float 4s ease-in-out infinite;
}

@keyframes gentle-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.chat-side-name {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.online-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--green);
  animation: blink 2s infinite;
}

.status-text { font-size: 13px; color: var(--green); font-weight: 500; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Chat container ──────────────────────────────────────────── */
.chat-container {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.chat-topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.bot-avatar-wrap { flex-shrink: 0; }

.bot-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.bot-info strong { display: block; font-size: 16px; font-weight: 700; color: #1e293b; }

.online-dot {
  font-size: 13px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.online-dot::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  animation: blink 2s infinite;
}

.progress-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.progress-track {
  width: 100px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width .6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Messages ────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  /* Scroll automático al final siempre */
  overflow-anchor: none;
  scroll-behavior: auto;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.msg { display: flex; gap: 12px; }

.msg.bot  { align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }

.msg-bot-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid var(--accent);
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.msg-bot-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.msg.bot  .msg-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top-left-radius: 4px;
  color: #334155;
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Typing dots */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 6px 2px;
  align-items: center;
}

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

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

@keyframes typingAnim {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Options area ────────────────────────────────────────────── */
.options-area {
  padding: 16px 24px 20px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.option-btn {
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  color: #334155;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.option-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(59, 130, 246, 0);
  transition: background .15s;
  border-radius: inherit;
  pointer-events: none;
}

.option-btn:hover {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.option-btn:active {
  transform: scale(0.97);
}

/* Estado seleccionado — claro y visible */
.option-btn.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transform: translateY(-1px);
}

.option-btn.selected .opt-icon {
  filter: none;
}

/* Checkmark en opciones seleccionadas */
.option-btn.selected::after {
  content: '✓';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  background: none;
  inset: auto;
  border-radius: 0;
}

.option-btn .opt-icon { font-size: 18px; flex-shrink: 0; }

/* Botón confirmar multiselección */
.confirm-btn {
  background: linear-gradient(135deg, var(--accent), #6340d8) !important;
  color: #fff !important;
  border-color: transparent !important;
  grid-column: 1 / -1;
  justify-content: center;
  font-weight: 600;
}

.confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4) !important;
  color: #fff !important;
}

/* El confirm-btn nunca muestra el checkmark de .selected */
.confirm-btn::after { display: none !important; }

/* Inputs de texto */
.text-input-row { display: flex; gap: 10px; }
.text-input-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; font-weight: 600; }

input.simple-input, textarea.free-text {
  flex: 1;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  color: #334155;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: border-color .2s, box-shadow .2s;
}

input.simple-input:focus, textarea.free-text:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input.simple-input::placeholder, textarea.free-text::placeholder { color: #94a3b8; }
textarea.free-text { resize: none; min-height: 80px; line-height: 1.5; }

/* Shake en error */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

input.shake, textarea.shake { animation: shake .4s ease; border-color: var(--red) !important; }

.send-btn {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border: none;
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform .18s, box-shadow .18s;
  flex-shrink: 0;
  align-self: flex-end;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.send-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45); }

/* ── Summary card mejorada ────────────────────────────────────── */
.summary-intro {
  margin-bottom: 12px;
  font-size: 14px;
  color: #334155;
}

.summary-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  margin-top: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.summary-header h4 {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: #1e293b;
  font-weight: 600;
}

.summary-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.summary-rows { padding: 0 20px; }

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}

.summary-row:last-child { border-bottom: none; }

.summary-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  flex-shrink: 0;
}

.summary-value {
  font-size: 13px;
  color: #1e293b;
  font-weight: 600;
  text-align: right;
  max-width: 55%;
  line-height: 1.4;
}

.price-highlight {
  margin: 0;
  padding: 18px 20px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #bfdbfe;
}

.p-label { font-size: 13px; color: #3b5e9c; font-weight: 600; }
.p-sub   { font-size: 11px; color: #60a5fa; margin-top: 2px; }

.p-price {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.p-currency { font-size: 14px; color: var(--accent2); }

.summary-footer {
  margin-top: 10px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
}

.summary-footer a { color: var(--accent); text-decoration: none; }
.summary-footer a:hover { text-decoration: underline; }

/* Botones de acción finales */
.summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  border: none;
}

.action-btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.action-btn.primary:hover { background: #2563eb; transform: translateY(-1px); }

.action-btn.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.action-btn.secondary:hover { background: #e2e8f0; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #ffffff;
  border: 1px solid var(--green);
  color: #334155;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn .3s ease;
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  font-weight: 500;
  max-width: 320px;
}

.toast.error { border-color: var(--red); }

@keyframes slideIn {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { padding: 16px; }

  .chat-panel { flex-direction: column; }

  .chat-side-card {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    min-height: auto;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .chat-side-card-inner {
    flex-direction: row;
    padding: 0;
    gap: 16px;
    width: 100%;
  }

  .bot-image-container { width: 72px; height: 72px; }
  .chat-side-img { width: 72px; height: 72px; }

  .chat-side-name { font-size: 22px; }

  .chat-container {
    border-radius: 0 0 var(--radius) var(--radius);
    min-width: auto;
  }
}

@media (max-width: 620px) {
  body { padding: 0; }

  .chat-wrapper { max-width: 100%; }

  .header {
    padding: 12px 16px 0;
    flex-direction: row;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
  }

  .header-left { display: none; }

  .header-center-logo { height: 44px; }

  .header-back-btn { padding: 8px 16px; font-size: 13px; }

  .chat-panel { min-height: 100dvh; }

  .chat-side-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    padding: 12px 16px;
  }

  .bot-image-container { width: 52px; height: 52px; }
  .chat-side-img { width: 52px; height: 52px; }

  .chat-side-name { font-size: 18px; }

  .online-status { padding: 5px 12px; }
  .status-text { font-size: 12px; }

  .chat-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    flex: 1;
  }

  .messages { padding: 16px; }

  .msg-bubble {
    max-width: 88%;
    font-size: 13px;
    padding: 12px 14px;
  }

  .options-area { padding: 12px 16px 16px; }

  .options-grid { grid-template-columns: 1fr 1fr; gap: 6px; }

  .option-btn { font-size: 13px; padding: 10px 12px; }
  .option-btn .opt-icon { font-size: 16px; }

  .p-price { font-size: 20px; }

  .summary-actions { flex-direction: column; }
  .action-btn { width: 100%; justify-content: center; }

  .toast { bottom: 16px; right: 16px; left: 16px; max-width: none; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  body { background: #fff; padding: 0; display: block; }
  .chat-wrapper, .chat-panel { max-width: 100%; display: block; }
  .chat-side-card, .chat-topbar, .options-area, .header, .summary-actions { display: none; }
  .chat-container { box-shadow: none; border: none; }
  .messages { overflow: visible; }
  .msg.user { display: none; }
  .summary-card { break-inside: avoid; }
}