/* ============================================================
   PAUL CHAT-WIDGET — Oasis KI Website
   Self-contained: kein Konflikt mit bestehendem Site-CSS dank
   .paul-* Namespace.

   FARB-SYSTEM:
   - Primary: Dunkelblau #0A1628 / #050E1C (Oasis-Hauptfarbe)
   - Accent:  Orange #FF5C1A (minimal, nur für Highlights)
   - Online-Dot: Grün #3FD97F
   ============================================================ */

.paul-bubble {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F1F38 0%, #050E1C 100%);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(5, 14, 28, 0.45),
              0 4px 12px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483646;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
}

.paul-bubble:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 36px rgba(5, 14, 28, 0.55);
}

.paul-bubble.paul-hidden { display: none; }

.paul-bubble-avatar {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Cabinet Grotesk', 'Instrument Sans', sans-serif;
  letter-spacing: -0.02em;
}

/* Online-Dot mit dezentem Orange-Akzent-Ring */
.paul-bubble-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3FD97F;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
  animation: paul-pulse 2s ease-in-out infinite;
}

@keyframes paul-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 217, 127, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(63, 217, 127, 0); }
}

/* ============================================================
   PEEK-MESSAGE (Auto-Popup nach 10s)
   ============================================================ */
.paul-peek {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  max-width: 280px;
  padding: 14px 16px 14px 16px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18),
              0 2px 8px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.08);
  z-index: 2147483645;
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1A1F2E;
  cursor: pointer;
  animation: paul-peek-in 0.4s cubic-bezier(.4, 0, .2, 1);
}

.paul-peek::before {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 32px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  transform: rotate(45deg);
}

.paul-peek-name {
  font-weight: 700;
  color: #0A1628;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.paul-peek-name::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #3FD97F;
  border-radius: 50%;
  display: inline-block;
}

.paul-peek-text {
  color: #475569;
}

.paul-peek-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #94A3B8;
  font-size: 1rem;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.paul-peek-close:hover {
  background: #F1F5F9;
  color: #1A1F2E;
}

.paul-peek.paul-hidden { display: none; }

@keyframes paul-peek-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   CHAT-PANEL
   ============================================================ */
.paul-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(5, 14, 28, 0.28),
              0 8px 20px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.08);
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  animation: paul-panel-in 0.3s cubic-bezier(.4, 0, .2, 1);
  isolation: isolate;
}

.paul-panel.paul-hidden { display: none; }

@keyframes paul-panel-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel-Header in Dunkelblau */
.paul-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0F1F38 0%, #050E1C 100%);
  color: #fff;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.paul-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.125rem;
  flex-shrink: 0;
  position: relative;
  color: #fff;
}

.paul-header-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: #3FD97F;
  border: 2px solid #050E1C;
  border-radius: 50%;
}

.paul-header-info {
  flex: 1;
  min-width: 0;
}

.paul-header-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

.paul-header-status {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 2px;
}

.paul-header-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.paul-header-close:hover { background: rgba(255, 255, 255, 0.2); }

/* Messages */
.paul-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F7F8FA;
  scroll-behavior: smooth;
}

.paul-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  gap: 4px;
}

.paul-msg-bot { align-self: flex-start; }
.paul-msg-user { align-self: flex-end; }

.paul-bubble-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Bot-Nachrichten: weiß mit dezenter Border */
.paul-msg-bot .paul-bubble-msg {
  background: #fff;
  color: #1A1F2E;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* User-Nachrichten: Dunkelblau */
.paul-msg-user .paul-bubble-msg {
  background: linear-gradient(135deg, #0F1F38 0%, #050E1C 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.paul-msg-time {
  font-size: 0.65rem;
  color: #94A3B8;
  padding: 0 6px;
}

.paul-msg-user .paul-msg-time { text-align: right; }

/* Action-Cards (CTA-Buttons in Chat) */
.paul-action-card {
  align-self: flex-start;
  max-width: 85%;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paul-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border: 1.5px solid #0A1628;
  border-radius: 10px;
  color: #0A1628;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

/* Primary-Action: Dunkelblau gefüllt mit dezentem Orange-Akzent-Border */
.paul-action-btn.paul-action-primary {
  background: linear-gradient(135deg, #0F1F38 0%, #050E1C 100%);
  color: #fff;
  border-color: #050E1C;
  box-shadow: 0 1px 0 rgba(255, 92, 26, 0.25) inset;
}

.paul-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 14, 28, 0.2);
  border-color: #FF5C1A;
}

.paul-action-btn.paul-action-primary:hover {
  border-color: #FF5C1A;
  box-shadow: 0 4px 12px rgba(5, 14, 28, 0.35),
              0 0 0 1px #FF5C1A;
}

/* Typing indicator */
.paul-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  display: flex;
  gap: 4px;
}

.paul-typing span {
  width: 6px;
  height: 6px;
  background: #0A1628;
  border-radius: 50%;
  animation: paul-bounce 1.2s ease-in-out infinite;
}

.paul-typing span:nth-child(2) { animation-delay: 0.15s; }
.paul-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes paul-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick-Actions (initial vor erstem Chat) */
.paul-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #F7F8FA;
}

