/*
 * Author: Alexander Saurwein
 * Path: app/static/widget.css
 *
 * CSS namespace .chatscreen-* — every selector is prefixed to avoid clashes
 * with the host page styles.
 */

.chatscreen-root,
.chatscreen-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
}

.chatscreen-root {
  --cs-primary: #0B3D91;
  --cs-primary-fg: #ffffff;
  --cs-admin-bg: #eef0f3;
  --cs-admin-fg: #1a1a1a;
  --cs-bot-bg: #e8eaef;
  --cs-bot-fg: #1a1a1a;
  --cs-bg: #ffffff;
  --cs-border: #d8dde3;
  --cs-muted: #6b7280;
  --cs-status-online: #22c55e;
  --cs-status-away: #f59e0b;
  --cs-status-offline: #9ca3af;

  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483600;
}

.chatscreen-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cs-primary);
  color: var(--cs-primary-fg);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.chatscreen-button:hover { filter: brightness(1.05); }
.chatscreen-button svg { width: 26px; height: 26px; fill: currentColor; }

.chatscreen-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.chatscreen-badge.is-visible { display: flex; }

.chatscreen-window {
  display: none;
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 340px;
  height: 500px;
  background: var(--cs-bg);
  border: 1px solid var(--cs-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  flex-direction: column;
  overflow: hidden;
}
.chatscreen-window.is-open { display: flex; }

.chatscreen-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chatscreen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--cs-primary);
  color: var(--cs-primary-fg);
}
.chatscreen-title { flex: 1; font-weight: 600; font-size: 15px; }
.chatscreen-close {
  background: none; border: none; color: inherit; cursor: pointer; font-size: 22px; line-height: 1; padding: 0 4px;
}

.chatscreen-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.18);
}
.chatscreen-status .chatscreen-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--cs-status-offline);
}
.chatscreen-status.is-online .chatscreen-dot { background: var(--cs-status-online); }
.chatscreen-status.is-away .chatscreen-dot { background: var(--cs-status-away); }

.chatscreen-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatscreen-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  word-wrap: break-word;
}
.chatscreen-msg-time { font-size: 10px; color: var(--cs-muted); margin-top: 2px; }
.chatscreen-msg.is-visitor { align-self: flex-end; background: var(--cs-primary); color: var(--cs-primary-fg); border-bottom-right-radius: 4px; }
.chatscreen-msg.is-admin   { align-self: flex-start; background: var(--cs-admin-bg); color: var(--cs-admin-fg); border-bottom-left-radius: 4px; }
.chatscreen-msg.is-bot     { align-self: flex-start; background: var(--cs-bot-bg);   color: var(--cs-bot-fg);   border-bottom-left-radius: 4px; }
.chatscreen-msg.is-bot::before { content: "🤖 "; }

.chatscreen-typing {
  align-self: flex-start;
  font-size: 13px;
  color: var(--cs-muted);
  font-style: italic;
}

.chatscreen-input-row {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--cs-border);
  background: #fff;
}
.chatscreen-input {
  flex: 1;
  border: 1px solid var(--cs-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none;
  height: 38px;
  max-height: 110px;
}
.chatscreen-send {
  background: var(--cs-primary);
  color: var(--cs-primary-fg);
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}
.chatscreen-send:disabled { opacity: 0.5; cursor: not-allowed; }

.chatscreen-footer {
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--cs-border);
  background: #fff;
}
.chatscreen-footer a { color: var(--cs-muted); text-decoration: underline; cursor: pointer; }

.chatscreen-consent {
  padding: 14px;
  font-size: 13px;
  color: var(--cs-admin-fg);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}
.chatscreen-consent button {
  background: var(--cs-primary);
  color: var(--cs-primary-fg);
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 480px) {
  .chatscreen-root { bottom: 0; right: 0; }
  .chatscreen-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .chatscreen-button { margin: 16px; }
}
