/* === 321x.pl – Patches (nie modyfikuj starego style.css, wczytaj ten plik po nim) === */

/* =========================================================
   1) MODALE – close / okno
   ========================================================= */

/* Ujednolicone, estetyczne "X" do zamykania modali i okienek */
.modal-close {
  --btn-size: 34px;
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--btn-size);
  height: var(--btn-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: #334155; /* slate-700 */
  transition: transform .12s ease, box-shadow .12s ease, color .12s ease, background .12s ease;
}
.modal-close:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  color: #0f172a; /* slate-900 */
  background: #f8fafc; /* slate-50 */
}
.modal-close:active {
  transform: scale(0.96);
}

/* Delikatne zaokrąglenie i cień dla okna modala */
.modal-window {
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(2,6,23,.18);
  background: #fff;
}

/* =========================================================
   2) OBRAZKI / KARTY – spójne miniatury
   ========================================================= */

.products-grid img,
.product-card img,
.card img,
.gallery-grid img,
.product-modal-img {
  width: 100% !important;
  height: auto;
  max-width: 100%;
  max-height: 90vh;

  aspect-ratio: auto;        /* ❗ NIE wymuszamy kadru */
  object-fit: contain;       /* ❗ NIC NIE UCINAMY */
  object-position: center;

  display: block;
  background: #fff;
  border-radius: 12px;
}

.product-card,
.products-grid .card {
  display: flex;
  flex-direction: column;
}
.products-grid .card .card-body,
.product-card .card-body {
  margin-top: .5rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Stopka modala produktu – lepsze układanie */
.product-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
}
.product-modal-footer > button {
  flex: 0 1 220px;
  min-width: 180px;
}

/* =========================================================
   3) COOKIE CONSENT — zawsze na wierzchu
   ========================================================= */

.modal-backdrop.consent {
  position: fixed;
  inset: 0;
  z-index: 20000 !important;
}
.modal-backdrop.consent .modal-window {
  position: relative;
  z-index: 20001 !important;
}
body.consent-blocked .modal-backdrop.consent,
body.consent-blocked .modal-backdrop.consent * {
  pointer-events: auto !important;
  opacity: 1 !important;
}

/* Kontakt dropdown */
.pm__btn-primary + div button {
  font-size: 0.95rem;
}

/* =========================================================
   4) INBOX / CHAT – JEDNA wersja (bez duplikatów)
   ========================================================= */

/* okno inbox */
.inbox-modal {
  width: 90vw;
  max-width: 900px;
  height: 70vh;
  display: flex;
  flex-direction: column;
}

/* header */
.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

/* tabs */
.inbox-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
}
.inbox-tab {
  flex: 1;
  padding: 8px;
  font-size: 14px;
  background: #f9fafb;
  border: none;
  cursor: pointer;
}
.inbox-tab.active {
  background: #fff;
  font-weight: 600;
  border-bottom: 2px solid #4f46e5;
}

/* body */
.inbox-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* lista wątków */
.inbox-threads {
  width: 320px;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  background: #f8fafc;
}

.thread-item {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background 0.15s ease;
}
.thread-item:hover {
  background: #eef2ff;
}
.thread-item.active {
  background: #e0e7ff;
  border-left: 4px solid #4f46e5;
}

.thread-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.thread-user {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}
.thread-badge {
  background: #dc2626;
  color: #fff;
  font-size: 12px;
  padding: 0 6px;
  border-radius: 999px;
}

