@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;700;900&family=Blinker:wght@300;400;600&display=swap');

:root {
  --mag-orange:     #F26722;
  --mag-orange-mid: #F89826;
  --mag-dark:       #101212;
  --mag-dark-2:     #1a1c1c;
  --mag-dark-3:     #252828;
  --mag-gray:       #353535;
  --mag-light:      #e5e5e5;
  --mag-white:      #ffffff;
  --mag-radius:     16px;
  --mag-radius-sm:  10px;
  --mag-shadow:     0 8px 40px rgba(0,0,0,0.4);
  --mag-font:       'Red Hat Display', 'Segoe UI', sans-serif;
  --mag-font-body:  'Blinker', 'Segoe UI', sans-serif;
}

/* ── Widget ── */
#magnetar-chat-widget {
  position: fixed !important; bottom: 24px; right: 24px;
  z-index: 2147483647 !important; /* max 32-bit z-index: wint altijd, ook van homepage-only overlays/CTA-balken */
  font-family: var(--mag-font-body);
  pointer-events: auto !important;
}

/* ── Toggle button ── */
#magnetar-chat-toggle {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  border: none; cursor: pointer !important;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(242,103,34,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  pointer-events: auto !important;
}
#magnetar-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(242,103,34,0.65); }
#magnetar-chat-toggle svg { width: 26px; height: 26px; pointer-events: none; }

#magnetar-chat-badge {
  position: absolute; top: -4px; right: -4px;
  background: #e5252a; color: white; font-size: 11px; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

/* ── Chat window ── */
#magnetar-chat-window {
  position: absolute; bottom: 74px; right: 0; width: 370px;
  display: flex; flex-direction: column;
  background: var(--mag-dark-2);
  border-radius: var(--mag-radius);
  box-shadow: var(--mag-shadow);
  overflow: hidden;
  animation: mag-slide-up 0.25s ease;
  border: 1px solid rgba(255,255,255,0.07);
}
#magnetar-chat-window[hidden] { display: none; }

@keyframes mag-slide-up {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
#magnetar-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--mag-dark) 0%, #1e2020 100%);
  border-bottom: 2px solid var(--mag-orange);
  flex-shrink: 0;
}
#magnetar-chat-header-left { display: flex; align-items: center; gap: 10px; }
#magnetar-chat-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#magnetar-chat-name { font-family: var(--mag-font); font-weight: 700; color: #fff; font-size: 15px; }
#magnetar-chat-status { font-size: 11px; color: #8cca8c; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.status-dot { width: 7px; height: 7px; background: #4caf50; border-radius: 50%; display: inline-block; animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

#magnetar-chat-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: color .2s, background .2s; line-height: 1;
}
#magnetar-chat-close:hover { color: white; background: rgba(255,255,255,.1); }

/* ── Quick action bars (boven + onder) ── */
.mag-quick-bar {
  display: flex; gap: 6px; padding: 8px 12px; flex-wrap: wrap; flex-shrink: 0;
  background: rgba(0,0,0,.25);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.mag-quick-bar.bottom {
  border-bottom: none;
  border-top: 1px solid rgba(255,255,255,.06);
  padding-top: 8px; padding-bottom: 8px;
}
#magnetar-chat-widget .magnetar-quick-btn,
#magnetar-chat-widget .magnetar-quick-btn:visited {
  background: #F26722 !important;
  border: 1px solid #F26722 !important;
  color: #ffffff !important;
  border-radius: 20px !important; padding: 5px 12px !important;
  font-size: 11.5px !important; font-weight: 700 !important;
  font-family: var(--mag-font-body) !important;
  cursor: pointer !important; white-space: nowrap !important;
  transition: background .2s, opacity .2s !important;
  box-shadow: none !important; text-decoration: none !important;
}
#magnetar-chat-widget .magnetar-quick-btn:hover {
  background: #d4581a !important;
  border-color: #d4581a !important;
  color: #fff !important;
}

/* ── Form titels wit ── */
#magnetar-chat-widget .mag-order-form h4,
#magnetar-chat-widget .mag-contact-form h4 {
  color: #ffffff !important;
}

/* ── Messages ── */
#magnetar-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth; min-height: 180px; max-height: 300px;
}
#magnetar-chat-messages::-webkit-scrollbar { width: 4px; }
#magnetar-chat-messages::-webkit-scrollbar-thumb { background: var(--mag-gray); border-radius: 4px; }

