/* ===============================
   WP Local Chatbot – Final CSS (Contrast Fix)
   =============================== */

/* --- Variables --- */
:root {
  --wplc-radius: 16px;
  --wplc-shadow: 0 12px 40px rgba(0,0,0,0.15);
  --wplc-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --wplc-z-index: 999999;
  
  /* Light Mode Defaults */
  --wplc-light-bg: #ffffff;
  --wplc-light-text: #1f2937;
  
  /* Dark Mode Defaults */
  --wplc-dark-bg: #1f2937;
  --wplc-dark-text: #f3f4f6;
  --wplc-dark-input-bg: #374151;
  --wplc-dark-input-text: #ffffff;
}

/* --- Wrapper & Position --- */
.wplc-chatbot {
  position: fixed;
  bottom: 20px;
  z-index: var(--wplc-z-index);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  pointer-events: none; 
  line-height: 1.5;
}
.wplc-chatbot * { box-sizing: border-box; }
.wplc-pos-right { right: 20px; }
.wplc-pos-left  { left: 20px; }

/* --- Toggle Button (FAB) --- */
.wplc-toggle {
  pointer-events: auto;
  width: 60px; height: 60px;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--wplc-fab-bg, #111827);
  color: var(--wplc-fab-icon, #ffffff);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transition: var(--wplc-transition);
  position: relative;
}
.wplc-toggle:hover { transform: scale(1.05); box-shadow: 0 12px 30px rgba(0,0,0,0.3); }
.wplc-toggle:active { transform: scale(0.95); }
.wplc-toggle i { font-size: 24px; transition: transform 0.3s ease; }

.wplc-toggle[aria-expanded="true"] i { transform: rotate(90deg); opacity: 0; }
.wplc-toggle[aria-expanded="true"]::after {
  content: "✕";
  position: absolute; font-size: 24px; line-height: 1;
  transform: rotate(0); opacity: 1;
}

/* --- Panel --- */
.wplc-panel {
  pointer-events: auto;
  display: flex; flex-direction: column;
  position: absolute;
  bottom: 80px; right: 0;
  width: 380px; height: 600px;
  max-width: calc(100vw - 40px);
  max-height: calc(80vh - 20px);
  background: var(--wplc-light-bg);
  border-radius: var(--wplc-radius);
  box-shadow: var(--wplc-shadow);
  opacity: 0; visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: var(--wplc-transition);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.05);
}
.wplc-pos-left .wplc-panel { left: 0; right: auto; }

/* Open State */
.wplc-panel.is-open {
  opacity: 1; visibility: visible;
  transform: translateY(0) scale(1);
}

/* --- Header --- */
.wplc-header {
  padding: 16px;
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: blur(8px);
  color: #333;
}
.wplc-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: inherit; }
.wplc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: wplc-pulse 2s infinite;
}
.wplc-header select {
  font-size: 13px; padding: 4px 24px 4px 8px;
  border: 1px solid #e5e7eb; border-radius: 6px;
  background-color: #f9fafb; cursor: pointer; outline: none;
  color: #374151;
  height: auto;
  min-height: 30px;
}
.wplc-close {
    background: transparent; border: 0; cursor: pointer; font-size: 16px; color: inherit; padding: 5px;
}

