/**
 * Tool Simulator 3D - Stylesheet
 * Copyright (c) 2024 Domi
 * Unauthorized copying, modification or distribution is prohibited.
 * This file is part of Tool Simulator 3D WordPress Plugin.
 * License: Proprietary - All Rights Reserved
 */

/* ═══════════════════════════════════════════════════════════════════════════
   ROOT & RESET
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-root {
  font-family: inherit;
  box-sizing: border-box;
  --tsim-border: #2a2f3e;
  --tsim-bg: #fff;
  --tsim-bg-dark: #0f1523;
  --tsim-text: #111827;
  --tsim-text-muted: #6b7280;
  --tsim-badge-text: #fff;
  --viz-border-radius: 12px;
}

.tsim-root *,
.tsim-root *::before,
.tsim-root *::after {
  box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FULL WIDTH LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-fullwidth {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: 12px;
  padding-right: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR - INSIDE CANVAS (overlay)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.0) 100%);
  flex-wrap: nowrap;
}

.tsim-topbar__left,
.tsim-topbar__mid,
.tsim-topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.tsim-modeBtns {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE MENU (HAMBURGER)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 980px) {
  .tsim-topbar {
    overflow: visible;
  }
  
  .tsim-mobile-menu-btn {
    display: block !important;
    margin-left: auto;
  }
  
  .tsim-topbar__collapsible {
    display: none;
    position: absolute;
    top: 100%;
    right: 12px;
    background: rgba(20, 25, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
  }
  
  .tsim-topbar[data-mobile-open="true"] .tsim-topbar__collapsible {
    display: flex;
  }
  
  .tsim-topbar__mid, 
  .tsim-topbar__right {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  
  .tsim-topbar__right > div {
    flex-direction: column;
    align-items: stretch;
  }
  
  .tsim-topbar__collapsible .tsim-btn, 
  .tsim-topbar__collapsible .tsim-lang-select {
    width: 100%;
    margin: 0 !important;
    text-align: left;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR - DESKTOP (GRID 3-COLUMN)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 981px) {
  .tsim-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "left mid right";
    align-items: center;
    gap: 8px;
  }

  .tsim-topbar__collapsible {
    display: contents;
  }

  .tsim-topbar__left {
    grid-area: left;
    justify-self: start;
  }

  .tsim-topbar__mid {
    grid-area: mid;
    justify-self: center;
  }

  .tsim-topbar__right {
    grid-area: right;
    justify-self: end;
  }
}

.tsim-badge {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS — OUTLINE STYLE (no filled background)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-btn {
  background: transparent !important;
  color: rgba(255, 255, 255, 0.9) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
  border-radius: var(--viz-btn-radius, 6px);
  padding: var(--viz-btn-padding, 6px 14px);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-transform: none;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.tsim-btn:hover,
.tsim-btn:focus,
.tsim-btn:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.65) !important;
  color: #fff !important;
}

.tsim-btn:active {
  background: rgba(255, 255, 255, 0.18) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS — BELOW CANVAS (Native theme via wp-block-button__link)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-btn-astra {
  cursor: pointer;
  white-space: nowrap;
}

.tsim-btn-astra:disabled {
  opacity: 0.45;
  filter: grayscale(0.7);
  cursor: not-allowed !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LANGUAGE SELECTOR (outline style)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-lang-select {
  background: transparent;
  color: rgba(255, 255, 255, 0.9) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--viz-btn-radius, 6px);
  padding: var(--viz-btn-padding, 5px 24px 5px 8px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg fill='rgba(255,255,255,0.7)' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.23 7.21a.75.75 0 011.06 0L10 10.94l3.71-3.73a.75.75 0 011.06 1.06l-4.25 4.25a.75.75 0 01-1.06 0L5.23 8.27a.75.75 0 010-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 14px;
  min-width: 75px;
  backdrop-filter: blur(4px);
}

.tsim-lang-select:hover,
.tsim-lang-select:focus,
.tsim-lang-select:focus-visible,
.tsim-lang-select:active {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.65) !important;
  color: #fff !important;
  outline: none !important;
}

.tsim-lang-select option {
  background: #1e293b;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CANVAS WRAPPER
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-canvasWrap {
  position: relative;
  border: 1px solid var(--tsim-border);
  border-radius: var(--viz-border-radius);
  overflow: hidden;
  background: var(--tsim-bg-dark);
}

.tsim-canvas {
  width: 100%;
  height: min(70vh, 720px);
  min-height: 420px;
}

.tsim-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EKRAN STARTOWY (PREMIUM)
   ═══════════════════════════════════════════════════════════════════════════ */

