/* ============================================
   Mobile-First T-Shirt Customizer Styles
   ============================================ */

* {
  box-sizing: border-box;
}

html, body {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  padding-bottom: 64px; /* Space for fixed bottom buttons */
  background: #f5f5f5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; /* Ensure body has minimum height */
  width: 100%;
  height: 100%;
  display: block; /* Ensure elements are visible */
}

/* ============================================
   MOBILE LAYOUT
   ============================================ */

.mobile-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  overflow: hidden;
  position: relative;
  width: 100%;
  min-height: 100vh; /* Ensure minimum visibility */
  background: #f5f5f5; /* Fallback background */
}

.mobile-app > *:not(.mobile-canvas-area) {
  flex-shrink: 0;
}

/* Mobile Header */
.mobile-header {
  background: #fff;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 150;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: relative;
}

.back-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: #495057;
  cursor: pointer;
  padding: 6px 8px;
  line-height: 1;
  border-radius: 8px;
  transition: background 0.2s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-btn:hover {
  background: #f8f9fa;
}

.progress-indicator {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
  flex-shrink: 0;
}

.step-icon, .step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: #e0e0e0;
  color: #666;
}

.progress-step.completed .step-icon {
  background: #4caf50;
  color: #fff;
}

.progress-step.active .step-number {
  background: #2196f3;
  color: #fff;
}

.step-label {
  font-size: 10px;
  color: #666;
  text-align: center;
  white-space: nowrap;
}

.progress-line {
  width: 30px;
  height: 2px;
  background: #e0e0e0;
  margin: 0 4px;
  flex-shrink: 0;
}

.progress-line.completed {
  background: #4caf50;
}

/* Main Canvas Area */
.mobile-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
  min-height: 400px; /* Ensure minimum visibility */
  overflow-y: auto;
}

.product-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  background: transparent;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-stage img#tshirtBase {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: calc(100vh - 140px); /* Account for header and tabs */
  object-fit: contain;
  object-position: center;
  z-index: 0;
  pointer-events: none;
}

.product-stage canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto !important;
  height: auto !important;
  max-width: 100vw;
  max-height: calc(100vh - 140px); /* Account for header and tabs */
  z-index: 1;
  border: 0;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.flip-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 999;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  width: 48px;
  height: 48px;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.flip-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.15);
}

.flip-btn:active {
  transform: scale(0.95);
}

.flip-btn svg {
  width: 24px;
  height: 24px;
  stroke: #495057;
  transition: stroke 0.2s ease;
}

.flip-btn:hover svg {
  stroke: #212529;
}

.flip-btn img {
  display: none;
}

.flip-btn span {
  display: none;
}

/* Tabs Container */
.tabs-container {
  position: relative;
  z-index: 150;
}

/* Top Tabs Navigation */
.top-tabs {
  display: flex;
  flex-wrap: nowrap;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 12px 8px 8px;
  justify-content: space-around;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  row-gap: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.top-tabs.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: #6c757d;
  transition: all 0.2s ease;
  position: relative;
  border-radius: 12px;
  margin: 0 2px;
  min-width: 0;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: #2196f3;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 3px 3px 0 0;
}

.tab-btn.active {
  color: #2196f3;
  background: rgba(33, 150, 243, 0.08);
}

.tab-btn.active::after {
  width: 60%;
}

.tab-btn:hover {
  background: rgba(33, 150, 243, 0.05);
}