.paul-quick-btn {
  padding: 7px 12px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  color: #1A1F2E;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.paul-quick-btn:hover {
  border-color: #0A1628;
  color: #0A1628;
  background: #F1F5F9;
}

.paul-quick-actions.paul-hidden { display: none; }

/* Input */
.paul-input-wrap {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.paul-input {
  flex: 1 1 auto;
  min-width: 0;   /* CRITICAL flex-Bug: ohne min-width:0 kann textarea-Inhalt überlaufen */
  width: 100%;
  resize: none;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 14px;
  padding: 9px 12px;
  font-family: inherit;
  /* iOS Safari Auto-Zoom Prevention: 16px MINIMUM */
  font-size: 16px !important;
  line-height: 1.35;
  color: #1A1F2E;
  background: #F7F8FA;
  outline: none;
  max-height: 100px;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.paul-input-wrap {
  /* Sicherheit: width 100%, box-sizing border-box, gegen Overflow */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.paul-send {
  flex: 0 0 38px;  /* Send-Button NIE schrumpfen, NIE wachsen */
}

.paul-input:focus {
  border-color: #0A1628;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(10, 22, 40, 0.08);
}

/* Send-Button: Dunkelblau mit Orange-Akzent-Indicator */
.paul-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0F1F38 0%, #050E1C 100%);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.paul-send::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FF5C1A;
  box-shadow: 0 0 4px rgba(255, 92, 26, 0.6);
}

.paul-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(5, 14, 28, 0.35);
}

.paul-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.paul-send:disabled::after { display: none; }

.paul-footer {
  text-align: center;
  font-size: 0.7rem;
  color: #94A3B8;
  padding: 6px 0 10px;
  background: #fff;
}

.paul-footer strong {
  color: #FF5C1A;
  font-weight: 600;
}

/* Mobile — Bottom-Sheet (oben 30% Website sichtbar) */
@media (max-width: 720px) {
  .paul-bubble {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 56px;
    height: 56px;
  }
  .paul-peek {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    max-width: calc(100vw - 32px);
  }

  /* Panel als Bottom-Sheet:
     - top: 30dvh → oben 30% der Website bleibt sichtbar
     - left:0 / right:0 (NICHT width:100vw — sonst overflow rechts auf iOS Safari)
     - bottom:0 + height:auto → füllt unteren Bereich
     - obere Ecken abgerundet (Bottom-Sheet-Optik)
  */
  .paul-panel {
    position: fixed !important;
    top: 30vh !important;
    top: 30dvh !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 70vh !important;
    max-height: 70dvh !important;
    border-radius: 18px 18px 0 0 !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
    border-bottom: none !important;
    box-shadow: 0 -10px 30px rgba(5, 14, 28, 0.18) !important;
  }

  /* Header oben — keine Safe-Area-Top mehr nötig (Panel ist unten) */
  .paul-header {
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    padding-left: 18px !important;
    padding-right: 12px !important;
  }

  /* Input unten — Safe-Area-Padding für iOS-Home-Indicator */
  .paul-input-wrap {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

/* Body-Scroll-Lock NICHT mehr aktiv — User soll oben weiter scrollen/klicken können */
body.paul-chat-open {
  /* keine Sperre — Bottom-Sheet erlaubt obere Interaktion */
}