.viz3d-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.4s ease;
  padding: 20px;
}

.viz3d-overlay--hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.viz3d-overlay--preview {
  background: #ffffff;
  padding: 0;
  overflow: hidden;
  border-radius: var(--viz-border-radius);
}

.viz3d-preview-branding {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 110;
  color: rgba(0, 30, 80, 0.9);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.viz3d-preview-image-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viz3d-preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border: none;
}

.viz3d-preview-overlay-shadow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 80px;
  background: rgba(0, 0, 0, 0.35);
  filter: blur(25px);
  border-radius: 50px;
  pointer-events: none;
  z-index: 101;
}

.viz3d-btn-load-3d {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 105;
  background: rgba(0, 30, 80, 0.6);
  color: #ffffff;
  border: none;
  padding: 16px 40px;
  border-radius: var(--viz-border-radius-md, 12px);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(233, 69, 96, 0.2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.viz3d-btn-load-3d:hover {
  transform: translate(-50%, -52%) scale(1.05);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 0 6px rgba(233, 69, 96, 0.3);
  background: rgba(0, 40, 100, 0.8);
  color: #ffffff;
}

.viz3d-btn-load-3d:active {
  transform: translate(-50%, -49%) scale(0.98);
}

.viz3d-preview-bottom {
  position: absolute;
  bottom: 15px;
  width: 100%;
  text-align: center;
  z-index: 110;
}

.viz3d-preview-hint {
  color: rgba(0, 0, 0, 0.4);
  font-size: 12px;
  text-align: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRE-ROLL AD OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-preroll {
  position: absolute;
  inset: 0;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 21, 35, 0.97);
  border-radius: 12px;
}

.tsim-preroll[data-state="hidden"] {
  display: none;
}

.tsim-preroll__ad {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 30px 60px;
  text-align: center;
  margin-bottom: 16px;
}

.tsim-preroll__icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
}

.tsim-preroll__label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
}

.tsim-preroll__size {
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  margin-top: 6px;
}