.tab-icon {
  width: 32px;
  height: 32px;
  stroke-width: 2;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.tab-btn.active .tab-icon {
  opacity: 1;
  transform: scale(1.15);
}

.tab-btn:hover .tab-icon {
  opacity: 0.9;
  transform: scale(1.05);
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
}

/* Tab Panels - Replace Tabs In Place */
.tab-panels {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  max-height: calc(100vh - 60px - 100px);
  width: 100%;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.tab-panels.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  overflow-y: auto;
}

/* Products Panel - Slide from Right Side */
.tab-panels.products-panel {
  position: fixed;
  top: 60px; /* Below header */
  left: auto;
  right: 0;
  width: 25%;
  min-width: 240px;
  max-width: 320px;
  height: calc(100vh - 60px);
  max-height: none;
  border-bottom: none;
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.tab-panels.products-panel.active {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Backdrop for products panel */
.products-panel-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 190;
  pointer-events: none;
}

.products-panel-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tab-panel {
  display: none;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 16px 50px 16px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #212529;
  letter-spacing: -0.3px;
}

.panel-header::after {
  display: none;
}

.panel-content {
  padding: 20px 16px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Text Tab Styles */
.text-input-group {
  position: relative;
  margin-bottom: 16px;
}

.text-input-group input[type="text"] {
  width: 100%;
  padding: 14px 50px 14px 16px;
  border: 1.5px solid #dee2e6;
  border-radius: 12px;
  font-size: 16px;
  background: #f8f9fa;
  transition: all 0.2s ease;
  font-family: inherit;
}

.text-input-group input[type="text"]:focus {
  outline: none;
  border-color: #2196f3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.char-count {
  display: block;
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  margin-left: 4px;
}

.confirm-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #28a745;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.confirm-btn:hover {
  background: #218838;
  transform: translateY(-50%) scale(1.05);
}

.text-controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-item label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.control-item select,
.control-item input[type="color"] {
  padding: 11px 12px;
  border: 1.5px solid #dee2e6;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: all 0.2s ease;
  font-family: inherit;
}

.control-item select:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.control-item input[type="color"] {
  height: 48px;
  cursor: pointer;
  border-radius: 10px;
  padding: 4px;
}

/* Upload Tab Styles */
.upload-area {
  text-align: center;
}

.upload-area input[type="file"] {
  display: none;
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  border: 2px dashed #ced4da;
  border-radius: 16px;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-label:hover {
  border-color: #2196f3;
  background: #e3f2fd;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.1);
}

.upload-icon {
  font-size: 48px;
}

.upload-label span:not(.upload-icon) {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.upload-label small {
  font-size: 12px;
  color: #666;
}

/* Gallery Tab Styles */
.gallery-open-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.gallery-open-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

/* Layers Tab Styles */
.layers-panel-mobile {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 16px;
}

#layersList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#layersList li {
  padding: 12px;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}

#layersList li:active {
  cursor: grabbing;
}

.layer-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.layer-actions-grid button {
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.layer-actions-grid button:hover {
  background: #f5f5f5;
  border-color: #2196f3;
}

/* Actions Tab Styles */
.action-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  border: 1.5px solid #dee2e6;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: #f8f9fa;
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.action-btn.delete {
  border-color: #dc3545;
  background: #fff5f5;
}

.action-btn.delete:hover {
  background: #ffeaea;
  border-color: #c82333;
}

.action-icon {
  font-size: 24px;
}

.action-btn span:not(.action-icon) {
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

.save-export-section {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.save-btn,
.export-btn {
  flex: 1;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.save-btn {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.export-btn {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

/* Products Tab Styles */
.product-list-mobile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
}

.product-item-mobile {
  border: 2px solid #dee2e6;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.product-item-mobile:hover,
.product-item-mobile.active {
  border-color: #2196f3;
  box-shadow: 0 4px 16px rgba(33, 150, 243, 0.2);
  transform: translateY(-2px);
}

.product-item-mobile.active {
  background: linear-gradient(135deg, #e3f2fd 0%, #fff 100%);
}

.product-item-mobile img {
  width: 80px;
  height: 80px;
  min-width: 80px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0;
}

.product-item-mobile span {
  display: block;
  font-weight: 600;
  color: #333;
  font-size: 14px;
  flex: 1;
  text-align: left;
}

/* Preview Section (Desktop only) */
.preview-section-desktop {
  display: none;
}

/* ============================================
   MODAL STYLES (Same as before)
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: #fff;
  padding: 0;
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 8px 16px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-content.modal-large {
  max-width: 680px;
  max-height: 75vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.02em;
}

.modal-close-btn {
  background: rgba(0, 0, 0, 0.04);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #333;
  transform: rotate(90deg);
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
  background: #fff;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-bottom: 20px;
}

.gallery-filters button {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.gallery-filters button:hover {
  border-color: #2196f3;
  color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.15);
}

.gallery-filters button.active {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  border-color: #2196f3;
  color: #fff;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.gallery-item {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  aspect-ratio: 1.5 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.gallery-item:hover {
  border-color: #2196f3;
  box-shadow: 0 8px 20px rgba(33, 150, 243, 0.25);
  transform: translateY(-4px) scale(1.02);
}

.gallery-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-buttons {
  margin-top: 32px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-buttons button {
  padding: 12px 24px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  min-width: 120px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-buttons .btn-primary {
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.modal-buttons .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.modal-buttons .btn-primary:active {
  transform: translateY(0);
}

.modal-buttons .btn-secondary {
  background: #f5f5f5;
  color: #495057;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.modal-buttons .btn-secondary:hover {
  background: #e9ecef;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.modal-buttons .btn-secondary:active {
  transform: translateY(0);
}

.modal-content p {
  color: #555;
  line-height: 1.6;
  margin: 0 0 8px 0;
  font-size: 0.95rem;
}

/* Tab Panel Backdrop */
.tab-panels-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 240;
  backdrop-filter: blur(4px);
}

.tab-panels-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.tab-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
}

.tab-panels.active .tab-panel-close {
  opacity: 1;
  pointer-events: auto;
}

/* Products panel close button styling */
.tab-panels.products-panel .tab-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
}

.tab-panel-close:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}

.tab-panel-close:active {
  transform: scale(0.95);
}

.tab-panel-close svg {
  width: 20px;
  height: 20px;
  stroke: #495057;
  stroke-width: 2.5;
  transition: stroke 0.2s ease;
}

.tab-panel-close:hover svg {
  stroke: #212529;
}

/* Modal Close Button (Bottom) - For regular modals */
.modal-close-bottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.modal-close-bottom:hover {
  background: #f8f9fa;
  border-color: rgba(0, 0, 0, 0.15);
  transform: translateX(-50%) scale(1.1) rotate(90deg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-close-bottom:active {
  transform: translateX(-50%) scale(0.95);
}

.modal-close-bottom svg {
  width: 22px;
  height: 22px;
  stroke: #666;
  transition: stroke 0.2s ease;
}

.modal-close-bottom:hover svg {
  stroke: #333;
}

/* For modal-large, position relative to modal-body */
.modal-content.modal-large .modal-close-bottom {
  position: absolute;
  bottom: 16px;
}

/* ============================================
   DESKTOP LAYOUT (Fallback)
   ============================================ */

@media (min-width: 1024px) {
  .mobile-app {
    flex-direction: row;
    height: 100vh;
  }

  .mobile-header {
    display: none;
  }

  .mobile-canvas-area {
    flex: 1;
    padding: 24px;
  }

  .product-stage {
    max-width: 800px;
    aspect-ratio: 4 / 5;
  }

  .top-tabs {
    display: none;
  }

  .tab-panels {
    position: static;
    transform: none;
    max-height: none;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    width: 320px;
    background: #fff;
    border-right: 1px solid #eee;
    padding: 16px;
    overflow-y: auto;
  }

  .tab-panel {
    display: block !important;
    margin-bottom: 24px;
  }

  .panel-header {
    position: static;
    padding: 0 0 12px 0;
    border-bottom: 1px solid #eee;
    background: transparent;
    margin-bottom: 16px;
  }

  .preview-section-desktop {
    display: block;
    width: 200px;
    background: #fdfdfd;
    padding: 16px;
    border-left: 1px solid #eee;
    overflow-y: auto;
  }

  .preview-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .preview-box {
    position: relative;
    border: 1px solid #eee;
    background: #f9f9f9;
    text-align: center;
    height: 200px;
    overflow: hidden;
    border-radius: 4px;
  }

  .preview-box .preview-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
  }

  .preview-box canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
  }

  .preview-box span {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.8);
    padding: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.tool-block {
  margin-bottom: 16px;
}

.tool-block label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Hide scrollbar for webkit browsers */
.tab-panels::-webkit-scrollbar,
.layers-panel-mobile::-webkit-scrollbar {
  width: 4px;
}

.tab-panels::-webkit-scrollbar-track,
.layers-panel-mobile::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.tab-panels::-webkit-scrollbar-thumb,
.layers-panel-mobile::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

/* ============================================
   ACTION BUTTONS SECTION (Below Canvas)
   ============================================ */

.action-buttons-section {
  background: #fff;
  padding: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.action-buttons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.action-buttons-row .action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  position: relative;
  overflow: hidden;
}

.action-buttons-row .action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s;
}

.action-buttons-row .action-btn:hover::before {
  left: 100%;
}

.action-buttons-row .action-btn:hover {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
}

.action-buttons-row .action-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.15);
}

.action-buttons-row .action-btn .action-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

.action-buttons-row .action-btn:hover .action-icon {
  transform: scale(1.1);
}

.action-buttons-row .action-btn .action-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #495057;
}

.action-buttons-row .action-btn.delete {
  border-color: #ff6b6b;
  background: linear-gradient(135deg, #fff5f5 0%, #ffeaea 100%);
  color: #dc3545;
}

.action-buttons-row .action-btn.delete:hover {
  background: linear-gradient(135deg, #ffeaea 0%, #ffd6d6 100%);
  border-color: #ff5252;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
}

.action-buttons-row .action-btn.delete .action-label {
  color: #dc3545;
}

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
  margin: 12px 0;
}

.layer-controls-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.layer-controls-row .layer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 10px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  font-size: 11px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.layer-controls-row .layer-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s;
}

.layer-controls-row .layer-btn:hover::before {
  left: 100%;
}

.layer-controls-row .layer-btn:hover {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
  color: #2196f3;
}

.layer-controls-row .layer-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.15);
}

.layer-controls-row .layer-btn .layer-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

.layer-controls-row .layer-btn:hover .layer-icon {
  transform: scale(1.15);
}

.layer-controls-row .layer-btn span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ============================================
   BOTTOM ACTION BUTTONS (Next and Save)
   ============================================ */

.bottom-action-buttons {
  display: flex;
  gap: 0;
  margin: 0;
  padding: 0;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  flex-shrink: 0;
  width: 100%;
}

.bottom-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 0;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0;
}

.bottom-btn.next-btn {
  background: #2196f3;
  color: #fff;
}

.bottom-btn.next-btn:hover {
  background: #1976d2;
}

.bottom-btn.save-btn {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: #fff;
}

.bottom-btn.save-btn:hover {
  background: linear-gradient(135deg, #218838 0%, #1ea080 100%);
}
