/**
 * AKIM Chatbot Widget Styles
 * Passend zum AKIM Corporate Design
 */

/* CSS Custom Properties - AKIM Branding */
:root {
  --akim-chat-primary: #3D4771;
  --akim-chat-accent: #D35F00;
  --akim-chat-bg: #ffffff;
  --akim-chat-text: #333333;
  --akim-chat-text-light: #666666;
  --akim-chat-border: #e0e0e0;
  --akim-chat-user-bg: #3D4771;
  --akim-chat-user-text: #ffffff;
  --akim-chat-bot-bg: #f5f7fa;
  --akim-chat-bot-text: #333333;
  --akim-chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --akim-chat-radius: 12px;
}

/* Container */
#akim-chatbot {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#akim-chatbot.akim-chat-open {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

/* Chat Button */
.akim-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--akim-chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--akim-chat-shadow);
  transition: transform 0.2s ease, background-color 0.2s ease;
  position: relative;
}

.akim-chat-button:hover {
  transform: scale(1.05);
  background: #c45500;
}

.akim-chat-button svg {
  width: 28px;
  height: 28px;
  color: white;
}

.akim-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Window */
.akim-chat-window {
  width: 450px;
  height: 600px;
  max-height: calc(100vh - 40px);
  max-width: calc(100vw - 40px);
  background: var(--akim-chat-bg);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: akimFadeIn 0.3s ease;
  pointer-events: auto;
}

@keyframes akimSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.akim-chat-header {
  background: var(--akim-chat-primary);
  color: white;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.akim-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.akim-chat-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
}

.akim-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.akim-chat-header p {
  margin: 0;
  font-size: 12px;
  opacity: 0.8;
}

.akim-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.akim-lang-select {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.akim-lang-select:hover {
  background: rgba(255, 255, 255, 0.25);
}

.akim-lang-select option {
  color: var(--akim-chat-text);
  background: white;
}

.akim-chat-minimize,
.akim-chat-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.akim-chat-minimize:hover,
.akim-chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.akim-chat-minimize svg,
.akim-chat-close svg {
  width: 20px;
  height: 20px;
}

/* Messages Area */
.akim-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Nachrichten links ausrichten */
  justify-content: flex-start; /* Nachrichten oben starten */
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message Bubbles */
.akim-chat-message {
  max-width: 85%;
  animation: akimFadeIn 0.3s ease;
}

@keyframes akimFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.akim-chat-message-user {
  align-self: flex-end;
}

.akim-chat-message-assistant {
  align-self: flex-start;
}

.akim-chat-message-content {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
}

.akim-chat-message-user .akim-chat-message-content {
  background: var(--akim-chat-user-bg);
  color: var(--akim-chat-user-text);
  border-bottom-right-radius: 4px;
}

.akim-chat-message-assistant .akim-chat-message-content {
  background: var(--akim-chat-bot-bg);
  color: var(--akim-chat-bot-text);
  border-bottom-left-radius: 4px;
}

.akim-chat-message-time {
  font-size: 11px;
  color: var(--akim-chat-text-light);
  margin-top: 4px;
  padding: 0 8px;
}

.akim-chat-message-user .akim-chat-message-time {
  text-align: right;
}

/* Typing Indicator */
.akim-chat-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--akim-chat-bot-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.akim-typing-dots {
  display: flex;
  gap: 4px;
}

.akim-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--akim-chat-text-light);
  border-radius: 50%;
  animation: akimTyping 1.4s infinite ease-in-out;
}

.akim-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.akim-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes akimTyping {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Input Area */
.akim-chat-input-area {
  padding: 15px;
  border-top: 1px solid var(--akim-chat-border);
  flex-shrink: 0;
}

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

.akim-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--akim-chat-border);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.akim-chat-input:focus {
  border-color: var(--akim-chat-accent);
}

.akim-chat-input::placeholder {
  color: var(--akim-chat-text-light);
}

.akim-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--akim-chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.akim-chat-send:hover {
  background: #c45500;
}

.akim-chat-send:disabled {
  background: var(--akim-chat-border);
  cursor: not-allowed;
}

.akim-chat-send svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* Completion Prompt */
.akim-chat-completion {
  background: var(--akim-chat-bot-bg);
  border: 1px solid var(--akim-chat-border);
  border-radius: var(--akim-chat-radius);
  padding: 15px;
  margin-top: 10px;
  animation: akimFadeIn 0.3s ease;
}

.akim-chat-completion p {
  margin: 0 0 12px 0;
  font-weight: 500;
}

.akim-chat-completion-buttons {
  display: flex;
  gap: 10px;
}

.akim-btn-primary,
.akim-btn-secondary {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.akim-btn-primary {
  background: var(--akim-chat-accent);
  color: white;
  border: none;
}

.akim-btn-primary:hover {
  background: #c45500;
}

.akim-btn-secondary {
  background: white;
  color: var(--akim-chat-text);
  border: 1px solid var(--akim-chat-border);
}

.akim-btn-secondary:hover {
  background: var(--akim-chat-bot-bg);
}

/* Spinner Animation */
.akim-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--akim-chat-border);
  border-top-color: var(--akim-chat-accent);
  border-radius: 50%;
  animation: akimSpin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* Spinner in Buttons (weiss) */
.akim-btn-primary .akim-spinner {
  width: 14px;
  height: 14px;
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
  margin-right: 4px;
}

@keyframes akimSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Disabled button state */
.akim-btn-primary:disabled {
  background: var(--akim-chat-text-light);
  cursor: not-allowed;
  opacity: 0.8;
}

/* Success/Error States */
.akim-success {
  color: #22c55e;
  font-weight: 500;
}

