/**
 * Insurance Chatbot Design System & Stylesheet
 * Sleek, ultra-modern glassmorphism UI with responsive mobile drawer support.
 */

:root {
  --ins-primary: #18221c;
  --ins-primary-gradient: linear-gradient(135deg, #18221c 0%, #26352c 100%);
  --ins-primary-hover: #26352c;
  --ins-accent: #9be553;
  --ins-bg: #ffffff;
  --ins-surface: #f8fafc;
  --ins-header-bg: #18221c;
  --ins-header-text: #ffffff;
  --ins-bot-bubble: #f1f5f9;
  --ins-bot-text: #0f172a;
  --ins-user-bubble: #18221c;
  --ins-user-text: #ffffff;
  --ins-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ins-radius: 18px;
  --ins-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Floating Launcher Button */
.ins-chatbot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ins-primary-gradient);
  box-shadow: 0 10px 25px -5px rgba(24, 34, 28, 0.45), 0 0 0 2px rgba(155, 229, 83, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999999;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  outline: none;
}

.ins-chatbot-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 15px 30px -5px rgba(24, 34, 28, 0.55), 0 0 0 3px rgba(155, 229, 83, 0.5);
}

.ins-launcher-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.3s ease;
}

.ins-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #9be553;
  color: #18221c;
  font-size: 11px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #18221c;
  animation: ins-pulse 2s infinite;
}

/* Launcher Teaser Tooltip */
.ins-launcher-teaser {
  position: absolute;
  right: 76px;
  background: #ffffff;
  color: #0f172a;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  font-family: var(--ins-font);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s ease;
  border: 1px solid #e2e8f0;
}

.ins-chatbot-launcher:hover .ins-launcher-teaser {
  opacity: 1;
  transform: translateX(0);
}

/* Chatbot Container Window */
.ins-chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 420px;
  height: 650px;
  max-height: calc(100vh - 120px);
  background: var(--ins-bg);
  border-radius: var(--ins-radius);
  box-shadow: var(--ins-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  font-family: var(--ins-font);
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.ins-chatbot-container.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Chat Header */
.ins-header {
  background: var(--ins-header-bg);
  color: var(--ins-header-text);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.ins-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ins-avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  overflow: visible;
}

.ins-avatar-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 14px;
}

.ins-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.ins-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid var(--ins-header-bg);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

.ins-profile-info .ins-bot-name {
  font-size: 15px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.ins-profile-info .ins-bot-role {
  font-size: 11px;
  color: #94a3b8;
  display: block;
}

.ins-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ins-btn-icon {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.ins-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Messages Area */
.ins-messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--ins-bg, #f8fafc);
  scroll-behavior: smooth;
}

/* Message Rows */
.ins-msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: ins-fade-slide 0.3s ease forwards;
}

.ins-msg-row.bot {
  align-self: flex-start;
}

.ins-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ins-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

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

.ins-msg-row.user .ins-msg-bubble {
  background: var(--ins-user-bubble);
  color: var(--ins-user-text);
  border-top-right-radius: 4px;
}

.ins-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  display: block;
}

.ins-msg-row.user .ins-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.ins-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
  background: #ffffff;
  border-radius: 16px;
  border-top-left-radius: 4px;
  border: 1px solid #e2e8f0;
  width: fit-content;
}

.ins-typing-dot {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: ins-bounce 1.4s infinite ease-in-out both;
}

.ins-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ins-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Quick Reply Chips */
.ins-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px 0;
}

.ins-chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ins-chip-btn:hover {
  background: var(--ins-primary);
  color: #ffffff;
  border-color: var(--ins-primary);
  transform: translateY(-1px);
}

/* Quote Cards & Tiers */
.ins-quote-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin-top: 8px;
}

.ins-quote-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.ins-quote-id {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.ins-quote-badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.ins-quote-price-box {
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  margin: 12px 0;
  border: 1px solid #e2e8f0;
}

.ins-quote-price-annual {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
}

.ins-quote-price-monthly {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.ins-quote-details {
  font-size: 12.5px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.ins-detail-line {
  display: flex;
  justify-content: space-between;
}

.ins-btn-primary {
  width: 100%;
  background: var(--ins-primary-gradient);
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.ins-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

/* In-Chat Payment Card */
.inchat-checkout-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 20px -5px rgba(0, 0, 0, 0.1);
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}

.checkout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.checkout-title {
  font-size: 13px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pci-badge {
  background: #ecfdf5;
  color: #059669;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid #a7f3d0;
}

.checkout-summary-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.plan-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: block;
}

.plan-sub {
  font-size: 11px;
  color: #64748b;
  display: block;
}

.plan-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--ins-primary);
}

.payment-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.input-field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  box-sizing: border-box;
}