.mag-message { display: flex; gap: 8px; animation: mag-msg-in .2s ease; }
@keyframes mag-msg-in { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }
.mag-message.user { flex-direction: row-reverse; }

.mag-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; font-family: var(--mag-font-body);
}
.mag-message.bot .mag-bubble {
  background: var(--mag-dark-3); color: #e8e8e8;
  border-bottom-left-radius: 4px; border: 1px solid rgba(255,255,255,.08);
}
.mag-message.user .mag-bubble {
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  color: #fff; border-bottom-right-radius: 4px; font-weight: 500;
}

/* Klikbare links in lopende AI-tekst (via linkify) */
#magnetar-chat-widget .mag-bubble .mag-text-link {
  color: #F26722 !important;
  text-decoration: underline !important;
  word-break: break-all !important;
  cursor: pointer !important;
}
#magnetar-chat-widget .mag-bubble .mag-text-link:hover {
  color: #ffffff !important;
}

/* Typing dots */
.mag-typing .mag-bubble { display: flex; align-items: center; gap: 5px; padding: 12px 16px; }
.mag-typing-dot { width: 7px; height: 7px; background: var(--mag-orange); border-radius: 50%; animation: mag-bounce 1.2s infinite; }
.mag-typing-dot:nth-child(2){animation-delay:.2s} .mag-typing-dot:nth-child(3){animation-delay:.4s}
@keyframes mag-bounce { 0%,80%,100%{transform:scale(.7);opacity:.5} 40%{transform:scale(1);opacity:1} }

/* ── Order card — hoog contrast ── */
.mag-order-card {
  background: #1c1e1e;
  border: 1px solid rgba(242,103,34,.55);
  border-radius: var(--mag-radius-sm);
  padding: 14px; margin-top: 8px;
}
.mag-order-card h4 {
  font-family: var(--mag-font); font-weight: 700;
  color: var(--mag-orange); margin: 0 0 10px; font-size: 15px;
}
.mag-order-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.1);
  color: #ffffff; font-size: 13px;
}
.mag-order-row:last-child { border-bottom: none; }
.mag-order-label {
  color: #b0b3b3; font-size: 11.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
#magnetar-chat-widget .mag-tracking-btn {
  display: inline-block !important; margin-top: 10px !important; padding: 7px 14px !important;
  background: #F26722 !important; color: #FFFFFF !important;
  border: 1px solid #F26722 !important;
  border-radius: 6px !important; font-size: 12px !important; font-weight: 600 !important;
  text-decoration: none !important; transition: opacity .2s !important;
}
#magnetar-chat-widget .mag-tracking-btn:hover { opacity: .85 !important; color: #FFFFFF !important; }

