/* ============================================================
   Netzarea Custom Zammad Chat Styling
   ============================================================ */

:root {
  --nz-green: #009966;
  --nz-green-dark: #007a52;
  --nz-green-shadow: rgba(0, 153, 102, 0.22);
  --nz-bg: #ffffff;
  --nz-bg-soft: #fafaf8;
  --nz-bg-msg-agent: #ececec;
  --nz-text: #1f2937;
  --nz-text-soft: #6b7280;
  --nz-border: #e5e7eb;
  --nz-online: #4ade80;
}

/* ----- Container ----- */
.zammad-chat {
  color: var(--nz-text);
  position: fixed;
  right: 24px;
  bottom: 0;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  width: 320px;
  height: auto;
  min-height: 3.2em;
  box-shadow: 0 -4px 20px var(--nz-green-shadow);
  border-radius: 12px 12px 0 0;
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}

@media only screen and (max-width: 768px) {
  .zammad-chat {
    right: 0;
    width: 100%;
    border-radius: 0 !important;
    font-size: 15px !important;
  }
}

.zammad-chat.zammad-chat-is-loaded { display: flex; opacity: 0; }
.zammad-chat.zammad-chat-is-shown { opacity: 1; transition: opacity 200ms ease; }
.zammad-chat.zammad-chat-is-open { height: 30em; }

@media only screen and (max-width: 768px) {
  .zammad-chat.zammad-chat-is-open { height: 100%; }
}

/* ----- Header ----- */
.zammad-chat-header {
  padding: 14px 16px;
  background: var(--nz-green);
  color: white;
  line-height: 1.3;
  height: auto;
  min-height: 3.2em;
  box-shadow: none;
  position: relative;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 150ms ease;
}

.zammad-chat-header:hover { background: var(--nz-green-dark); }

.zammad-chat.zammad-chat-is-open .zammad-chat-header {
  cursor: default;
  background: var(--nz-green);
}

@media only screen and (max-width: 768px) {
  .zammad-chat-header { border-radius: 0 !important; }
}

/* ----- Welcome (Pulse + Text, links) ----- */
.zammad-chat-welcome {
  display: flex;
  align-items: center;
  flex: 1;
  order: 1;
  position: relative;
  padding-left: 18px;
  min-width: 0;
}

.zammad-chat-welcome::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nz-online);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.8);
  animation: nz-pulse 2s ease-in-out infinite;
}

@keyframes nz-pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.8); }
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.zammad-chat-welcome .zammad-chat-icon { display: none; }

