/* ── Jardinería IA — Frontend Chat ────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --jai-green:      #2d6a4f;
  --jai-green-mid:  #40916c;
  --jai-green-lt:   #74c69d;
  --jai-cream:      #f8f5f0;
  --jai-warm:       #e9ecef;
  --jai-text:       #1b1b1b;
  --jai-muted:      #6b7280;
  --jai-radius:     18px;
  --jai-shadow:     0 8px 32px rgba(45,106,79,.15);
}

#jai-chat-widget {
  font-family: 'DM Sans', sans-serif;
  max-width: 680px;
  margin: 0 auto 40px;
  border-radius: var(--jai-radius);
  box-shadow: var(--jai-shadow);
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────── */
.jai-header {
  background: linear-gradient(135deg, var(--jai-green) 0%, var(--jai-green-mid) 100%);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
}
.jai-header-icon {
  font-size: 2rem;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.jai-header-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: .3px;
}
.jai-header-status {
  font-size: .8rem;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.jai-dot {
  width: 8px; height: 8px;
  background: #74c69d;
  border-radius: 50%;
  animation: jai-pulse 2s ease-in-out infinite;
}
@keyframes jai-pulse {
  0%,100% { opacity:1 }
  50%      { opacity:.4 }
}

/* ── Messages ────────────────────────────── */
.jai-messages {
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 260px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--jai-cream);
  scroll-behavior: smooth;
}
.jai-messages::-webkit-scrollbar { width: 4px }
.jai-messages::-webkit-scrollbar-track { background: transparent }
.jai-messages::-webkit-scrollbar-thumb { background: #cde; border-radius: 2px }

.jai-msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: jai-slide-in .25s ease;
}
@keyframes jai-slide-in {
  from { opacity:0; transform:translateY(8px) }
  to   { opacity:1; transform:translateY(0) }
}
.jai-msg-user {
  flex-direction: row-reverse;
}
.jai-msg-avatar {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #d4edda;
  display: grid; place-items: center;
}
.jai-msg-bubble {
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 12px 16px;
  font-size: .93rem;
  line-height: 1.6;
  color: var(--jai-text);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  max-width: 80%;
}
.jai-msg-user .jai-msg-bubble {
  background: var(--jai-green);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.jai-msg-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.jai-msg-image-grid img {
  width: 90px; height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.4);
}

/* Typing indicator */
.jai-typing .jai-msg-bubble {
  padding: 14px 18px;
}
.jai-typing-dots {
  display: flex; gap: 5px; align-items: center;
}
.jai-typing-dots span {
  width: 7px; height: 7px;
  background: var(--jai-green-mid);
  border-radius: 50%;
  animation: jai-bounce .9s ease-in-out infinite;
}
.jai-typing-dots span:nth-child(2) { animation-delay: .15s }
.jai-typing-dots span:nth-child(3) { animation-delay: .30s }
@keyframes jai-bounce {
  0%,100% { transform: translateY(0) }
  50%      { transform: translateY(-5px) }
}

/* ── Preview zone ────────────────────────── */
.jai-preview-zone {
  background: #f0faf4;
  border-top: 1px solid #d4edda;
  padding: 10px 16px;
  font-size: .85rem;
}
.jai-preview-title {
  color: var(--jai-green);
  font-weight: 600;
  margin-bottom: 8px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.jai-preview-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.jai-preview-item {
  position: relative;
}
.jai-preview-item img {
  width: 70px; height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #74c69d;
}
.jai-preview-remove {
  position: absolute;
  top: -5px; right: -5px;
  background: #e63946;
  color: #fff;
  border: none; cursor: pointer;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px;
  display: grid; place-items: center;
  line-height: 1;
}

/* ── Quote panel ─────────────────────────── */
.jai-quote-panel {
  border-top: 3px solid var(--jai-green);
  background: #f8fffe;
  padding: 18px 20px 14px;
}
.jai-quote-header {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--jai-green);
  margin-bottom: 12px;
  font-weight: 400;
}
.jai-quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.jai-quote-table th {
  background: var(--jai-green);
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
  font-size: .8rem;
}
.jai-quote-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #e0f0e9;
  color: var(--jai-text);
}
.jai-quote-table tr:nth-child(even) td { background: #edf7f1 }
.jai-quote-total {
  text-align: right;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--jai-green);
  margin-top: 10px;
  padding: 8px 10px;
  background: #d8f3dc;
  border-radius: 8px;
}
.jai-quote-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* ── Client form ─────────────────────────── */
.jai-client-form {
  background: #fffbf0;
  border-top: 1px solid #f0e6c8;
  padding: 14px 18px;
  font-size: .88rem;
}
.jai-client-title {
  color: #7c5c00;
  margin-bottom: 10px;
  font-weight: 500;
}
.jai-client-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.jai-client-fields input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: .88rem;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color .2s;
}
.jai-client-fields input:focus { border-color: var(--jai-green-mid) }
.jai-client-ok { color: var(--jai-green); font-weight: 600; margin-top: 8px }