.akim-error {
  color: #ef4444;
  font-weight: 500;
}

/* Scrollbar Styling */
.akim-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.akim-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.akim-chat-messages::-webkit-scrollbar-thumb {
  background: var(--akim-chat-border);
  border-radius: 3px;
}

.akim-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--akim-chat-text-light);
}

/* Responsive Design */
@media (max-width: 480px) {
  #akim-chatbot {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: block; /* Kein Flexbox - einfaches Block-Layout */
  }

  #akim-chatbot.akim-chat-open {
    background: none; /* Kein Overlay nötig bei Fullscreen */
  }

  .akim-chat-window {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0;
    display: grid;
    grid-template-rows: auto 1fr auto; /* Header, Messages, Input */
  }

  .akim-chat-header {
    padding: 10px 12px;
    grid-row: 1;
  }

  .akim-chat-header h3 {
    font-size: 14px;
  }

  .akim-chat-header p {
    font-size: 10px;
  }

  .akim-chat-logo {
    width: 32px;
    height: 32px;
  }

  .akim-chat-header-info {
    gap: 8px;
  }

  /* Messages-Bereich */
  .akim-chat-messages {
    grid-row: 2;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end; /* Nachrichten unten starten */
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
  }

  .akim-chat-message {
    display: block;
    max-width: 85%;
    flex-shrink: 0;
  }

  .akim-chat-message-user {
    align-self: flex-end;
  }

  .akim-chat-message-assistant {
    align-self: flex-start;
  }

  .akim-chat-message-content {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    display: inline-block;
  }

  .akim-chat-message-time {
    font-size: 10px;
    margin-top: 2px;
  }

  /* Input-Bereich */
  .akim-chat-input-area {
    grid-row: 3;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--akim-chat-bg);
    border-top: 1px solid var(--akim-chat-border);
  }

  .akim-chat-form {
    gap: 8px;
  }

  .akim-chat-input {
    padding: 10px 14px;
    font-size: 16px;
    border-radius: 20px;
  }

  .akim-chat-send {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }

  .akim-chat-send svg {
    width: 18px;
    height: 18px;
  }

  .akim-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
  }

  /* Sprachauswahl kompakter */
  .akim-lang-select {
    padding: 4px 8px;
    font-size: 12px;
  }

  /* Minimize/Close Buttons */
  .akim-chat-minimize svg,
  .akim-chat-close svg {
    width: 18px;
    height: 18px;
  }

  /* Completion Buttons auf Mobile */
  .akim-chat-completion {
    padding: 10px;
    margin-top: 8px;
  }

  .akim-chat-completion p {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .akim-chat-completion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .akim-btn-primary,
  .akim-btn-secondary {
    padding: 8px 14px;
    font-size: 13px;
    flex: 1;
    text-align: center;
    min-width: 120px;
  }

  /* Typing Indicator */
  .akim-chat-typing {
    align-self: flex-start;
    flex-shrink: 0;
  }

  /* Completion Prompt */
  .akim-chat-completion {
    align-self: stretch;
    flex-shrink: 0;
    width: 100%;
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  .akim-chat-window {
    width: 350px;
    height: 500px;
  }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
  /* Kann bei Bedarf aktiviert werden */
  /*
  :root {
    --akim-chat-bg: #1a1a2e;
    --akim-chat-text: #e4e4e7;
    --akim-chat-text-light: #a1a1aa;
    --akim-chat-border: #3f3f46;
    --akim-chat-bot-bg: #27273a;
    --akim-chat-bot-text: #e4e4e7;
  }
  */
}

/* Popup Overlay for Additional Data */
.akim-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: akimFadeIn 0.2s ease;
}

.akim-popup {
  background: var(--akim-chat-bg);
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  position: relative;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: akimSlideUp 0.3s ease;
}

.akim-popup-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: var(--akim-chat-text-light);
  transition: color 0.2s ease;
}

.akim-popup-close:hover {
  color: var(--akim-chat-text);
}

.akim-popup-close svg {
  width: 20px;
  height: 20px;
}

.akim-popup h3 {
  margin: 0 0 5px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--akim-chat-primary);
}

.akim-popup-subtitle {
  margin: 0 0 25px 0;
  font-size: 14px;
  color: var(--akim-chat-text-light);
}

.akim-popup-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.akim-popup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.akim-popup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.akim-popup-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--akim-chat-text);
}

.akim-popup-field input,
.akim-popup-field select {
  padding: 12px 14px;
  border: 1px solid var(--akim-chat-border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.akim-popup-field input:focus,
.akim-popup-field select:focus {
  outline: none;
  border-color: var(--akim-chat-accent);
}

.akim-popup-field input::placeholder {
  color: var(--akim-chat-text-light);
}

.akim-popup-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.akim-popup-buttons .akim-btn-secondary {
  flex: 1;
}

.akim-popup-buttons .akim-btn-primary {
  flex: 1;
}

/* Mobile responsiveness for popup */
@media (max-width: 480px) {
  .akim-popup-overlay {
    padding: 15px;
  }

  .akim-popup {
    padding: 20px;
    max-height: calc(100vh - 30px);
    overflow-y: auto;
  }

  .akim-popup h3 {
    font-size: 18px;
    padding-right: 25px;
  }

  .akim-popup-row {
    grid-template-columns: 1fr;
  }

  .akim-popup-buttons {
    flex-direction: column-reverse;
  }

  .akim-popup-field input,
  .akim-popup-field select {
    padding: 10px 12px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Print - Hide Chatbot */
@media print {
  #akim-chatbot {
    display: none !important;
  }
}
