
/**
 * AFAS InSite Configurator Widget — Productie CSS
 * ================================================
 * Alle styling voor de floating chatbot-widget,
 * het chatvenster, de wireframe-overlay en responsive layout.
 *
 * GEBRUIK:
 * <link rel="stylesheet" href="/assets/insite-widget.css">
 */

/* ═══════════════════════════════════════════════════════
   RESET (alleen voor widget-elementen)
   ═══════════════════════════════════════════════════════ */
#insite-fab,
#insite-fab *,
#chatWindow,
#chatWindow *,
#wfOverlay,
#wfOverlay * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ═══════════════════════════════════════════════════════
   FLOATING CHAT BUBBLE
   ═══════════════════════════════════════════════════════ */
#insite-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f3460, #1a5276);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(15, 52, 96, 0.35);
  z-index: 9999;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none;
}

#insite-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(15, 52, 96, 0.45);
}

#insite-fab svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  pointer-events: none;
}

#insite-fab .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e74c3c;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════
   CHAT TOGGLE (hidden checkbox)
   ═══════════════════════════════════════════════════════ */
#chat-toggle {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════
   CHAT WINDOW
   ═══════════════════════════════════════════════════════ */
.insite-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 580px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#chat-toggle:checked ~ .insite-chat-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

#chat-toggle:checked ~ #insite-fab .badge {
  display: none;
}

