/* ============================================================
   JP SHEET — AI Chatbot Styles (Phase 3)
   /assets/css/chatbot.css
   FIXES:
   - Mobile FAB smaller (was too big)
   - Mobile panel fully responsive (full screen, close button visible)
   - Button text clearly visible on red CTAs
   - Vehicle card / order card better visible on mobile
   - Status messages during async lookups
   ============================================================ */

/* ===== Floating Button ===== */
.jpc-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #BB1823 0%, #8E121B 100%);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(187, 24, 35, 0.32), 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.jpc-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 28px rgba(187, 24, 35, 0.4), 0 3px 10px rgba(0, 0, 0, 0.13);
}
.jpc-fab:active { transform: scale(0.95); }
.jpc-fab svg {
  width: 24px;
  height: 24px;
  color: #fff;
  stroke-width: 2.2;
}

/* MOBILE: Smaller FAB */
@media (max-width: 480px) {
  .jpc-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    box-shadow: 0 4px 14px rgba(187, 24, 35, 0.32);
  }
  .jpc-fab svg { width: 20px; height: 20px; }
}

/* Pulse animation for first-time visitors */
.jpc-fab--pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #BB1823;
  animation: jpc-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes jpc-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

.jpc-fab__dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 11px;
  height: 11px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid #BB1823;
  animation: jpc-dot-pulse 1.8s ease-in-out infinite;
}
@keyframes jpc-dot-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

.jpc-fab--hidden { display: none !important; }

