/* Desktop: designer-wrap is the positioning context for the floating toolbar.
   max-width matches the native canvas width so "right: 15px" on the toggle
   always lands near the canvas right edge, not a wider column edge. */
.swm-designer-wrap {
  position: relative;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.swm-designer-toolbar {
  display: grid;
  gap: 10px;
}

.swm-view-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.swm-view-bottom {
  margin-top: 10px;
  max-width: 540px;
  justify-content: center;
}

.swm-view-arrow {
  min-width: 34px;
  height: 34px;
  border: 1px solid #2563eb;
  background: #fff;
  color: #2563eb;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  font-size: 18px;
}

.swm-view-btn.is-active,
.swm-view-btn.active,
.view-btn.active {
  background: #111827;
  color: #fff;
}

.swm-btn {
  background: #111;
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  border: 1px solid #111;
  transition: 0.2s ease;
  cursor: pointer;
}

.swm-btn:hover {
  background: #333;
  border-color: #333;
}

.swm-tools-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.swm-tools-row input[type="text"] {
  min-width: 180px;
}

.swm-canvas-wrap {
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
  background: #f9fafb;
}

#swm-tools-toggle {
  position: absolute;
  top: 3px;
  right: 15px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #111;
  color: #fff;
  padding: 8px 12px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

#swm-tools-toggle:hover {
  transform: scale(1.05);
}

#swm-tools-toggle .icon {
  font-size: 14px;
}

#swm-tools-toggle.active {
  background: #333;
}

.swm-tools-panel {
  position: absolute;
  top: 60px;
  right: 15px;
  width: 240px;
  background: #ffffff;
  border: none;
  border-radius: 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  padding: 14px;
  z-index: 9;
  display: none;
  font-size: 13px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.swm-tools-panel.active {
  display: grid;
}

#swm-tools-panel .swm-section {
  margin-bottom: 14px;
}

#swm-tools-panel .swm-section:last-child {
  margin-bottom: 0;
}

#swm-tools-panel .swm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

#swm-tools-panel .swm-row label,
#swm-tools-panel .swm-section > label {
  font-size: 12px;
  color: #666;
}

#swm-tools-panel .swm-inline {
  gap: 8px;
}

#swm-tools-panel .swm-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  background: #f5f5f5;
  color: #111;
  margin-bottom: 6px;
  cursor: pointer;
  transition: 0.2s;
}

#swm-tools-panel .swm-btn.primary {
  background: #111;
  color: #fff;
}

#swm-tools-panel .swm-btn:hover {
  background: #eaeaea;
}

#swm-tools-panel .swm-btn.primary:hover {
  background: #222;
}

#swm-tools-panel .swm-danger-btn {
  width: 100%;
  background: #ff4d4d;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

#swm-tools-panel .swm-danger-btn:hover {
  background: #e60000;
}

#swm-tools-panel .swm-icon-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: #f5f5f5;
  font-weight: bold;
  cursor: pointer;
}

#swm-tools-panel .swm-icon-btn.active {
  background: #111;
  color: #fff;
}

#swm-tools-panel input,
#swm-tools-panel select {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
}

#swm-tools-panel #swm-font-family {
  width: 100%;
}

#swm-tools-panel #swm-font-family option[value="Montserrat"] { font-family: "Montserrat", sans-serif; }
#swm-tools-panel #swm-font-family option[value="Poppins"] { font-family: "Poppins", sans-serif; }
#swm-tools-panel #swm-font-family option[value="Oswald"] { font-family: "Oswald", sans-serif; }
#swm-tools-panel #swm-font-family option[value="Roboto"] { font-family: "Roboto", sans-serif; }

.swm-canvas-wrap {
  position: relative;
  width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
}

.canvas-container {
  max-width: none !important;
  transform-origin: top left;
}

#swm-canvas,
#swm-designer-canvas {
  display: block;
  border: 2px dashed #ccc;
  border-radius: 10px;
  max-width: 100%;
}

#swm-hint {
  position: absolute;
  top: 60px;
  right: 15px;
  background: #111;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  max-width: 220px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: fadeInUp 0.3s ease;
  z-index: 999;
  display: none;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

#swm-designer-status {
  font-size: 14px;
  color: #374151;
}

.single-product div.product form.cart,
.woocommerce div.product form.cart {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 8px;
  align-items: start;
}

