/* ==========================================================
   Smart Contact Widget — Frontend Styles  (v1.1.0)
========================================================== */

:root {
  --scw-color:       #2563eb;
  --scw-color-dark:  #1d4ed8;
  --scw-color-light: #dbeafe;
  --scw-wa-green:    #25d366;
  --scw-wa-dark:     #128c7e;
  --scw-radius:      16px;
  --scw-shadow:      0 25px 60px rgba(0,0,0,.22), 0 8px 20px rgba(0,0,0,.14);
  --scw-glass:       rgba(255,255,255,.94);
  --scw-blur:        blur(20px);
  --scw-transition:  cubic-bezier(.34,1.56,.64,1);
  --scw-easing:      cubic-bezier(.4,0,.2,1);
  --scw-font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------------------------------------------------------
   Launcher
--------------------------------------------------------- */
#scw-root { position: static; }

.scw-launcher {
  position: fixed;
  z-index: 99990;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.scw-launcher.scw-pos-left { right: auto; left: 24px; flex-direction: row-reverse; }

.scw-launcher:focus-visible .scw-launcher-circle {
  outline: 3px solid var(--scw-color);
  outline-offset: 4px;
}

.scw-launcher-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--scw-color);
  opacity: .18;
  animation: scw-pulse 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scw-pulse {
  0%, 100% { transform: scale(1);    opacity: .18; }
  50%      { transform: scale(1.35); opacity: 0; }
}

.scw-launcher-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--scw-color);
  box-shadow: 0 6px 24px rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .3s var(--scw-transition), box-shadow .3s var(--scw-easing);
  position: relative;
  flex-shrink: 0;
}
.scw-launcher:hover .scw-launcher-circle,
.scw-launcher:focus .scw-launcher-circle { transform: scale(1.08); }

.scw-launcher.is-open .scw-launcher-circle { background: #ef4444; }

.scw-launcher-icon {
  width: 26px; height: 26px;
  fill: #fff;
  transition: transform .4s var(--scw-transition), opacity .2s;
}
.scw-launcher-icon svg { width: 100%; height: 100%; fill: #fff; }
.scw-launcher-icon-open { position: absolute; opacity: 0; transform: rotate(-90deg) scale(.5); }
.scw-launcher.is-open .scw-launcher-icon-main { opacity: 0; transform: rotate(90deg) scale(.5); }
.scw-launcher.is-open .scw-launcher-icon-open { opacity: 1; transform: rotate(0) scale(1); }

.scw-launcher-label {
  background: var(--scw-color);
  color: #fff;
  font: 600 13px/1 var(--scw-font);
  padding: 8px 14px;
  border-radius: 20px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  white-space: nowrap;
  transition: transform .3s var(--scw-transition), opacity .3s;
  pointer-events: none;
}
.scw-launcher.is-open .scw-launcher-label { opacity: 0; transform: translateX(6px); }

/* ---------------------------------------------------------
   Popup
--------------------------------------------------------- */
.scw-popup {
  position: fixed;
  z-index: 99989;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--scw-glass);
  backdrop-filter: var(--scw-blur);
  -webkit-backdrop-filter: var(--scw-blur);
  border-radius: var(--scw-radius);
  box-shadow: var(--scw-shadow);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s var(--scw-easing), visibility .25s, transform .3s var(--scw-transition);
  font-family: var(--scw-font);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 130px);
}

.scw-popup.scw-pos-corner-right { bottom: 96px; right: 24px; transform-origin: bottom right; transform: scale(.92) translateY(12px); }
.scw-popup.scw-pos-corner-left  { bottom: 96px; left:  24px; transform-origin: bottom left;  transform: scale(.92) translateY(12px); }
.scw-popup.scw-pos-center       { top: 50%; left: 50%; transform: translate(-50%,-46%); transform-origin: center; max-height: calc(100vh - 48px); }
.scw-popup.scw-pos-side-right   { right: 0; top: 0; bottom: 0; height: 100%; max-height: 100%; width: 360px; border-radius: var(--scw-radius) 0 0 var(--scw-radius); transform: translateX(110%); }
.scw-popup.scw-pos-side-left    { left:  0; top: 0; bottom: 0; height: 100%; max-height: 100%; width: 360px; border-radius: 0 var(--scw-radius) var(--scw-radius) 0; transform: translateX(-110%); }