/* ── Header ── */
.insite-chat-header {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.insite-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.insite-chat-info {
  flex: 1;
  min-width: 0;
}

.insite-chat-info .name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.insite-chat-info .status {
  font-size: 10px;
  opacity: 0.7;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insite-chat-close {
  cursor: pointer;
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
  transition: opacity 0.15s ease;
  background: none;
  border: none;
  color: #fff;
  padding: 4px;
}

.insite-chat-close:hover {
  opacity: 1;
}

/* ── Progress bar ── */
.insite-progress-wrap {
  padding: 0 20px;
  background: #f8f9fb;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.insite-progress-outer {
  height: 4px;
  background: #e8ecf0;
  border-radius: 2px;
  margin: 10px 0 6px;
  overflow: hidden;
}

.insite-progress-inner {
  height: 100%;
  background: linear-gradient(90deg, #0f3460, #3b82f6);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

.insite-progress-text {
  font-size: 10px;
  color: #888;
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

/* ── Messages area ── */
.insite-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 340px;
  scroll-behavior: smooth;
}

/* Scrollbar styling */
.insite-chat-body::-webkit-scrollbar {
  width: 4px;
}

.insite-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.insite-chat-body::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 2px;
}

/* ── Message bubbles ── */
.insite-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.insite-msg.bot {
  background: #f0f4f8;
  color: #1a1a2e;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.insite-msg.user {
  background: linear-gradient(135deg, #0f3460, #1a5276);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.insite-msg.system {
  background: #fffbeb;
  color: #92400e;
  align-self: center;
  border-radius: 8px;
  font-size: 11px;
  text-align: center;
  border: 1px solid #fde68a;
  max-width: 95%;
}

.insite-msg .portal-badge {
  display: inline-block;
  background: rgba(15, 52, 96, 0.08);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #0f3460;
  margin-bottom: 4px;
}

/* Typing indicator */
.insite-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
  background: #f0f4f8;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.insite-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bbb;
  animation: insiteTyping 1.2s infinite;
}

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

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

@keyframes insiteTyping {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ═══════════════════════════════════════════════════════
   ANSWER BUTTONS
   ═══════════════════════════════════════════════════════ */
.insite-answer-area {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insite-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.insite-abtn {
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1.5px solid #d0d8e0;
  background: #fff;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  -webkit-user-select: none;
}

.insite-abtn:hover {
  border-color: #0f3460;
  background: #f0f4ff;
  color: #0f3460;
}

.insite-abtn.selected {
  border-color: #0f3460;
  background: #0f3460;
  color: #fff;
}

/* Ja/Nee variants */
.insite-abtn.yes {
  border-color: #22c55e;
  color: #15803d;
}

.insite-abtn.yes:hover,
.insite-abtn.yes.selected {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
}

.insite-abtn.no {
  border-color: #ef4444;
  color: #dc2626;
}

.insite-abtn.no:hover,
.insite-abtn.no.selected {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* Action buttons (wireframe bekijken, JSON export) */
.insite-abtn.action {
  background: linear-gradient(135deg, #0f3460, #1a5276);
  color: #fff;
  border-color: #0f3460;
  font-weight: 700;
}

.insite-abtn.action:hover {
  box-shadow: 0 4px 12px rgba(15, 52, 96, 0.3);
  transform: translateY(-1px);
}

/* Confirm button */
.insite-confirm-btn {
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #0f3460, #1a5276);
  color: #fff;
  align-self: flex-end;
  transition: all 0.15s ease;
  display: none;
}

.insite-confirm-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(15, 52, 96, 0.3);
}

.insite-confirm-btn.show {
  display: block;
}

/* ═══════════════════════════════════════════════════════
   WIREFRAME OVERLAY
   ═══════════════════════════════════════════════════════ */
.insite-wf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.insite-wf-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.insite-wf-panel {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  padding: 0;
}

.insite-wf-panel::-webkit-scrollbar {
  width: 6px;
}

.insite-wf-panel::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

/* Panel header */
.insite-wf-panel-header {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 20px 24px 12px;
  border-bottom: 1px solid #eee;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.insite-wf-panel-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #0f3460;
  margin: 0;
}

.insite-wf-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  border: none;
  transition: background 0.15s ease;
}

.insite-wf-close:hover {
  background: #e0e0e0;
}

/* Panel body */
.insite-wf-panel-body {
  padding: 20px 24px 24px;
}

/* ── Stats ── */
.insite-wf-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.insite-wf-stat {
  background: #f8f9fb;
  border-radius: 8px;
  padding: 12px 16px;
  flex: 1;
  text-align: center;
}

.insite-wf-stat .sv {
  font-size: 22px;
  font-weight: 700;
  color: #0f3460;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.insite-wf-stat .sl {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

/* ── Portal cards ── */
.insite-wf-portal {
  border: 1.5px solid #e8ecf0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  transition: border-color 0.15s ease;
}

.insite-wf-portal:hover {
  border-color: #c0c8d0;
}

.insite-wf-portal h3 {
  font-size: 14px;
  font-weight: 700;
  color: #0f3460;
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Zones ── */
.insite-wf-zone {
  margin-bottom: 10px;
}

.insite-wf-zone:last-child {
  margin-bottom: 0;
}

.insite-wf-zone-label {
  font-size: 9px;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.insite-wf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Widget cards ── */
.insite-wf-w {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.insite-wf-w:hover {
  border-color: #c0c0c0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Color bar top */
.insite-wf-w::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.insite-wf-w.t-snelkoppeling::before { background: #3b82f6; }
.insite-wf-w.t-overzicht::before    { background: #8b5cf6; }
.insite-wf-w.t-tegel::before        { background: #f59e0b; }

/* Width variants */
.insite-wf-w.b-smal  { width: calc(33.333% - 4px); min-width: 100px; }
.insite-wf-w.b-breed { width: calc(50% - 3px);     min-width: 140px; }
.insite-wf-w.b-vol   { width: 100%; }

/* Widget content */
.insite-wf-w .wn {
  font-size: 11px;
  font-weight: 700;
  color: #1a1a2e;
}

.insite-wf-w .wt {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 3px;
}

.insite-wf-w .wt.t-snelkoppeling { background: #dbeafe; color: #1d4ed8; }
.insite-wf-w .wt.t-overzicht     { background: #ede9fe; color: #6d28d9; }
.insite-wf-w .wt.t-tegel         { background: #fef3c7; color: #b45309; }

.insite-wf-w .wd {
  font-size: 9px;
  color: #999;
  margin-top: 2px;
}

/* Placeholder lines (skeleton) */
.insite-wf-ph {
  height: 5px;
  background: #f0f0f0;
  border-radius: 3px;
  margin: 2px 0;
}

/* ── Tabgroups ── */
.insite-wf-tg {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.insite-wf-tg .tg-tabs {
  display: flex;
  background: #f8f9fb;
  border-bottom: 1px solid #e0e0e0;
  overflow-x: auto;
}

.insite-wf-tg .tg-tabs span {
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 600;
  color: #888;
  white-space: nowrap;
  cursor: default;
}

.insite-wf-tg .tg-tabs span.active {
  color: #0f3460;
  background: #fff;
  border-bottom: 2px solid #0f3460;
}

.insite-wf-tg .tg-body {
  padding: 10px;
}

.insite-wf-tg .tg-body .tw {
  font-size: 11px;
  font-weight: 600;
  color: #1a1a2e;
}

.insite-wf-tg .tg-body .td {
  font-size: 9px;
  color: #999;
  margin-bottom: 4px;
}

/* ── Legend ── */
.insite-wf-legend {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #eee;
  margin-top: 8px;
}

.insite-wf-legend-i {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: #888;
}

.insite-wf-legend-i .d {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── JSON export block ── */
.insite-wf-json-toggle {
  margin-top: 12px;
}

.insite-wf-json-toggle summary {
  font-size: 11px;
  font-weight: 600;
  color: #0f3460;
  cursor: pointer;
  padding: 8px 0;
  user-select: none;
}

.insite-wf-json-toggle summary:hover {
  text-decoration: underline;
}

.insite-wf-json-block {
  background: #1a1a2e;
  color: #a8d8a8;
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 10px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 768px) {
  .insite-chat-window {
    width: 360px;
  }

  .insite-wf-panel {
    width: 95%;
    max-height: 90vh;
  }

  .insite-wf-stats {
    gap: 8px;
  }

  .insite-wf-stat {
    padding: 10px 12px;
  }

  .insite-wf-stat .sv {
    font-size: 18px;
  }
}

/* Mobile */
@media (max-width: 500px) {
  #insite-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }

  .insite-chat-window {
    width: calc(100% - 16px);
    right: 8px;
    bottom: 80px;
    max-height: 70vh;
    border-radius: 12px;
  }

  .insite-chat-header {
    padding: 12px 16px;
  }

  .insite-chat-body {
    max-height: 280px;
    padding: 12px;
  }

  .insite-msg {
    max-width: 90%;
    font-size: 12px;
  }

  .insite-answer-area {
    padding: 10px 12px;
  }

  .insite-abtn {
    padding: 7px 11px;
    font-size: 11px;
  }

  .insite-wf-panel {
    width: 100%;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
    position: fixed;
    bottom: 0;
  }

  .insite-wf-w.b-smal,
  .insite-wf-w.b-breed {
    width: 100%;
  }

  .insite-wf-stats {
    flex-direction: column;
    gap: 6px;
  }
}

/* ═══════════════════════════════════════════════════════
   PRINT STYLES (voor wireframe export)
   ═══════════════════════════════════════════════════════ */
@media print {
  #insite-fab,
  .insite-chat-window,
  .insite-chat-close,
  .insite-wf-close,
  .insite-wf-json-toggle {
    display: none !important;
  }

  .insite-wf-overlay {
    position: static;
    background: none;
    opacity: 1;
    pointer-events: all;
  }

  .insite-wf-panel {
    width: 100%;
    max-width: 100%;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
  }

  .insite-wf-portal {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
</style>

