/* Główny układ lewego panelu */
.left-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Dynamiczny kontener dopasowujący wysokość */
#canvas-container {
  position: relative;
  flex: 1;
  background-color: #f8fafc;
  touch-action: manipulation;
}

.model-loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid #2563eb;
  border-right-color: transparent;
  border-radius: 50%;
  animation: model-loading-spin 0.75s linear infinite;
}

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

.param-group {
  margin-bottom: 16px;
}
.param-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #16a34a;
  margin-bottom: 10px;
}

/* Tabs - Poziomy scroll zoptymalizowany pod dotyk */
.tab-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  border-bottom: 2px solid #f1f5f9;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Ukrywa pasek scrolla dla czystszego wyglądu */
}
.tab-container::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background-color: #f1f5f9;
  color: #475569;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  touch-action: manipulation;
}
.tab-btn:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}
.tab-btn.active {
  background-color: #2563eb;
  color: #ffffff;
}

/* Kafelki materiałów - Zoptymalizowana siatka pod małe ekrany */
.color-grid {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.color-grid::-webkit-scrollbar {
  display: none;
}

.color-grid .color-tile {
  flex: 0 0 118px;
  scroll-snap-align: start;
}

.color-carousel {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.color-carousel-arrow {
  flex: 0 0 34px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease-in-out;
}

.color-carousel-arrow:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.color-carousel-arrow:active {
  transform: scale(0.96);
}

.color-carousel-arrow:disabled,
.color-carousel-arrow:disabled:hover,
.color-carousel-arrow:disabled:active {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #cbd5e1;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.color-tile {
  position: relative;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  padding: 6px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 105px;
  user-select: none;
  background: #ffffff;
  touch-action: manipulation;
}
.color-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.08);
}
.color-tile.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px #93c5fd;
}

/* Zablokowany kafelek (brak w magazynie) */
.color-tile.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(80%);
  background: #f8fafc;
  border-color: #e2e8f0 !important;
  box-shadow: none !important;
}

.tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  height: 16px;
}
.brand-logo {
  height: 14px;
  width: auto;
  object-fit: contain;
}
.out-of-stock-badge {
  font-size: 8px;
  font-weight: 700;
  color: #ef4444;
  background-color: #fee2e2;
  padding: 1px 3px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* Próbka koloru z kodem HEX */
.color-preview-box {
  height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  font-family: monospace;
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.1);
}

.tile-footer {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.color-title-container {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.color-name-text {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.material-tag {
  font-size: 8px;
  font-weight: 600;
  background-color: #f1f5f9;
  color: #475569;
  padding: 1px 3px;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}
.color-price-tag {
  font-size: 10px;
  font-weight: 800;
  color: #059669;
}

/* Styl dla interaktywnej kostki widoków (ViewCube) zoptymalizowanej pod mobile */
.viewcube-wrapper {
  perspective: 400px;
  width: 48px;
  height: 48px;
  cursor: pointer;
}
@media (min-width: 640px) {
  .viewcube-wrapper {
    width: 60px;
    height: 60px;
  }
}

.viewcube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
}

.viewcube-face {
  position: absolute;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cbd5e1;
  font-size: 8px;
  font-weight: bold;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  user-select: none;
}
@media (min-width: 640px) {
  .viewcube-face {
    width: 60px;
    height: 60px;
    font-size: 9px;
  }
}

.viewcube-face:hover { background: #2563eb; color: white; }

.face-front  { transform: translateZ(24px); }
.face-back   { transform: rotateY(180deg) translateZ(24px); }
.face-right  { transform: rotateY(90deg) translateZ(24px); }
.face-left   { transform: rotateY(-90deg) translateZ(24px); }
.face-top    { transform: rotateX(90deg) translateZ(24px); }
.face-bottom { transform: rotateX(-90deg) translateZ(24px); }

@media (min-width: 640px) {
  .face-front  { transform: translateZ(30px); }
  .face-back   { transform: rotateY(180deg) translateZ(30px); }
  .face-right  { transform: rotateY(90deg) translateZ(30px); }
  .face-left   { transform: rotateY(-90deg) translateZ(30px); }
  .face-top    { transform: rotateX(90deg) translateZ(30px); }
  .face-bottom { transform: rotateX(-90deg) translateZ(30px); }
}

.extracted-color-grid {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.extracted-color-grid::-webkit-scrollbar {
  display: none;
}

.extracted-color-tile {
  position: relative;
  flex: 0 0 165px;
  min-height: 145px;
  padding: 6px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease-in-out;
  user-select: none;
  scroll-snap-align: start;
}

.extracted-color-tile:hover {
  transform: translateY(-1px);
  border-color: #60a5fa;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
}

.extracted-color-tile.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px #93c5fd;
}

.extracted-color-arrow {
  height: 15px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}

.project-plate-tile {
  display: flex;
  flex: 0 0 150px;
  min-height: 72px;
  padding: 6px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  transition: all 0.15s ease-in-out;
}

.project-plate-list {
  display: flex;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.project-plate-list::-webkit-scrollbar {
  display: none;
}

.project-plate-list .project-plate-tile {
  scroll-snap-align: start;
}

.project-plate-tile:hover {
  border-color: #60a5fa;
  transform: translateY(-1px);
}

.project-plate-tile.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 2px #bfdbfe;
}

.project-plate-thumbnail {
  width: 100%;
  height: 58px;
  object-fit: contain;
  border-radius: 5px;
  background: #f8fafc;
}

.project-plate-placeholder {
  display: flex;
  width: 100%;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 12px;
}
