/* Ebsdorfergrund Chatbot – Frontend Styles */

:root {
  --ecb-primary:   #2e7d32;
  --ecb-secondary: #1b5e20;
  --ecb-text:      #1a1a1a;
  --ecb-bg:        #ffffff;
  --ecb-border:    #e0e0e0;
  --ecb-user-bg:   #e8f5e9;
  --ecb-bot-bg:    #f5f5f5;
  --ecb-radius:    16px;
  --ecb-shadow:    0 8px 32px rgba(0,0,0,0.18);
}

/* Toggle Button */
#ebsdorf-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--ecb-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(46,125,50,0.45);
  z-index: 99998;
  transition: transform .2s, box-shadow .2s;
  overflow: hidden;
  padding: 0;
}
#ebsdorf-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(46,125,50,0.55);
}
#ebsdorf-chat-toggle img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 50%;
}
#ebsdorf-chat-toggle .ecb-toggle-icon {
  font-size: 32px;
  line-height: 1;
}

/* Chat Window */
#ebsdorf-chat-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 130px);
  border-radius: var(--ecb-radius);
  background: var(--ecb-bg);
  box-shadow: var(--ecb-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99997;
  overflow: hidden;
  transform: scale(.95) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s;
}
#ebsdorf-chat-window.ecb-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.ecb-header {
  background: var(--ecb-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ecb-header img, .ecb-header .ecb-header-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: contain;
  background: rgba(255,255,255,0.15);
  padding: 4px;
  font-size: 28px; line-height: 44px; text-align: center;
}
.ecb-header-title { font-weight: 700; font-size: 15px; }
.ecb-header-subtitle { font-size: 11px; opacity: .8; }
.ecb-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  opacity: .8;
  padding: 4px;
}
.ecb-close-btn:hover { opacity: 1; }

