/**
 * 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: #e5e7eb;
  --tsim-bg: #fff;
  --tsim-bg-dark: #0b1020;
  --tsim-text: #111827;
  --tsim-text-muted: #6b7280;
  --tsim-badge-bg: #111827;
  --tsim-badge-text: #fff;
}

.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 - MOBILE (DEFAULT)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

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

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

/* ═══════════════════════════════════════════════════════════════════════════
   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: 12px;
  }

  .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-topbar__left,
  .tsim-topbar__mid,
  .tsim-topbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .tsim-modeBtns {
    flex-wrap: nowrap;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-badge {
  background: var(--tsim-badge-bg);
  color: var(--tsim-badge-text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS - BASE (Astra compatibility)
   ═══════════════════════════════════════════════════════════════════════════ */

.tsim-btn {
  /* Intentionally minimal - Astra theme handles styling */
}

.tsim-root button[title],
.tsim-root input[title] {
  cursor: help;
}

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

.tsim-canvasWrap {
  position: relative;
  border: 1px solid var(--tsim-border);
  border-radius: 12px;
  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;
}

/* ═══════════════════════════════════════════════════════════════════════════
   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: 12px;
  padding: 12px;
  background: var(--tsim-bg);
  margin-top: 12px;
}

.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;
}

.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);
}

.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: 12px;
  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;
  }
}

/* End of Tool Simulator 3D Stylesheet */

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

.tsim-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 32, 0.95);
  z-index: 100;
  border-radius: 12px;
}

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

.tsim-loading__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: tsim-spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes tsim-spin {
  to {
    transform: rotate(360deg);
  }
}

.tsim-loading__text {
  color: #fff;
  font-size: 14px;
  margin-bottom: 12px;
  text-align: center;
}

.tsim-loading__bar-wrap {
  width: min(280px, 80%);
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
}

.tsim-loading__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 999px;
  transition: width 0.2s ease-out;
}

.tsim-loading__percent {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 8px;
}

/* Error state */
.tsim-loading[data-state="error"] .tsim-loading__spinner {
  border-color: #ef4444;
  border-top-color: #ef4444;
  animation: none;
}

.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;
}