/* --- Messages Area --- */
.wplc-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f9fafb;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
  color: var(--wplc-light-text);
}
.wplc-user, .wplc-bot {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}
.wplc-user {
  align-self: flex-end;
  background: #2563eb; color: #fff;
  border-bottom-right-radius: 2px;
  box-shadow: 0 2px 5px rgba(37,99,235,0.2);
}
.wplc-bot {
  align-self: flex-start;
  background: #fff; color: #1f2937;
  border-bottom-left-radius: 2px;
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.wplc-bot a { color: #2563eb; text-decoration: underline; }

/* Typing Indicator */
.wplc-typing { font-style: italic; color: #6b7280; background: transparent; border: none; box-shadow: none; padding-left: 0; }
.wplc-typing::after { content: '...'; animation: wplc-dots 1.5s steps(5, end) infinite; }

/* --- Input Area --- */
.wplc-form {
  padding: 12px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex; gap: 8px;
  align-items: center;
}
.wplc-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db; 
  border-radius: 20px;
  font-size: 14px; 
  outline: none;
  transition: border-color 0.2s;
  
  /* Force Light Mode Defaults first */
  background-color: #ffffff !important;
  color: #111827 !important;
  box-shadow: none !important;
  height: auto !important;
  min-height: 40px;
}
.wplc-input:focus { border-color: #2563eb; }
.wplc-input::placeholder { color: #9ca3af; opacity: 1; }

.wplc-send {
  background: #111827; color: #fff;
  border: none; border-radius: 50%;
  width: 42px; height: 42px; min-width: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.2s;
  padding: 0;
}
.wplc-send:hover { transform: scale(1.05); background: #000; }
.wplc-send i { font-size: 14px; }

/* --- Language Picker Overlay --- */
.wplc-lang-picker {
  position: absolute; top:0; left:0; right:0; bottom:0;
  background: #fff; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.wplc-lang-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; border: 1px solid #e5e7eb;
  font-size: 32px; margin: 0 10px; cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.wplc-lang-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); }

/* --- Animations --- */
@keyframes wplc-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
@keyframes wplc-dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* ===============================
   DARK MODE OVERRIDES
   =============================== */
@media (prefers-color-scheme: dark) {
  
  /* Panel Background */
  .wplc-panel { 
    background: var(--wplc-dark-bg) !important; 
    border-color: #374151 !important; 
  }

  /* Header */
  .wplc-header { 
    background: rgba(31, 41, 55, 0.95) !important; 
    border-bottom-color: #374151 !important; 
    color: #f3f4f6 !important;
  }
  .wplc-header select { 
    background-color: #111827 !important; 
    color: #ffffff !important; 
    border-color: #4b5563 !important; 
  }
  
  /* Messages */
  .wplc-messages { 
    background: #111827 !important; 
    color: var(--wplc-dark-text) !important;
  }
  .wplc-bot { 
    background: #374151 !important; 
    color: #f3f4f6 !important; 
    border-color: #4b5563 !important; 
  }
  .wplc-bot a { color: #60a5fa !important; }
  
  /* Forms & Input - AGGRESSIVE OVERRIDE */
  .wplc-form { 
    background: var(--wplc-dark-bg) !important; 
    border-top-color: #374151 !important; 
  }
  
  /* Hier zwingen wir den Hintergrund auf DUNKELGRAU und die Schrift auf WEISS */
  .wplc-input { 
    background-color: #374151 !important; 
    color: #ffffff !important; 
    border-color: #4b5563 !important;
    background-image: none !important; /* Verhindert Theme-Gradients */
  }
  
  /* Placeholder muss auch sichtbar sein */
  .wplc-input::placeholder { 
    color: #9ca3af !important; 
    opacity: 1 !important;
  }
  
  .wplc-input:focus { 
    background-color: #374151 !important;
    color: #ffffff !important;
    border-color: #60a5fa !important; 
  }

  /* Buttons */
  .wplc-send { 
    background: #374151 !important; 
    border: 1px solid #4b5563 !important; 
  }
  .wplc-send:hover { background: #4b5563 !important; }

  /* Lang Picker */
  .wplc-lang-picker { background: var(--wplc-dark-bg) !important; color: #fff !important; }
  .wplc-lang-btn { background: #111827 !important; border-color: #374151 !important; }
}

/* --- Mobile --- */
@media (max-width: 480px) {
  .wplc-chatbot { bottom: 10px; right: 10px; }
  .wplc-pos-left { left: 10px; }
  .wplc-panel { width: calc(100vw - 20px); height: 80vh; bottom: 70px; }
}