.zammad-chat-welcome-text {
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zammad-chat-welcome-text strong { font-weight: 600; }

/* ----- Header Controls (rechts) ----- */
.zammad-chat-header-controls {
  order: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  float: none;
}

.zammad-chat-header-icon {
  position: static;
  height: auto;
  width: auto;
  text-align: center;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 150ms ease;
  display: flex;
  align-items: center;
}

.zammad-chat-header-icon:hover { background: rgba(255, 255, 255, 0.15); }
.zammad-chat-header-icon::before { content: none; }

.zammad-chat-header-icon-open,
.zammad-chat-header-icon-close {
  fill: currentColor;
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.zammad-chat-header-icon-close { width: 13px; }

.zammad-chat-header-icon-close,
.zammad-chat.zammad-chat-is-open .zammad-chat-header-icon-open { display: none; }

.zammad-chat.zammad-chat-is-open .zammad-chat-header-icon-close { display: inline; }

/* ----- Agent Display ----- */
.zammad-chat-agent {
  float: none;
  display: flex;
  align-items: center;
  flex: 1;
  order: 1;
}

.zammad-chat-agent.zammad-chat-is-hidden { display: none; }

.zammad-chat-agent-avatar {
  border-radius: 50%;
  margin-right: 10px;
  float: none;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.zammad-chat-agent-name {
  font-weight: 500;
  font-size: 14px;
  display: block;
}

.zammad-chat-agent-status {
  margin: 0;
  display: inline-block;
  line-height: 1;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  opacity: 0.9;
}

.zammad-chat-agent-status.zammad-chat-is-hidden { display: none; }

.zammad-chat-agent-status::before {
  content: '';
  background: #f59e0b;
  display: inline-block;
  height: 6px;
  width: 6px;
  border-radius: 50%;
  position: relative;
  margin-right: 5px;
  vertical-align: middle;
  box-shadow: none;
}

.zammad-chat-agent-status[data-status='online']::before { background: var(--nz-online); }
.zammad-chat-agent-status[data-status='connecting']::before {
  animation: linear nz-connect-fade 600ms infinite alternate;
  background: #f59e0b;
}

@keyframes nz-connect-fade {
  from { opacity: 0.5; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

/* ----- Modal ----- */
.zammad-chat-modal {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  top: 3.2em;
  margin-top: 0;
  text-align: center;
  background: var(--nz-bg);
  z-index: 1;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zammad-chat-modal:empty { display: none; }

.zammad-chat-modal-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--nz-text);
}

.zammad-chat-modal-text .zammad-chat-loading-animation { font-size: 0.7em; }
.zammad-chat-modal-text .zammad-chat-button { margin-top: 1em; font-size: 13px; }

.zammad-chat-modal .zammad-chat-loading-animation {
  margin-right: 8px;
  vertical-align: middle;
}

/* ----- Scroll Hint ----- */
.zammad-scroll-hint {
  background: var(--nz-bg-soft);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--nz-border);
  padding: 7px 12px;
  color: var(--nz-text-soft);
  cursor: pointer;
  font-size: 12px;
}

.zammad-scroll-hint.is-hidden { display: none; }
.zammad-scroll-hint-icon { fill: var(--nz-text-soft); margin-right: 8px; }

/* ----- Body / Messages ----- */
.zammad-chat-body {
  padding: 12px 14px;
  overflow: auto;
  background: var(--nz-bg-soft);
  flex: 1;
  display: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.zammad-chat-is-open .zammad-chat-body { display: block; }

.zammad-chat-timestamp {
  text-align: center;
  color: var(--nz-text-soft);
  font-size: 11px;
  margin: 12px 0 8px;
}

.zammad-chat-status { margin: 12px 0; text-align: center; }
.zammad-chat-message { margin: 6px 0; }

.zammad-chat-message-body {
  white-space: pre-line;
  overflow-wrap: break-word;
  border-radius: 14px;
  padding: 9px 13px;
  line-height: 1.4;
  font-size: 13px;
  background: var(--nz-bg-msg-agent);
  color: var(--nz-text);
  display: inline-block;
  max-width: 78%;
  box-shadow: none;
  border-bottom-left-radius: 4px;
}

.zammad-chat-status-inner {
  padding: 8px 14px;
  font-size: 12px;
  line-height: 1.4;
  background: #f3f4f6;
  color: var(--nz-text-soft);
  display: inline-block;
  max-width: 80%;
  border-radius: 8px;
  box-shadow: none;
}

.zammad-chat-message--customer { text-align: right; }

.zammad-chat-message--customer + .zammad-chat-message--agent,
.zammad-chat-message--agent + .zammad-chat-message--customer {
  margin-top: 12px;
}

.zammad-chat-message--customer .zammad-chat-message-body {
  background: var(--nz-green);
  color: white;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 14px;
}

.zammad-chat-message--unread { font-weight: 500; }
.zammad-chat-message--typing .zammad-chat-message-body { white-space: normal; }

/* ----- Loading ----- */
.zammad-chat-loading-animation { display: inline-block; }

.zammad-chat-loading-circle {
  background: var(--nz-text-soft);
  border-radius: 50%;
  height: 0.5em;
  width: 0.5em;
  display: inline-block;
  animation: ease-in-out nz-load-fade 600ms infinite alternate;
}

.zammad-chat-loading-circle + .zammad-chat-loading-circle { animation-delay: 0.13s; }
.zammad-chat-loading-circle + .zammad-chat-loading-circle + .zammad-chat-loading-circle { animation-delay: 0.26s; }

@keyframes nz-load-fade {
  0% { opacity: 0.3; transform: scale(0.6); }
  67% { opacity: 1; transform: scale(1); }
}

/* ----- Form Controls (FORM-Element) ----- */
.zammad-chat-controls {
  overflow: hidden;
  display: none;
  align-items: flex-end;
  border-top: 1px solid var(--nz-border);
  padding: 8px 10px;
  margin: 0;
  line-height: 1.4em;
  box-shadow: none;
  position: relative;
  background: var(--nz-bg);
  gap: 8px;
}

.zammad-chat-is-open .zammad-chat-controls { display: flex; }

/* ----- Input (contenteditable div) ----- */
.zammad-chat-input {
  margin: 0;
  padding: 8px 10px;
  float: none;
  max-height: 6em;
  min-height: 1.4em;
  font-family: inherit;
  line-height: 1.4em;
  font-size: 13px;
  color: var(--nz-text);
  appearance: none;
  border: none;
  background: none;
  box-shadow: none;
  box-sizing: content-box;
  outline: none;
  flex: 1;
  overflow: auto;
  display: block;
}

.zammad-chat-input:empty::before {
  content: attr(placeholder);
  color: #9ca3af;
  pointer-events: none;
}

/* ----- Send Button (mit "Senden" Text - Pill-Form) ----- */
.zammad-chat-button {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  background: var(--nz-green);
  color: white;
  padding: 9px 16px;
  margin: 0;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  box-shadow: none;
  outline: none;
  display: inline-block;
  transition: background 150ms ease, transform 100ms ease;
  flex-shrink: 0;
  align-self: center;
}

.zammad-chat-button:hover { background: var(--nz-green-dark); }
.zammad-chat-button:active { transform: scale(0.97); }

.zammad-chat-send { float: none; }

.zammad-chat-button:disabled,
.zammad-chat-input:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.zammad-chat-is-hidden { display: none; }

.zammad-chat--animate { transition: transform 400ms ease, height 400ms ease; }

.zammad-chat-icon {
  height: 18px;
  width: 18px;
  fill: currentColor;
  vertical-align: middle;
}