.tsim-preroll__text {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ROTATE OVERLAY (MOBILE PORTRAIT)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-rotate {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  padding: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UNDER PANELS CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-under {
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-section {
  border: 1px solid var(--tsim-border);
  border-radius: var(--viz-border-radius);
  padding: 12px;
  background: var(--tsim-bg);
  margin-top: 12px;
}

.tsim-section[data-state="hidden"] {
  display: none !important;
}

.tsim-section h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: var(--tsim-text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM GRID (TEST CONFIG)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-formGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

@media (max-width: 980px) {
  .tsim-formGrid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 520px) {
  .tsim-formGrid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM FIELDS
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-field label {
  display: block;
  font-size: 12px;
  color: var(--tsim-text-muted);
  margin-bottom: 4px;
}

.tsim-field input {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ROWS
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MEASURE ROW (POMIAR)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-measureRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.tsim-input {
  width: 100%;
  min-width: min(200px, 100%);
  flex: 1 1 180px;
}

@media (min-width: 981px) {

  .tsim-measureRow>button,
  .tsim-measureRow>input {
    flex: 0 0 auto;
  }

  .tsim-measureRow .tsim-input {
    flex: 1 1 200px;
    min-width: 200px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MUTED TEXT
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-muted {
  color: var(--tsim-text-muted);
  font-size: 12px;
  display: block;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HISTORY SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-history {
  margin-top: 14px;
}

.tsim-tableWrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--tsim-border);
  border-radius: 10px;
}

.tsim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tsim-table th,
.tsim-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--tsim-border);
}

.tsim-table th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
  text-align: left;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 99999;
  cursor: pointer;
}

.tsim-modal[aria-hidden="false"] {
  display: flex;
}

.tsim-modal__card {
  width: min(560px, 100%);
  background: var(--tsim-bg);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  cursor: default;
}

.tsim-modal__title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--tsim-text);
}

.tsim-modal__body {
  color: var(--tsim-text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.tsim-modal__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GATE (CREDITS LOGIN REQUIRED)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-gate {
  padding: 14px;
  border: 1px solid var(--tsim-border);
  border-radius: var(--viz-border-radius);
  background: var(--tsim-bg);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SLIDER DRAG MODE INDICATOR
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-root[data-slider-mode="true"] .tsim-canvas {
  cursor: ew-resize;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {

  .tsim-topbar,
  .tsim-canvasWrap,
  .tsim-modal {
    display: none !important;
  }

  .tsim-history {
    page-break-inside: avoid;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 21, 35, 0.98);
  z-index: 999999;
  border-radius: 0;
  /* Usunięto zaokrąglenia dla pełnego ekranu */
}

.tsim-loading[data-state="hidden"] {
  display: none;
}

/* Usunięty spinner z Wizualizacje_3D_z_quiz - stawiają na czysty progress bar */

/* MIEJSCE NA REKLAMĘ WZOREM WIZUALIZACJI 3D */
.viz3d-ad-placeholder {
  width: 90%;
  max-width: 1000px;
  height: 60vh;
  min-height: 250px;
  max-height: 500px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(100, 80, 200, 0.3);
  flex-shrink: 0;
  margin-bottom: 25px !important;
  position: relative;
  overflow: hidden;
}

/* Subtelny animowany gradient w tle reklamy dla ciekawszego efektu */
.viz3d-ad-placeholder::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
  animation: ad-pulse 8s infinite alternate ease-in-out;
}

@keyframes ad-pulse {
  0% {
    transform: scale(0.8) translate(0, 0);
  }

  100% {
    transform: scale(1.2) translate(5%, 5%);
  }
}

.viz3d-ad-placeholder__inner {
  text-align: center;
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 22px;
  line-height: 1.6;
  z-index: 1;
}

.viz3d-ad-placeholder__icon {
  font-size: 64px;
  margin-bottom: 20px;
  display: block;
}

.tsim-loading__bar-wrap {
  width: 55%;
  max-width: 380px;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 24px;
}

.tsim-loading__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--viz-primary, #3b82f6), #ff6b6b);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.tsim-loading__text {
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  letter-spacing: 0.3px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
}

.tsim-loading__text span:last-child {
  margin-left: 5px;
}

/* Error state */
/* Error state bez spinnera */

.tsim-loading[data-state="error"] .tsim-loading__bar {
  background: #ef4444;
}

.tsim-loading[data-state="error"] .tsim-loading__text {
  color: #fca5a5;
}

/* Disabled buttons */
.tsim-root button:disabled {
  opacity: 0.45;
  filter: grayscale(0.7);
  cursor: not-allowed !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FULLSCREEN MODE
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-root:fullscreen,
.tsim-root:-webkit-full-screen {
  background: #0f1523;
  padding: 0 12px;
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
}

.tsim-root:fullscreen .tsim-fullwidth,
.tsim-root:-webkit-full-screen .tsim-fullwidth {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* CanvasWrap zajmuje resztę dostępnej przestrzeni */
.tsim-root:fullscreen .tsim-canvasWrap,
.tsim-root:-webkit-full-screen .tsim-canvasWrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Sam canvas wypełnia CanvasWrap na 100% */
.tsim-root:fullscreen .tsim-canvas,
.tsim-root:-webkit-full-screen .tsim-canvas {
  height: 100%;
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
}

/* Panele dolne na samym dole, bez scrollovwania rosną sobie w górę */
.tsim-root:fullscreen .tsim-under,
.tsim-root:-webkit-full-screen .tsim-under {
  flex: 0 0 auto;
  margin-top: 8px;
  margin-bottom: 8px;
}

/* Ukrywamy historię by nie zabierała miejsca lub włączamy scrollowanie tylko dla sekcji z wynikami */
.tsim-root:fullscreen .tsim-history,
.tsim-root:-webkit-full-screen .tsim-history {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WATERMARK
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  z-index: 9;
  pointer-events: none;
  font-size: 70px;
  font-weight: 800;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  text-transform: uppercase;
  font-family: inherit;
}

@media (max-width: 600px) {
  .tsim-watermark {
    font-size: 40px;
  }
}