.single-product div.product form.cart .quantity,
.woocommerce div.product form.cart .quantity {
  grid-column: 1;
  grid-row: 1 / 3;
  margin: 0 !important;
  align-self: start;
}

.single-product div.product form.cart .single_add_to_cart_button,
.woocommerce div.product form.cart .single_add_to_cart_button {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.single-product div.product form.cart #quote-btn.swm-quote-inline-btn,
.woocommerce div.product form.cart #quote-btn.swm-quote-inline-btn {
  grid-column: 2;
  grid-row: 2;
  position: static !important;
  left: auto !important;
  top: auto !important;
  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  border-radius: 6px;
  background: #111;
  border-color: #111;
  color: #fff;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.single-product div.product form.cart #quote-btn.swm-quote-inline-btn:hover,
.woocommerce div.product form.cart #quote-btn.swm-quote-inline-btn:hover {
  background: #333;
  border-color: #333;
}

#swm-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

#swm-loader.active {
  display: flex;
}

.swm-loader-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d1d5db;
  border-top-color: #111827;
  border-radius: 50%;
  animation: swm-spin 0.9s linear infinite;
}

@keyframes swm-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.swm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 999999;
  overflow-y: auto;
  padding: 48px 16px 40px;
  box-sizing: border-box;
}

.swm-modal.active {
  display: flex;
}

.swm-modal-content {
  background: #fff;
  padding: 32px 28px 28px;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  display: grid;
  gap: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  margin: auto 0;
  box-sizing: border-box;
}

.swm-modal-content h3 {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
}

.swm-modal-content input {
  min-height: 46px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
  outline: none;
  background: #fff;
  color: #111;
}

.swm-modal-content input:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.07);
}

.swm-modal-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  display: none;
}

.swm-modal-error.active {
  display: block;
}

.swm-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

#confirm-quote {
  background: #111 !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 13px 32px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: background 0.15s !important;
  white-space: nowrap;
}

#confirm-quote:hover {
  background: #333 !important;
}

#confirm-quote:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.swm-feedback-content {
  width: 100%;
  max-width: min(92vw, 460px);
  text-align: center;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  padding: 36px 28px 28px;
  margin: auto 0;
  box-sizing: border-box;
}

.swm-feedback-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
}

.swm-feedback-content.is-success .swm-feedback-icon {
  background: #dcfce7;
  color: #166534;
}

.swm-feedback-content.is-success .swm-feedback-icon::before {
  content: "✓";
}

.swm-feedback-content.is-error .swm-feedback-icon {
  background: #fee2e2;
  color: #991b1b;
}

.swm-feedback-content.is-error .swm-feedback-icon::before {
  content: "!";
}

#swm-feedback-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: #111827;
}

#swm-feedback-message {
  margin: 0 0 16px;
  font-size: 16px;
  color: #374151;
  line-height: 1.5;
}

#swm-feedback-pdf {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  color: #1d4ed8;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .swm-modal {
    padding: 20px 12px 32px;
    align-items: flex-start;
  }

  .swm-modal-content {
    padding: 24px 18px 20px;
    gap: 10px;
  }

  .swm-modal-content h3 {
    font-size: 19px;
  }

  .swm-modal-content input {
    min-height: 42px;
    font-size: 16px;
  }

  .swm-feedback-content {
    padding: 28px 18px 22px;
  }

  #swm-feedback-title {
    font-size: 22px;
  }

  #swm-feedback-message {
    font-size: 15px;
  }

  /* On mobile the toolbar leaves absolute mode and flows above the canvas. */
  .swm-designer-wrap {
    max-width: none;
  }

  #swm-tools-toggle {
    position: relative;
    top: auto;
    right: auto;
    align-self: flex-end;
    margin-bottom: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  }

  .swm-tools-panel {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    width: 100% !important;
    margin-bottom: 8px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  }

  #swm-hint {
    display: none !important;
  }

  .single-product div.product form.cart,
  .woocommerce div.product form.cart {
    grid-template-columns: auto 1fr;
  }

  .single-product div.product form.cart #quote-btn.swm-quote-inline-btn,
  .woocommerce div.product form.cart #quote-btn.swm-quote-inline-btn {
    font-size: 14px;
    padding: 10px 14px;
  }
}