.input-field:focus {
  outline: none;
  border-color: var(--ins-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.card-input-wrapper {
  position: relative;
}

.card-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-group.half {
  flex: 1;
}

.wallet-pay-box {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: #6b21a8;
}

.btn-wallet-express {
  width: 100%;
  background: #000000;
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin: 10px 0;
  transition: opacity 0.2s;
}

.btn-wallet-express:hover {
  opacity: 0.88;
}

.wallet-sub {
  font-size: 10px;
  color: #7e22ce;
}

.promo-code-section {
  margin: 12px 0;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.promo-input-row {
  display: flex;
  gap: 6px;
}

.input-promo {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
  text-transform: uppercase;
}

.btn-apply-promo {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-apply-promo:hover {
  background: #e2e8f0;
}

.promo-message {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 600;
}

.btn-submit-payment {
  width: 100%;
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.btn-submit-payment:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* Processing Overlay */
.payment-processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  text-align: center;
  padding: 20px;
}

.processing-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--ins-primary);
  border-radius: 50%;
  animation: ins-spin 1s infinite linear;
  margin-bottom: 14px;
}

.processing-step {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.processing-sub {
  font-size: 11px;
  color: #64748b;
}

/* Digital Policy Receipt */
.insurance-receipt-card {
  background: #ffffff;
  border: 2px solid #10b981;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.15);
  margin-top: 8px;
}

.receipt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.receipt-status-badge {
  background: #ecfdf5;
  color: #059669;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.receipt-status-badge .status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
}

.receipt-policy-no {
  text-align: right;
}

.receipt-policy-no .label {
  display: block;
  font-size: 10px;
  color: #64748b;
}

.receipt-policy-no strong {
  font-size: 13px;
  color: #0f172a;
}

.receipt-body {
  border-top: 1px dashed #e2e8f0;
  border-bottom: 1px dashed #e2e8f0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.receipt-row.total {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  padding-top: 4px;
}

.receipt-amount {
  font-size: 18px;
  color: #10b981;
}

.receipt-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn-receipt-action {
  flex: 1;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Chat Input Footer */
.ins-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.ins-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 4px 6px 4px 16px;
  transition: border-color 0.2s;
}

.ins-input-wrapper:focus-within {
  border-color: var(--ins-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ins-input-text {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: #0f172a;
  outline: none;
}

.ins-btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ins-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
}

.ins-btn-send:hover {
  transform: scale(1.06);
  background: var(--ins-primary-hover);
}

.ins-btn-mic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.ins-btn-mic.recording {
  color: #ef4444;
  animation: ins-pulse 1s infinite;
}

.hidden {
  display: none !important;
}

/* Animations */
@keyframes ins-fade-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ins-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes ins-spin {
  to { transform: rotate(360deg); }
}

@keyframes ins-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Responsive Mobile View */
@media (max-width: 600px) {
  .ins-chatbot-container {
    width: 100vw !important;
    height: 100% !important;
    max-height: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    top: 0 !important;
  }
  .ins-chatbot-launcher {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  .ins-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .ins-messages-body {
    padding: 12px 12px 0 12px;
  }
  .ins-header {
    padding: 12px 16px;
  }
  .ins-input-area input, .ins-input-area textarea {
    font-size: 16px !important; /* prevent iOS zoom */
  }
}

/* Dedicated Print Styles: cleans up page if printed from main window */
@media print {
  body > *:not(.ins-chatbot-container) {
    display: none !important;
  }
  .ins-chatbot-launcher, .ins-header, .ins-footer, .ins-quick-replies, .receipt-actions, .ins-msg-time, .ins-msg-row:not(:has(.insurance-receipt-card)) {
    display: none !important;
  }
  .ins-chatbot-container {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }
  .ins-messages-body {
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
  }
  .insurance-receipt-card {
    border: 2px solid #059669 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin: 20px auto !important;
    max-width: 650px !important;
  }
}