.scw-popup.is-open { opacity: 1; visibility: visible; }
.scw-popup.is-open.scw-pos-corner-right,
.scw-popup.is-open.scw-pos-corner-left { transform: scale(1) translateY(0); }
.scw-popup.is-open.scw-pos-center      { transform: translate(-50%,-50%); }
.scw-popup.is-open.scw-pos-side-right,
.scw-popup.is-open.scw-pos-side-left   { transform: translateX(0); }

.scw-overlay {
  position: fixed; inset: 0; z-index: 99988;
  background: rgba(0,0,0,.35);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.scw-overlay.is-open { opacity: 1; visibility: visible; }

/* Header */
.scw-popup-header {
  background: linear-gradient(135deg, var(--scw-color) 0%, var(--scw-color-dark) 100%);
  padding: 18px 18px 0;
  color: #fff;
  flex-shrink: 0;
}
.scw-popup-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.scw-popup-header h3 {
  margin: 0;
  font: 700 16px/1.3 var(--scw-font);
  letter-spacing: -.01em;
  color: #fff;
}
.scw-close-btn {
  background: transparent;
  border: none;
  padding: 4px;
  width: 32px; height: 32px;
  cursor: pointer;
  color: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.scw-close-btn svg { width: 20px; height: 20px; fill: currentColor; }
.scw-close-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.scw-close-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Tabs */
.scw-tabs { display: flex; gap: 4px; }
.scw-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 12px;
  cursor: pointer;
  border: none;
  background: rgba(255,255,255,.15);
  border-radius: 10px 10px 0 0;
  color: rgba(255,255,255,.8);
  font: 600 11px/1 var(--scw-font);
  transition: background .2s, color .2s;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.scw-tab:hover  { background: rgba(255,255,255,.24); color: #fff; }
.scw-tab.active { background: #fff; color: var(--scw-color); box-shadow: 0 -2px 12px rgba(0,0,0,.08); }
.scw-tab:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.scw-tab-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.scw-tab-icon svg { width: 22px; height: 22px; fill: currentColor; }

/* Panels — przewijalne, gdy treść nie mieści się w oknie przeglądarki */
.scw-panels {
  background: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}
.scw-panel { display: none; padding: 20px; animation: scw-fadein .2s var(--scw-easing); }
.scw-panel.active { display: block; }
@keyframes scw-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------
   Godziny dostępności
--------------------------------------------------------- */
.scw-availability-hours {
  background: rgba(0,0,0,.03);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 16px 20px 0;
  font: 400 12px/1.45 var(--scw-font);
  color: #4b5563;
}
.scw-hours-title { font-weight: 700; margin-bottom: 5px; color: #1f2937; }
.scw-hours-title::before { content: '🕒'; margin-right: 5px; }
.scw-hours-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.scw-hours-row strong { color: #111; font-weight: 600; }
.scw-hours-notice {
  font-style: italic;
  border-top: 1px solid rgba(0,0,0,.07);
  padding-top: 5px;
  margin-top: 5px;
  color: #6b7280;
  font-size: 11px;
}

/* ---------------------------------------------------------
   Panele kanałów
--------------------------------------------------------- */
.scw-channel-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 0;
}
.scw-hero-left { align-items: flex-start; text-align: left; }
.scw-hero-row  { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; width: 100%; }

.scw-channel-icon-big {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.scw-icon-sm { width: 44px; height: 44px; margin: 0; }
.scw-icon-sm svg { width: 24px; height: 24px; }
.scw-channel-icon-big svg { width: 34px; height: 34px; fill: #fff; }
.scw-icon-wa    { background: linear-gradient(135deg, #25d366, #128c7e); box-shadow: 0 6px 20px rgba(37,211,102,.35); }
.scw-icon-phone { background: linear-gradient(135deg, #0d9488, #0f766e); box-shadow: 0 6px 20px rgba(13,148,136,.35); }
.scw-icon-mail  { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 6px 20px rgba(99,102,241,.35); }

.scw-channel-title { font: 700 17px/1.25 var(--scw-font); color: #111; margin-bottom: 6px; }
.scw-channel-desc  { font: 400 13px/1.5 var(--scw-font); color: #6b7280; margin-bottom: 20px; }
.scw-title-tight   { margin: 0 0 2px; }
.scw-desc-tight    { margin: 0; }

.scw-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 13px 20px;
  border: none; border-radius: 12px;
  font: 700 14px/1 var(--scw-font);
  cursor: pointer;
  transition: transform .2s var(--scw-transition), box-shadow .2s, opacity .2s;
  color: #fff;
  text-decoration: none;
  box-sizing: border-box;
  position: relative;
}
.scw-btn:hover:not(:disabled)  { transform: translateY(-2px); }
.scw-btn:active:not(:disabled) { transform: translateY(0); }
.scw-btn:disabled { opacity: .55; cursor: not-allowed; }
.scw-btn:focus-visible { outline: 3px solid var(--scw-color); outline-offset: 2px; }
.scw-btn svg { width: 18px; height: 18px; fill: #fff; flex-shrink: 0; }

.scw-btn-wa       { background: linear-gradient(135deg, #25d366, #128c7e); box-shadow: 0 4px 14px rgba(37,211,102,.35); }
.scw-btn-phone    { background: linear-gradient(135deg, #0d9488, #0f766e); box-shadow: 0 4px 14px rgba(13,148,136,.35); }
.scw-btn-send     { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.scw-btn-callback { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 14px rgba(245,158,11,.35); }

.scw-divider {
  display: flex; align-items: center; gap: 10px;
  color: #9ca3af;
  font: 400 12px/1.3 var(--scw-font);
  margin: 16px 0 12px;
  width: 100%;
  text-align: center;
}
.scw-divider::before, .scw-divider::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }

.scw-phone-direct {
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  font: 400 13px/1.4 var(--scw-font);
  color: #6b7280;
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
}
.scw-phone-direct strong { display: block; font-size: 18px; color: #111; letter-spacing: .02em; margin-top: 4px; }
.scw-tel-link { color: var(--scw-color); text-decoration: none; }
.scw-tel-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------
   Formularze
--------------------------------------------------------- */
.scw-form { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.scw-form-full { width: 100%; }

.scw-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.scw-field-label {
  display: block;
  font: 600 12px/1.2 var(--scw-font);
  color: #4b5563;
  margin-bottom: 4px;
  text-align: left;
  letter-spacing: .02em;
}

.scw-input,
.scw-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font: 400 16px/1.4 var(--scw-font);  /* 16px zapobiega auto-zoomowi na iOS */
  color: #111;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
  outline: none;
  -webkit-appearance: none;
}
.scw-input:focus,
.scw-textarea:focus {
  border-color: var(--scw-color);
  box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}
.scw-textarea { resize: vertical; min-height: 88px; }

/* Captcha – checkbox */
.scw-captcha {
  display: flex; align-items: center; gap: 10px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  user-select: none;
  margin: 4px 0 8px;
}
.scw-captcha:hover { border-color: var(--scw-color); }
.scw-captcha:focus-visible { outline: 3px solid var(--scw-color); outline-offset: 2px; }
.scw-captcha.checked { border-color: #22c55e; background: #f0fdf4; }
.scw-captcha-box {
  width: 22px; height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
}
.scw-captcha.checked .scw-captcha-box { background: #22c55e; border-color: #22c55e; }
.scw-captcha-box svg { width: 14px; height: 14px; fill: #fff; opacity: 0; transition: opacity .2s; }
.scw-captcha.checked .scw-captcha-box svg { opacity: 1; }
.scw-captcha-label { font: 400 13px/1.3 var(--scw-font); color: #374151; }

/* Captcha – zadanie matematyczne */
.scw-captcha-math {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 4px 0 8px;
}
.scw-math-question {
  font: 700 15px/1 var(--scw-font);
  color: #374151;
  white-space: nowrap;
}
.scw-math-input {
  width: 84px !important;
  text-align: center;
  padding: 8px 6px !important;
  margin: 0;
}

/* Komunikaty */
.scw-message {
  padding: 10px 14px;
  border-radius: 10px;
  font: 400 13px/1.4 var(--scw-font);
  display: none;
  margin: 4px 0 8px;
}
.scw-message.show { display: block; }
.scw-msg-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.scw-msg-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Pola opcjonalne */
.scw-optional-toggle {
  font: 400 12px/1.3 var(--scw-font);
  color: var(--scw-color);
  cursor: pointer;
  background: none; border: none;
  padding: 2px 0;
  margin-bottom: 10px;
  text-decoration: underline;
  text-underline-offset: 2px;
  align-self: flex-start;
}
.scw-optional-fields { display: none; flex-direction: column; }
.scw-optional-fields.show { display: flex; }

/* Spinner */
.scw-spinner {
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: scw-spin .7s linear infinite;
  display: none;
}
.scw-loading .scw-spinner { display: block; }
.scw-loading .scw-btn-text { opacity: 0; }
@keyframes scw-spin { to { transform: rotate(360deg); } }

/* RODO */
.scw-gdpr-row { margin: 4px 0 10px; }
.scw-gdpr-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font: 400 12px/1.45 var(--scw-font);
  color: #6b7280;
  cursor: pointer;
  text-align: left;
}
.scw-gdpr-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--scw-color);
  width: 16px; height: 16px;
  cursor: pointer;
}
.scw-gdpr-label a { color: var(--scw-color); text-decoration: underline; }
.scw-gdpr-label a:hover { text-decoration: none; }

/* Stopka */
.scw-popup-footer {
  background: #f9fafb;
  border-top: 1px solid #f0f0f0;
  padding: 10px 20px;
  text-align: center;
  font: 400 11px/1.3 var(--scw-font);
  color: #9ca3af;
  flex-shrink: 0;
}

/* ---------------------------------------------------------
   Honeypot – niewidoczny dla człowieka, widoczny dla bota
--------------------------------------------------------- */
.scw-honeypot {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---------------------------------------------------------
   Responsywność
--------------------------------------------------------- */
@media (max-width: 480px) {
  .scw-launcher { bottom: 16px; right: 16px; }
  .scw-launcher.scw-pos-left { left: 16px; right: auto; }
  .scw-popup { width: calc(100vw - 24px); max-height: calc(100vh - 110px); }
  .scw-popup.scw-pos-corner-right { right: 12px; bottom: 88px; }
  .scw-popup.scw-pos-corner-left  { left:  12px; bottom: 88px; }
  .scw-popup.scw-pos-side-right,
  .scw-popup.scw-pos-side-left    { width: 100vw; max-width: 100vw; }
  .scw-launcher-label { display: none; }
}

/* Widoczność zależna od urządzenia (ustawienia w panelu admina) */
@media (max-width: 767px) {
  #scw-root.scw-hide-mobile { display: none !important; }
  #scw-root.scw-hide-mobile ~ .scw-overlay { display: none !important; }
}
@media (min-width: 768px) {
  #scw-root.scw-hide-desktop { display: none !important; }
  #scw-root.scw-hide-desktop ~ .scw-overlay { display: none !important; }
}

/* ---------------------------------------------------------
   Tryb ciemny
--------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .scw-popup   { background: rgba(18,18,28,.94); border-color: rgba(255,255,255,.1); }
  .scw-panels  { background: #12121c; }
  .scw-tab.active { background: #12121c; color: #fff; }
  .scw-channel-title { color: #f3f4f6; }
  .scw-channel-desc  { color: #9ca3af; }
  .scw-input, .scw-textarea { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.14); color: #f3f4f6; }
  .scw-captcha, .scw-captcha-math { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); }
  .scw-captcha-label, .scw-math-question { color: #d1d5db; }
  .scw-phone-direct { background: rgba(255,255,255,.05); }
  .scw-phone-direct strong { color: #f3f4f6; }
  .scw-availability-hours { background: rgba(255,255,255,.05); color: #9ca3af; }
  .scw-hours-title, .scw-hours-row strong { color: #f3f4f6; }
  .scw-popup-footer { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.08); }
  .scw-field-label { color: #9ca3af; }
  .scw-divider::before, .scw-divider::after { background: rgba(255,255,255,.12); }
  .scw-msg-success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); color: #86efac; }
  .scw-msg-error   { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); color: #fca5a5; }
}

/* ---------------------------------------------------------
   Ograniczenie animacji (migreny, epilepsja, preferencje systemowe)
--------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .scw-launcher-ring { animation: none; opacity: .12; }
  .scw-launcher-circle,
  .scw-launcher-icon,
  .scw-launcher-label,
  .scw-popup,
  .scw-btn,
  .scw-tab,
  .scw-input,
  .scw-textarea,
  .scw-captcha,
  .scw-close-btn { transition: none !important; }
  .scw-panel { animation: none !important; }
  .scw-spinner { animation-duration: 1.6s; }
  .scw-popup.scw-pos-corner-right,
  .scw-popup.scw-pos-corner-left,
  .scw-popup.scw-pos-side-right,
  .scw-popup.scw-pos-side-left { transform: none; }
  .scw-popup.scw-pos-center    { transform: translate(-50%,-50%); }
}

/* Wysoki kontrast */
@media (forced-colors: active) {
  .scw-popup, .scw-captcha, .scw-input, .scw-textarea { border: 1px solid CanvasText; }
}