/* ── Input area ──────────────────────────── */
.jai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px 12px;
}
.jai-upload-btn {
  cursor: pointer;
  font-size: 1.35rem;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--jai-green-mid);
  transition: background .15s;
  flex-shrink: 0;
  line-height: 1;
  display: grid; place-items: center;
}
.jai-upload-btn:hover { background: #e8f5e9 }
#jai-text-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: .93rem;
  font-family: 'DM Sans', sans-serif;
  padding: 8px 10px;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  color: var(--jai-text);
}
.jai-send-btn {
  background: var(--jai-green);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: grid; place-items: center;
  transition: background .2s, transform .1s;
}
.jai-send-btn:hover  { background: var(--jai-green-mid) }
.jai-send-btn:active { transform: scale(.95) }
.jai-send-btn svg { width: 20px; height: 20px }
.jai-send-btn:disabled { opacity: .5; cursor: not-allowed }

/* ── Shared buttons ──────────────────────── */
.jai-btn-primary, .jai-btn-secondary {
  border: none;
  cursor: pointer;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 18px;
  transition: all .2s;
}
.jai-btn-primary   { background: var(--jai-green); color: #fff }
.jai-btn-primary:hover { background: var(--jai-green-mid) }
.jai-btn-secondary { background: #e8f5e9; color: var(--jai-green) }
.jai-btn-secondary:hover { background: #d4edda }

/* ── Payment Panel ──────────────────────── */
.jai-payment-panel {
  border-top: 3px solid #2d6a4f;
  background: #f8fffe;
  padding: 16px 18px;
}
.jai-payment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  color: #2d6a4f;
  font-size: .9rem;
}
.jai-stripe-badge-sm {
  font-size: .7rem;
  color: #666;
  font-weight: 400;
}
.jai-payment-summary {
  background: #e8f5e9;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: .9rem;
  color: #1b4332;
}
.jai-pay-amount {
  font-weight: 700;
  color: #2d6a4f;
  font-size: 1.1rem;
}

/* Stripe Payment Element */
#jai-payment-element {
  margin: 12px 0;
}
.jai-payment-error {
  background: #fce4ec;
  color: #c2185b;
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 4px solid #c2185b;
  margin: 10px 0;
  font-size: .85rem;
}
.jai-btn-pay-confirm {
  width: 100%;
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.jai-btn-pay-confirm:hover:not(:disabled) { 
  background: linear-gradient(135deg, #1b4332, #2d6a4f);
  box-shadow: 0 4px 16px rgba(45,106,79,.3);
}
.jai-btn-pay-confirm:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.jai-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: jai-spin .8s linear infinite;
}
@keyframes jai-spin {
  to { transform: rotate(360deg) }
}
.jai-payment-secure {
  text-align: center;
  font-size: .75rem;
  color: #666;
  margin-top: 10px;
}

/* Payment Success */
.jai-payment-success {
  background: #e8f5e9;
  border: 2px solid #74c69d;
  border-radius: 14px;
  padding: 28px;
  text-align: center;
}
.jai-success-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  animation: jai-bounce-success .6s ease;
}
@keyframes jai-bounce-success {
  0%   { transform: scale(0) }
  50%  { transform: scale(1.2) }
  100% { transform: scale(1) }
}
.jai-success-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: #2d6a4f;
  margin-bottom: 10px;
  font-weight: 400;
}
.jai-success-msg {
  color: #1b4332;
  font-size: .9rem;
  line-height: 1.6;
}

/* Stripe Badge */
.jai-stripe-card {
  background: linear-gradient(135deg, rgba(45,106,79,.03), rgba(116,198,157,.05));
  border: 1.5px solid #d4edda;
  position: relative;
}
.jai-stripe-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .5px;
  margin-bottom: 14px;
}
.jai-badge-test {
  background: #fff3cd;
  color: #856404;
}
.jai-badge-live {
  background: #d4edda;
  color: #155724;
}

/* Admin stats */
.jai-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.jai-stat {
  background: #fff;
  border: 1.5px solid #e0f0e9;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(45,106,79,.06);
}
.jai-stat-val {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.jai-stat-green .jai-stat-val { color: #2d6a4f }
.jai-stat-blue .jai-stat-val  { color: #1976d2 }
.jai-stat-yellow .jai-stat-val { color: #f57c00 }
.jai-stat-label {
  font-size: .8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.jai-checklist { list-style: none; padding: 0 }
.jai-checklist li {
  padding: 10px 0;
  border-bottom: 1px solid #e0f0e9;
  font-size: .9rem;
}
.jai-checklist li:last-child { border-bottom: none }
.jai-pi-link {
  color: #2d6a4f;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dotted #2d6a4f;
}
.jai-pi-link:hover { color: #1b4332 }

.jai-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
}
.jai-status-paid  { background: #d4edda; color: #155724 }
.jai-status-init  { background: #fff3cd; color: #856404 }
.jai-status-fail  { background: #f8d7da; color: #721c24 }
.jai-status-pend  { background: #e2e3e5; color: #383d41 }

/* ── Responsive ──────────────────────────── */
@media (max-width: 520px) {
  .jai-messages { max-height: 320px }
  .jai-msg-bubble { max-width: 90% }
  .jai-client-fields { flex-direction: column }
  .jai-quote-table { font-size: .78rem }
  .jai-stat-row { grid-template-columns: 1fr }
}