/* ── Order lookup form ── */
.mag-order-form {
  background: #1c1e1e; border: 1px solid rgba(242,103,34,.3);
  border-radius: var(--mag-radius-sm); padding: 14px;
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
}
.mag-order-form h4 { font-family: var(--mag-font); font-weight: 700; color: #ffffff; margin: 0 0 4px; font-size: 14px; }
.mag-order-form input {
  background: var(--mag-dark-3); border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px; padding: 9px 11px; color: #fff;
  font-size: 13px; font-family: var(--mag-font-body);
  width: 100%; box-sizing: border-box; outline: none; transition: border-color .2s;
}
.mag-order-form input:focus { border-color: var(--mag-orange); }
.mag-order-form input::placeholder { color: rgba(255,255,255,.35); }
.mag-order-form button {
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  color: #fff; border: none; border-radius: 7px;
  padding: 9px 14px; font-size: 13px; font-weight: 700;
  font-family: var(--mag-font); cursor: pointer; transition: opacity .2s;
}
.mag-order-form button:hover { opacity: .9; }
.mag-order-form button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Contact form ── */
.mag-contact-form {
  background: #1c1e1e; border: 1px solid rgba(242,103,34,.3);
  border-radius: var(--mag-radius-sm); padding: 14px;
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
}
.mag-contact-form h4 { font-family: var(--mag-font); font-weight: 700; color: #ffffff; margin: 0 0 4px; font-size: 14px; }
.mag-contact-note { color: #b9bcbc; font-size: 12px; margin: 0 0 10px; line-height: 1.4; }
.mag-contact-form input,
.mag-contact-form textarea {
  background: var(--mag-dark-3); border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px; padding: 9px 11px; color: #fff;
  font-size: 13px; font-family: var(--mag-font-body);
  width: 100%; box-sizing: border-box; outline: none; transition: border-color .2s;
}
.mag-contact-form input:focus,
.mag-contact-form textarea:focus { border-color: var(--mag-orange); }
.mag-contact-form input::placeholder,
.mag-contact-form textarea::placeholder { color: rgba(255,255,255,.35); }
.mag-contact-form textarea { resize: none; height: 70px; }
.mag-contact-form button {
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  color: #fff; border: none; border-radius: 7px;
  padding: 9px 14px; font-size: 13px; font-weight: 700;
  font-family: var(--mag-font); cursor: pointer; transition: opacity .2s, transform .1s;
}
.mag-contact-form button:hover { opacity: .9; transform: translateY(-1px); }
.mag-contact-form button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Alerts ── */
.mag-alert { padding: 8px 12px; border-radius: 7px; font-size: 13px; margin-top: 6px; }
.mag-alert-success { background: rgba(242,103,34,.15); border: 1px solid rgba(242,103,34,.4); color: #f5a57a; }
.mag-alert-error   { background: rgba(244,67,54,.15);  border: 1px solid rgba(244,67,54,.3);  color: #f08080; }

/* ── Input area ── */
#magnetar-chat-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0; background: var(--mag-dark-2);
}
#magnetar-chat-input {
  flex: 1; background: var(--mag-dark-3);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; padding: 9px 12px;
  color: #fff; font-size: 13.5px; font-family: var(--mag-font-body);
  resize: none; outline: none; transition: border-color .2s;
  max-height: 100px; overflow-y: auto; line-height: 1.4;
}
#magnetar-chat-input:focus { border-color: var(--mag-orange); }
#magnetar-chat-input::placeholder { color: rgba(255,255,255,.3); }

#magnetar-chat-send {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--mag-orange), var(--mag-orange-mid));
  border: none; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .2s;
}
#magnetar-chat-send:hover { transform: scale(1.05); }
#magnetar-chat-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
#magnetar-chat-send svg { width: 16px; height: 16px; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #magnetar-chat-widget {
    bottom: 16px; right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  /* Venster vult vrijwel het hele scherm zodat niets buiten beeld valt */
  #magnetar-chat-window {
    position: fixed;
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
    bottom: 84px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    top: 12px;
    top: calc(12px + env(safe-area-inset-top));
    max-height: none;
  }

  /* Berichtenlijst groeit mee met de beschikbare ruimte i.p.v. vaste 300px */
  #magnetar-chat-messages {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }

  /* 16px voorkomt dat iOS Safari inzoomt bij focus op het invoerveld */
  #magnetar-chat-input {
    font-size: 16px;
  }

  /* Iets ruimere tikdoelen voor knoppen op touchscreens */
  #magnetar-chat-widget .mag-menu-btn {
    padding: 12px 14px !important;
  }
  #magnetar-chat-widget .magnetar-quick-btn {
    padding: 7px 13px !important;
  }
}



/* ── Form titels wit ── */
#magnetar-chat-widget .mag-order-form h4,
#magnetar-chat-widget .mag-contact-form h4 {
  color: #ffffff !important;
}

/* ── Keuzemenu grid ── */
.mag-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}

#magnetar-chat-widget .mag-menu-btn {
  background: var(--mag-orange) !important;
  border: 1px solid var(--mag-orange) !important;
  color: #ffffff !important;
  border-radius: 9px !important;
  padding: 9px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  font-family: var(--mag-font-body) !important;
  cursor: pointer !important;
  text-align: left !important;
  transition: background .15s, border-color .15s, opacity .15s !important;
  width: 100% !important;
  box-shadow: none !important;
}

#magnetar-chat-widget .mag-menu-btn:hover:not(:disabled) {
  background: #d4581a !important;
  border-color: #d4581a !important;
  color: #fff !important;
  opacity: 1 !important;
}

#magnetar-chat-widget .mag-menu-btn:disabled {
  cursor: default !important;
}

#magnetar-chat-widget .mag-product-btn {
  display: block !important;
  margin-top: 8px !important;
  padding: 10px 14px !important;
  background: #F26722 !important;
  color: #FFFFFF !important;
  border: 1px solid #F26722 !important;
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  font-family: var(--mag-font-body) !important;
  text-align: center !important;
  text-decoration: none !important;
  transition: background .2s, transform .1s !important;
}

#magnetar-chat-widget .mag-product-btn:hover {
  background: #d9551a !important;
  color: #FFFFFF !important;
  transform: translateY(-1px);
}