.thread-preview {
  font-size: 13px;
  color: #374151;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-product {
  font-size: 12px;
  margin-top: 4px;
  color: #6b7280;
}
.thread-product-link {
  color: #4f46e5;
  text-decoration: none;
  cursor: pointer;
}
.thread-product-link:hover {
  text-decoration: underline;
}
.thread-date {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* chat area */
.inbox-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.chat-empty { color: #9ca3af; font-size: 14px; }
.chat-placeholder { font-size: 14px; }

.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  background: #f9fafb;
}

.chat-messages {
  padding: 16px;
  background: #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.chat-bubble {
  max-width: 65%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 4px;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: #4f46e5;
  color: #fff;
  border-top-right-radius: 4px;
}
.chat-date {
  font-size: 11px;
  margin-top: 6px;
  color: #6b7280;
}
.chat-bubble.mine .chat-date {
  color: rgba(255,255,255,0.75);
}

.chat-reply {
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  gap: 10px;
}
.chat-reply textarea {
  resize: none;
  min-height: 44px;
}
.chat-reply button {
  min-width: 90px;
}

/* =========================================================
   5) INBOX – MOBILE
   ========================================================= */

@media (max-width: 768px) {

  .inbox-body { flex-direction: column; }

  /* lista */
  .inbox-left {
    width: 100%;
    display: block;
  }

  /* rozmowa */
  .inbox-chat {
    width: 100%;
    display: none;
  }

  .inbox-chat.mobile-active { display: flex; }
  .inbox-left.mobile-hidden { display: none; }

  .chat-back-btn {
    background: none;
    border: none;
    font-size: 18px;
    margin-right: 8px;
    cursor: pointer;
  }
}

/* Inbox fullscreen + ogólne modale na mobile (padding tła) */
@media (max-width: 768px) {

  .modal-backdrop {
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
  }

  .modal-window.inbox-modal {
    width: 100vw !important;
    height: 100svh !important;
    max-width: 100vw !important;
    max-height: 100svh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
  }

  .inbox-header { flex: 0 0 auto; }

  .inbox-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
  }

  .inbox-left,
  .inbox-chat {
    width: 100% !important;
    max-width: 100% !important;
  }

  .inbox-threads,
  .chat-messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Klawiatura mobilna – zachowanie inputa w czacie */
@media (max-width: 768px) {
  .chat-reply {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 20;
  }

  body.keyboard-open .chat-reply {
    position: fixed;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  body.keyboard-open .chat-messages {
    padding-bottom: 140px;
  }
}

/* TYLKO inbox – dokładne podniesienie pod klawiaturę (JS ustawia --keyboard-height) */
@media (max-width: 768px) {
  body.keyboard-open-inbox .modal-window.inbox-modal {
    padding-bottom: var(--keyboard-height, 0px);
    height: calc(100svh - var(--keyboard-height, 0px)) !important;
  }

  body.keyboard-open-inbox .chat-reply {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--keyboard-height, 0px);
    background: #fff;
    z-index: 50;
  }

  body.keyboard-open-inbox .chat-messages {
    padding-bottom: 160px;
  }
}

/* Inne fullscreen modale na mobile */
@media (max-width: 768px) {
  .modal-window.inbox-modal,
  .modal-window.product-modal-full {
    width: 100vw !important;
    height: 100svh !important;
    max-height: 100svh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
}

/* Małe ekrany – łagodniejsze zachowanie absolutów w modalach */
@media (max-width: 640px) {
  .modal-window { overflow-y: auto; }

  .modal-window .absolute {
    position: static !important;
    margin-top: 8px;
  }
}

/* =========================================================
   6) ONBOARDING / DODAWANIE – CZYSTY SYSTEM
   ========================================================= */

/* Ostrzeżenie o prywatności */
.privacy-warning {
  color: #dc2626; /* Tailwind red-600 */
}

/* Stała wysokość przycisków w stopce modala */
.modal-window .btn-primary,
.modal-window .btn-secondary {
  min-height: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Bez brzydkich ringów na btn-primary w modalach */
.modal-window button.btn-primary:focus,
.modal-window button.btn-primary:focus-visible,
.modal-window button.btn-primary:active {
  outline: none !important;
  box-shadow: none !important;
}

/* ===== MOBILE ONBOARDING (sticky hint) ===== */
@keyframes floatHint {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.mobile-onboarding-hint {
  position: sticky;
  top: 64px;
  z-index: 50;

  margin: 0 auto 8px auto;
  width: fit-content;
  max-width: 90vw;

  padding: 10px 18px;
  border-radius: 9999px;

  background: rgba(79,70,229,0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;

  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 8px 20px rgba(79,70,229,0.35);

  animation: floatHint 3s ease-in-out infinite;
  pointer-events: none;
}

/* ===== Przyciski onboarding – “Dodaj” na górze ===== */
.btn-add-onboarding {
  background-color: #4f46e5;
  color: #fff;
  border-radius: 0.75rem;
  font-weight: 600;
  position: relative;
  z-index: 2;
}
.btn-add-onboarding:hover {
  background-color: #4338ca;
}
.btn-add-onboarding::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 0.9rem;
  border: 2px solid rgba(99,102,241,0.6);
  animation: addPulse 1.8s infinite;
  pointer-events: none;
}

@keyframes addPulse {
  0%   { opacity: 1; transform: scale(1); }
  70%  { opacity: 0; transform: scale(1.25); }
  100% { opacity: 0; }
}

/* ===== Puls na przyciskach “AI / Zapisz” (bez ramek dookoła) ===== */
@keyframes rememberPulse {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(1.12); }
}
.remember-pulse {
  animation: rememberPulse 1.8s ease-in-out infinite;
}

/* =========================================================
   7) CHMURKI ONBOARDING
   - domyślnie: NAD (strzałka w dół)
   - wariant:   PO PRAWEJ (strzałka w lewo + animacja lewo/prawo)
   ========================================================= */

/* baza – domyślnie chmurka NAD elementem */
.onboarding-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);

  max-width: 260px;
  width: max-content;
  white-space: normal;
  word-break: break-word;
  text-align: center;
  line-height: 1.25;

  padding: 8px 16px;
  border-radius: 9999px;

  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 13px;
  font-weight: 500;

  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 8px 20px rgba(79,70,229,0.35);

  z-index: 50;
  pointer-events: none;
}

/* strzałka w dół (NAD elementem) */
.onboarding-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);

  width: 0;
  height: 0;

  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #6366f1;
}

/* alias – jeśli w HTML jest onboarding-bubble--above, to tylko koryguj odstęp */
.onboarding-bubble--above {
  bottom: calc(100% + 12px);
}