/* ===== Chat Panel ===== */
.jpc-panel {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 380px;
  max-width: calc(100vw - 28px);
  height: 600px;
  max-height: calc(100vh - 44px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.jpc-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* MOBILE: Full screen panel */
@media (max-width: 540px) {
  .jpc-panel {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    border-radius: 0 !important;
    transform: translateY(100%) !important;
  }
  .jpc-panel--open {
    transform: translateY(0) !important;
  }
}

/* ===== Header ===== */
.jpc-header {
  background: linear-gradient(135deg, #BB1823 0%, #8E121B 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 540px) {
  .jpc-header {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

.jpc-header__avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.jpc-header__avatar svg {
  width: 18px;
  height: 18px;
  color: #fff;
}
.jpc-header__info { flex: 1; min-width: 0; }
.jpc-header__title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
}
.jpc-header__status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.jpc-header__status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

.jpc-header__actions { display: flex; gap: 6px; flex-shrink: 0; }
.jpc-header__btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  flex-shrink: 0;
}
.jpc-header__btn:hover { background: rgba(255, 255, 255, 0.3); }
.jpc-header__btn:active { background: rgba(255, 255, 255, 0.4); }
.jpc-header__btn svg { width: 14px; height: 14px; pointer-events: none; }

@media (max-width: 540px) {
  .jpc-header__btn {
    width: 36px;
    height: 36px;
  }
  .jpc-header__btn svg { width: 16px; height: 16px; }
}

/* ===== Messages Area ===== */
.jpc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #FAFAF9;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 540px) {
  .jpc-messages { padding: 12px; }
}

.jpc-msg {
  max-width: 85%;
  font-size: 13.5px;
  line-height: 1.5;
  animation: jpc-msg-in 0.25s ease-out;
}
@keyframes jpc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.jpc-msg--user {
  align-self: flex-end;
  background: #BB1823;
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  word-wrap: break-word;
}
.jpc-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: #1F2937;
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid #E5E7EB;
  word-wrap: break-word;
  max-width: 90%;
}
.jpc-msg--bot p { margin: 0 0 8px; }
.jpc-msg--bot p:last-child { margin-bottom: 0; }
.jpc-msg--bot strong { font-weight: 700; color: #111; }
.jpc-msg--bot em { font-style: italic; }
.jpc-msg--bot ul, .jpc-msg--bot ol { margin: 6px 0 6px 18px; padding: 0; }
.jpc-msg--bot li { margin-bottom: 3px; }
.jpc-msg--bot a { color: #BB1823; font-weight: 600; text-decoration: underline; }
.jpc-msg--bot code { background: #F3F4F6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ===== Welcome Block ===== */
.jpc-welcome {
  text-align: center;
  padding: 12px 6px 6px;
}
.jpc-welcome__title {
  font-size: 14px;
  font-weight: 800;
  color: #111;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.jpc-welcome__text {
  font-size: 12px;
  color: #6B7280;
  line-height: 1.55;
  margin: 0 0 16px;
}

/* ===== Suggested Chips ===== */
.jpc-suggested {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
  animation: jpc-msg-in 0.3s ease-out 0.1s backwards;
}
.jpc-chip {
  background: #fff;
  border: 1px solid #E5E7EB;
  color: #374151;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
.jpc-chip:hover {
  background: #FFF1F2;
  border-color: #BB1823;
  color: #BB1823;
}
.jpc-chip__icon {
  display: inline-block;
  margin-right: 6px;
  color: #BB1823;
  font-size: 14px;
}

/* ===== CTA Buttons in Bot Messages ===== */
.jpc-cta-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.jpc-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none !important;
  transition: all 0.15s;
  font-family: inherit;
  border: none;
  cursor: pointer;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.jpc-cta--primary {
  background: #BB1823;
  color: #ffffff !important;
}
.jpc-cta--primary:hover { background: #8E121B; color: #ffffff !important; }
.jpc-cta--whatsapp {
  background: #16A34A;
  color: #ffffff !important;
}
.jpc-cta--whatsapp:hover { background: #15803D; color: #ffffff !important; }
.jpc-cta--secondary {
  background: #fff;
  color: #BB1823 !important;
  border: 1.5px solid #BB1823;
}
.jpc-cta--secondary:hover { background: #FEF2F2; color: #BB1823 !important; }
.jpc-cta--secondary:disabled { opacity: 0.6; cursor: not-allowed; }
.jpc-cta svg { width: 13px; height: 13px; flex-shrink: 0; }
.jpc-cta:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Vehicle Card ===== */
.jpc-vc {
  margin-top: 10px;
  padding: 12px;
  background: linear-gradient(135deg, #FEF2F2 0%, #FFF7F8 100%);
  border: 1.5px solid #FECACA;
  border-radius: 10px;
}
.jpc-vc__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.jpc-vc__icon {
  font-size: 22px;
  flex-shrink: 0;
}
.jpc-vc__main { flex: 1; min-width: 0; }
.jpc-vc__title {
  font-size: 13.5px;
  font-weight: 800;
  color: #111;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.jpc-vc__chassis {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: #BB1823;
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: -0.02em;
}
.jpc-vc__details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed #FECACA;
}
.jpc-vc__detail {
  font-size: 11px;
  color: #6B7280;
  background: #fff;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #FECACA;
}
.jpc-vc__detail b {
  color: #111;
  font-weight: 700;
  margin-right: 3px;
}

/* ===== Order Card ===== */
.jpc-oc {
  margin-top: 10px;
  background: #fff;
  border: 1.5px solid #BB1823;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(187, 24, 35, 0.06);
}
.jpc-oc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #FFF1F2;
  border-bottom: 1px solid #FECACA;
  gap: 10px;
}
.jpc-oc__badge {
  font-size: 10.5px;
  font-weight: 800;
  color: #BB1823;
  letter-spacing: -0.01em;
}
.jpc-oc__ref {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #6B7280;
  letter-spacing: -0.02em;
}
.jpc-oc__rows {
  padding: 8px 12px 10px;
}
.jpc-oc__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed #F3F4F6;
  gap: 10px;
}
.jpc-oc__row:last-child { border-bottom: none; }
.jpc-oc__row span {
  color: #6B7280;
  font-weight: 500;
  flex-shrink: 0;
}
.jpc-oc__row b {
  color: #111;
  font-weight: 700;
  text-align: right;
  word-break: break-word;
}

/* Refunded / Manual Not Found variant */
.jpc-oc--refund {
  border-color: #F59E0B;
}
.jpc-oc--refund .jpc-oc__head {
  background: #FFFBEB;
  border-bottom-color: #FDE68A;
}
.jpc-oc--refund .jpc-oc__badge {
  color: #B45309;
}

/* Pending / In Progress variant */
.jpc-oc--pending {
  border-color: #3B82F6;
}
.jpc-oc--pending .jpc-oc__head {
  background: #EFF6FF;
  border-bottom-color: #BFDBFE;
}
.jpc-oc--pending .jpc-oc__badge {
  color: #1E40AF;
}

/* ===== Typing Indicator ===== */
.jpc-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #E5E7EB;
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.jpc-typing span {
  width: 7px;
  height: 7px;
  background: #BB1823;
  border-radius: 50%;
  animation: jpc-bounce 1.2s infinite ease-in-out;
}
.jpc-typing span:nth-child(2) { animation-delay: 0.15s; }
.jpc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes jpc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== Status Pill (lookup in progress) ===== */
.jpc-status {
  align-self: flex-start;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  padding: 8px 14px;
  border-radius: 16px 16px 16px 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #1E40AF;
  font-weight: 600;
  animation: jpc-msg-in 0.2s ease-out;
}
.jpc-status__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #BFDBFE;
  border-top-color: #1E40AF;
  border-radius: 50%;
  animation: jpc-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes jpc-spin {
  to { transform: rotate(360deg); }
}

/* ===== Input Area ===== */
.jpc-input-area {
  border-top: 1px solid #E5E7EB;
  background: #fff;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.jpc-input {
  flex: 1;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  min-height: 38px;
  line-height: 1.4;
  color: #111;
  outline: none;
  transition: border-color 0.15s;
}
.jpc-input:focus { border-color: #BB1823; }
.jpc-input::placeholder { color: #9CA3AF; }
.jpc-input:disabled { background: #F9FAFB; cursor: not-allowed; }

.jpc-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #BB1823;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.jpc-send:hover:not(:disabled) { background: #8E121B; }
.jpc-send:disabled { background: #D1D5DB; cursor: not-allowed; }
.jpc-send svg { width: 16px; height: 16px; pointer-events: none; }

/* ===== Footer ===== */
.jpc-foot {
  padding: 6px 12px 8px;
  font-size: 10px;
  color: #9CA3AF;
  text-align: center;
  background: #fff;
  border-top: 1px solid #F3F4F6;
}
.jpc-foot a { color: #BB1823; font-weight: 600; text-decoration: none; }

@media (max-width: 540px) {
  .jpc-foot {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .jpc-input-area + .jpc-foot {
    padding-bottom: 8px;
  }
}

/* ===== Error Message ===== */
.jpc-error {
  align-self: center;
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  max-width: 90%;
}

/* ===== Feedback Buttons ===== */
.jpc-feedback {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #E5E7EB;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #6B7280;
}
.jpc-feedback__label {
  font-weight: 500;
  margin-right: 4px;
}
.jpc-feedback__btn {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.jpc-feedback__btn:hover {
  border-color: #BB1823;
  background: #FFF1F2;
  transform: scale(1.08);
}
.jpc-feedback--rated {
  color: #16A34A;
  font-weight: 600;
  border-top-color: transparent;
  font-style: italic;
}

/* Hide on print */
@media print {
  .jpc-fab, .jpc-panel { display: none !important; }
}