/* Privacy Banner */
.ecb-privacy-banner {
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  padding: 10px 14px;
  font-size: 11.5px;
  color: #5d4037;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}
.ecb-privacy-banner .ecb-privacy-ok {
  margin-left: auto;
  background: none;
  border: 1px solid #5d4037;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  white-space: nowrap;
  color: #5d4037;
}

/* Messages */
.ecb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ecb-messages::-webkit-scrollbar { width: 4px; }
.ecb-messages::-webkit-scrollbar-thumb { background: var(--ecb-border); border-radius: 4px; }

.ecb-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.ecb-msg-bot {
  background: var(--ecb-bot-bg);
  color: var(--ecb-text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.ecb-msg-user {
  background: var(--ecb-user-bg);
  color: var(--ecb-text);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.ecb-msg-meta {
  font-size: 10.5px;
  color: #999;
  margin-top: 3px;
  text-align: right;
}
.ecb-msg-bot .ecb-msg-meta { text-align: left; }

/* Typing indicator */
.ecb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
  background: var(--ecb-bot-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.ecb-typing span {
  width: 7px; height: 7px;
  background: var(--ecb-primary);
  border-radius: 50%;
  display: inline-block;
  animation: ecb-bounce 1.2s infinite;
  opacity: .7;
}
.ecb-typing span:nth-child(2) { animation-delay: .2s; }
.ecb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ecb-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* Input area */
.ecb-input-area {
  padding: 12px;
  border-top: 1px solid var(--ecb-border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--ecb-bg);
}
.ecb-input {
  flex: 1;
  border: 1px solid var(--ecb-border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: border-color .15s;
  max-height: 100px;
}
.ecb-input:focus { border-color: var(--ecb-primary); }
.ecb-send-btn {
  background: var(--ecb-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  align-self: flex-end;
}
.ecb-send-btn:hover { background: var(--ecb-secondary); }
.ecb-send-btn:disabled { opacity: .5; cursor: default; }

/* Mic button */
.ecb-mic-btn {
  background: transparent;
  border: 1px solid var(--ecb-border);
  border-radius: 50%;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
  align-self: flex-end;
  color: #555;
}
.ecb-mic-btn:hover {
  background: #f0faf0;
  border-color: var(--ecb-primary);
}
/* Pulsing animation when actively listening */
.ecb-mic-active {
  background: #fef2f2 !important;
  border-color: #dc2626 !important;
  color: #dc2626 !important;
  animation: ecb-pulse 1.2s ease-in-out infinite;
}
@keyframes ecb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* Mic error message */
.ecb-mic-error {
  margin: 4px 12px;
  padding: 6px 10px;
  font-size: 12px;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 6px;
  animation: ecb-fadein .2s ease;
}

/* STT availability hint (auto-disappears) */
.ecb-stt-hint {
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 2px 0 4px;
  animation: ecb-fadein .4s ease;
}
@keyframes ecb-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Footer */
.ecb-footer {
  padding: 5px 14px 8px;
  text-align: center;
  font-size: 10px;
  color: #bbb;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
  #ebsdorf-chat-window {
    bottom: 0; right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 92vh;
    max-height: 92vh;
    border-radius: var(--ecb-radius) var(--ecb-radius) 0 0;
  }
  #ebsdorf-chat-toggle { bottom: 20px; right: 20px; }
}

/* ── Mängelmelder & Chips ─────────────────────────────────── */
.ecb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 12px 10px;
}
.ecb-chip {
  background: var(--ecb-primary);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.ecb-chip:hover  { background: var(--ecb-secondary); transform: translateY(-1px); }
.ecb-chip:active { transform: translateY(0); }
.ecb-chip-outline {
  background: transparent;
  color: var(--ecb-primary);
  border: 1.5px solid var(--ecb-primary);
}
.ecb-chip-outline:hover { background: var(--ecb-primary); color: #fff; }

/* Report mode header transition */
.ecb-header { transition: background .3s ease; }

/* ── Report Mode ── */
.ecb-header-report {
  background: #b91c1c !important;
}
.ecb-report-badge {
  font-size: 11px;
  font-weight: 600;
  opacity: 1;
}

/* Quick action buttons */
.ecb-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0;
}

/* Chip buttons (inline actions) */
.ecb-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px 0;
}
.ecb-chip {
  background: #fff;
  border: 1.5px solid var(--ecb-primary);
  color: var(--ecb-primary);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.ecb-chip:hover {
  background: var(--ecb-primary);
  color: #fff;
}
.ecb-chip-report {
  border-color: #b91c1c;
  color: #b91c1c;
}
.ecb-chip-report:hover {
  background: #b91c1c;
  color: #fff;
}
.ecb-chip-danger {
  border-color: #dc2626;
  color: #dc2626;
}
.ecb-chip-danger:hover {
  background: #dc2626;
  color: #fff;
}
.ecb-chip-map {
  border-color: #2563eb;
  color: #2563eb;
}
.ecb-chip-map:hover {
  background: #2563eb;
  color: #fff;
}
.ecb-chip-upload {
  border-color: #7c3aed;
  color: #7c3aed;
}
.ecb-chip-upload:hover {
  background: #7c3aed;
  color: #fff;
}

/* Photo upload row */
.ecb-photo-upload-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 8px 0;
}

/* System message (non-chat info) */
.ecb-system-msg {
  font-size: 12px;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 2px 0;
  animation: ecb-fadein .2s ease;
}

/* Map modal */
.ecb-map-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ecb-map-modal-inner {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.ecb-map-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* Map modal buttons */
.ecb-btn-primary {
  background: var(--ecb-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.ecb-btn-primary:hover:not(:disabled) { background: var(--ecb-secondary); }
.ecb-btn-primary:disabled { opacity: .4; cursor: default; }
.ecb-btn-secondary {
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.ecb-btn-secondary:hover { background: #eee; }

/* ── Speech bubble over toggle button ── */
.ecb-bubble {
  position: fixed;
  bottom: 104px;
  right: 28px;
  background: #fff;
  color: #1a1a1a;
  font-size: 13.5px;
  line-height: 1.45;
  padding: 10px 28px 10px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  max-width: 220px;
  text-align: left;
  z-index: 99996;
  animation: ecb-bubble-in .35s cubic-bezier(.34,1.56,.64,1) both;
  border: 1px solid rgba(0,0,0,.07);
  cursor: default;
}
/* tail pointing toward the button */
.ecb-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.08));
}
.ecb-bubble-close {
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 16px;
  line-height: 1;
  color: #aaa;
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  transition: color .15s;
}
.ecb-bubble-close:hover { color: #333; }
.ecb-bubble-hidden {
  display: none !important;
}
@keyframes ecb-bubble-in {
  from { opacity: 0; transform: scale(.85) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@media (max-width: 480px) {
  .ecb-bubble { bottom: 90px; right: 20px; max-width: 180px; font-size: 12.5px; }
}

/* ── Ortsteile-Marker auf der Karte (SVG-Pin + Label) ── */

/* Leaflet-Wrapper: muss transparent und ohne Rahmen sein */
.ecb-ort-marker {
  background: transparent !important;
  border: none !important;
  overflow: visible !important;
}

/* Pin + Label nebeneinander */
.ecb-ort-pin-wrap {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

/* Textlabel neben dem Pin */
.ecb-ort-label {
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1.5px solid #2563eb;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: background .15s, color .15s;
  font-family: inherit;
  line-height: 1.5;
  margin-bottom: 5px; /* Vertikal mittig zum Pin ausrichten */
}
.ecb-ort-pin-wrap:hover .ecb-ort-label {
  background: #2563eb;
  color: #fff;
}
.ecb-ort-pin-wrap:hover svg path:first-child {
  fill: #1d4ed8;
}

/* ── Datenschutz-Info-Button im Footer ── */
.ecb-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ecb-info-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  opacity: .6;
  transition: opacity .15s;
  vertical-align: middle;
}
.ecb-info-btn:hover { opacity: 1; }

/* ── Datenschutz-Popup ── */
.ecb-privacy-popup {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}
.ecb-privacy-popup[style*="flex"] { pointer-events: all; }
.ecb-privacy-popup-inner {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ecb-fadein .2s ease;
  border: 1px solid rgba(0,0,0,.08);
}
.ecb-privacy-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
  flex-shrink: 0;
}
.ecb-privacy-popup-body {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: #333;
  overflow-y: auto;
}
.ecb-privacy-popup-body p {
  margin: 0 0 10px;
}
.ecb-privacy-popup-body p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .ecb-privacy-popup {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
  }
  .ecb-privacy-popup-inner {
    border-radius: 12px 12px 0 0;
    max-height: 75vh;
  }
}