/* delikatny puls chmurki nad elementem (nie dotyka wariantu --right) */
@keyframes bubblePulse {
  0%   { transform: translateX(-50%) scale(1); }
  50%  { transform: translateX(-50%) scale(1.05); }
  100% { transform: translateX(-50%) scale(1); }
}
.onboarding-bubble:not(.onboarding-bubble--right) {
  animation: bubblePulse 1.8s infinite;
}

/* ===== WARIANT: chmurka po PRAWEJ stronie (np. Galeria) ===== */
@keyframes floatSide {
  0%   { transform: translateY(-50%) translateX(0); }
  50%  { transform: translateY(-50%) translateX(10px); }
  100% { transform: translateY(-50%) translateX(0); }
}

.onboarding-bubble--right {
  top: 50%;
  left: calc(100% + 12px);
  bottom: auto;

  /* animacja boczna */
  animation: floatSide 2.4s ease-in-out infinite;

  /* krótkie teksty przy Galerii niech się nie łamią */
  white-space: nowrap;
  max-width: none;
}

/* strzałka Z LEWEJ (wskazuje kafelek) – nadpisuje dolną strzałkę */
.onboarding-bubble.onboarding-bubble--right::after {
  top: 50%;
  left: -8px;
  transform: translateY(-50%);

  border: none;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid #6366f1;
}

/* małe ekrany – chmurki niech nie wychodzą poza ekran */
@media (max-width: 640px) {
  .onboarding-bubble {
    max-width: 90vw;
  }
}
/* ===== MOBILE: chmurka przy Aparat / Galeria ===== */
.onboarding-bubble--mobile-photos {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translate(-50%, -100%);

  max-width: 90vw;
  white-space: nowrap;

  z-index: 30;
}

/* strzałka w dół – wskazuje środek kafelka */
.onboarding-bubble--mobile-photos::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);

  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #6366f1;
}

/* ===== MOBILE: chmurka po PRAWEJ stronie Aparat / Galeria ===== */
@media (max-width: 640px) {

  .onboarding-bubble--mobile-photos {
    top: 50%;
    left: calc(100% + 12px);
    bottom: auto;

    transform: translateY(-50%);
    white-space: nowrap;
    z-index: 40;
  }

  /* strzałka z LEWEJ strony (wskazuje kafelek) */
  .onboarding-bubble--mobile-photos::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -8px;
    transform: translateY(-50%);

    border: none;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #6366f1;
  }
}

/* =========================================================
   MODAL: Zamknięcie konkursu – ZAWSZE NA WIERZCHU
   ========================================================= */

.modal-backdrop.modal-freeze-contest {
  position: fixed;
  inset: 0;
  z-index: 30000 !important; /* ⬅️ wyżej niż admin, inbox, wszystko */
}

.modal-freeze-contest-window {
  position: relative;
  z-index: 30001 !important;
}

/* =========================
   ADMIN PANEL – tabele nie mogą wychodzić poza modal
   ========================= */

/* Admin modal ma trzymać się ekranu i nie wypuszczać poziomych overflowów */
.modal-window.max-w-5xl{
  width: min(95vw, 64rem) !important;  /* 64rem = max-w-5xl */
  max-width: 95vw !important;
  overflow-x: hidden !important;       /* klucz: nic nie “wyjdzie bokiem” */
}

/* Wrapper do poziomego scrolla tabel */
.admin-table-scroll{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tabele w adminie: niech mają stabilny układ i nie rozpychają modala */
.modal-window.max-w-5xl table{
  border-collapse: collapse;
}

.rotate-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.rotate-btn:hover {
  background: rgba(0,0,0,.85);
}


/* ===== IMAGE VIEWER – OBRÓT POD ZDJĘCIEM ===== */

.image-rotate-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  padding-bottom: 10px;
}

.rotate-btn-big {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 10px 18px;
  border-radius: 9999px;
  border: none;

  background: #111827; /* prawie czarny */
  color: #fff;

  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.rotate-btn-big:hover {
  background: #000;
}

/* ===== IMAGE VIEWER – ZOOM ===== */

.image-viewer-img {
  cursor: zoom-in;
  transition: transform 0.25s ease;
}

.image-viewer-img.zoomed {
  cursor: zoom-out;
}
.image-viewer-img {
  cursor: zoom-in;
  user-select: none;
}

.image-viewer-img.zoomed {
  cursor: grab;
}

.image-viewer-img.zoomed.dragging {
  cursor: grabbing;
}

.image-viewer-img {
  touch-action: pan-x pan-y pinch-zoom;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* SEO-only links: widoczne dla Google, NIEKLIKALNE dla usera */
.sr-only {
  pointer-events: none !important;
}

.banner-overlay {
  background: linear-gradient(
    to right,
    rgba(0,0,0,0.75) 0%,
    rgba(0,0,0,0.55) 40%,
    rgba(0,0,0,0.25) 65%,
    rgba(0,0,0,0.05) 100%
  );
}
