/**
 * Frontend styles.
 *
 * @package PDM_Product_Forms
 */

/* Product Form Container */
.pdm-product-form {
  margin: 30px 0;
  padding: 30px;
  background: #ffffff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pdm-product-form.pdm-form-hidden {
  display: none;
}

/* Purchase Options */
.pdm-purchase-options {
  margin: 30px 0;
  padding: 20px;
  background: var(--bg-block, #f9f9f9);
  border-radius: 5px;
  border: 2px solid var(--border-color, #e0e0e0);
}

.pdm-purchase-options h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 18px;
  color: var(--title-color, #333);
  font-family: var(--e-global-typography-primary-font-family, inherit);
  font-weight: 700;
}

.pdm-option-buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.pdm-option-buttons .button {
  flex: 1;
  min-width: 200px;
  display: inline-block;
  padding: 0 15px;
  font-size: 16px;
  height: 50px;
  line-height: 48px;
  font-weight: 700;
  text-transform: capitalize;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  vertical-align: middle;
  box-shadow: none;
  text-shadow: none;
  outline: none !important;
  font-family: var(--e-global-typography-primary-font-family, inherit);
}

.pdm-option-customize {
  background: #e37ef4 !important;
  background: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-option-customize:hover {
  background: #cd72dc !important;
  background: var(--darken10, #cd72dc) !important;
  border-color: #cd72dc !important;
  border-color: var(--darken10, #cd72dc) !important;
  transform: translateY(-2px);
}

.pdm-option-direct {
  background: none !important;
  color: #e37ef4 !important;
  color: var(--primary-color, #e37ef4) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-option-direct:hover {
  background: #e37ef4 !important;
  background: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  transform: translateY(-2px);
}

.pdm-option-customize:disabled,
.pdm-option-customize.disabled,
.pdm-option-direct:disabled,
.pdm-option-direct.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.pdm-option-customize:disabled:hover,
.pdm-option-customize.disabled:hover {
  background: var(--primary-color, #e37ef4) !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-option-direct:disabled:hover,
.pdm-option-direct.disabled:hover {
  background: none !important;
  color: var(--primary-color, #e37ef4) !important;
}

/* Steps */
.pdm-form-steps {
  margin-bottom: 25px;
}

.pdm-form-step {
  display: none;
}

.pdm-form-step.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

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

.pdm-step-header {
  margin-bottom: 20px;
}

.pdm-step-header h4 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: #333;
}

.pdm-step-description {
  margin: 0;
  color: #666;
  font-size: 14px;
}

/* Fields */
.pdm-step-fields {
  display: grid;
  gap: 20px;
}

.pdm-form-field {
  display: flex;
  flex-direction: column;
}

.pdm-form-field label {
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.pdm-form-field .required {
  color: #dc3232;
  margin-left: 3px;
}

.pdm-input {
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

.pdm-input:focus {
  outline: none;
  border-color: #2271b1;
  box-shadow: 0 0 0 1px #2271b1;
}

.pdm-form-field textarea.pdm-input {
  min-height: 100px;
  resize: vertical;
}

/* Radio and Checkbox Groups */
.pdm-radio-group,
.pdm-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdm-radio-label,
.pdm-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

.pdm-radio-label input,
.pdm-checkbox-label input {
  margin: 0;
  width: auto;
}

/* Field Errors */
.pdm-form-field.has-error .pdm-input {
  border-color: #dc3232;
}

.pdm-field-error {
  color: #dc3232;
  font-size: 12px;
  margin-top: 5px;
  display: block;
}

/* Navigation */
.pdm-form-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding-top: 25px;
  border-top: 2px solid var(--border-color, #e0e0e0);
}

.pdm-step-indicator {
  font-weight: 600;
  color: var(--content-color, #666);
  font-size: 14px;
}

.pdm-nav-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.pdm-form-navigation .button {
  display: inline-block;
  padding: 0 15px;
  font-size: 16px;
  height: 50px;
  line-height: 48px;
  font-weight: 700;
  text-transform: capitalize;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  vertical-align: middle;
  box-shadow: none;
  text-shadow: none;
  outline: none !important;
  font-family: var(--e-global-typography-primary-font-family, inherit);
  white-space: nowrap;
}

.pdm-prev-step {
  background: none !important;
  color: #e37ef4 !important;
  color: var(--primary-color, #e37ef4) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-prev-step:hover {
  background: #e37ef4 !important;
  background: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  transform: translateY(-2px);
}

.pdm-next-step {
  background: #e37ef4 !important;
  background: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-next-step:hover {
  background: #cd72dc !important;
  background: var(--darken10, #cd72dc) !important;
  border-color: #cd72dc !important;
  border-color: var(--darken10, #cd72dc) !important;
  transform: translateY(-2px);
}

.pdm-complete-form {
  background: none !important;
  color: #e37ef4 !important;
  color: var(--primary-color, #e37ef4) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
}

.pdm-complete-form:hover {
  background: #e37ef4 !important;
  background: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  transform: translateY(-2px);
}

/* Messages */
.pdm-form-messages {
  margin-top: 15px;
}

.pdm-message {
  padding: 12px 15px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.pdm-message-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.pdm-message-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Theme Integration - Inherit theme styles */
.pdm-product-form .pdm-input,
.pdm-product-form select.pdm-input,
.pdm-product-form textarea.pdm-input {
  font-family: inherit;
}

.pdm-product-form .button {
  font-family: inherit;
}

/* Responsive */
@media (max-width: 768px) {
  .pdm-product-form {
    padding: 20px;
  }

  .pdm-form-navigation {
    flex-wrap: wrap;
  }

  .pdm-step-indicator {
    width: 100%;
    text-align: center;
    order: -1;
    margin-bottom: 15px;
  }

  .pdm-nav-buttons {
    width: 100%;
  }

  .pdm-form-navigation .button {
    width: 100%;
  }

  .pdm-prev-step {
    width: 100%;
  }
}

/* WooCommerce Integration */
.single-product .pdm-product-form {
  margin: 30px 0;
}

/* Hide WooCommerce add to cart buttons when form is present and not completed */
body.single-product:has(.pdm-product-form:not(.pdm-form-completed))
  .woocommerce-variation-add-to-cart,
body.single-product:has(.pdm-product-form:not(.pdm-form-completed))
  .variations_button {
  display: none !important;
}

/* Show WooCommerce add to cart buttons when form is completed */
body.single-product:has(.pdm-product-form.pdm-form-completed)
  .woocommerce-variation-add-to-cart,
body.single-product:has(.pdm-product-form.pdm-form-completed)
  .variations_button,
body.single-product:has(.pdm-product-form.pdm-form-bypassed)
  .woocommerce-variation-add-to-cart,
body.single-product:has(.pdm-product-form.pdm-form-bypassed)
  .variations_button {
  display: block !important;
}

body.single-product:has(.pdm-product-form.pdm-form-completed)
  .woocommerce-variation-add-to-cart,
body.single-product:has(.pdm-product-form.pdm-form-bypassed)
  .woocommerce-variation-add-to-cart {
  display: flex !important;
}

/* Custom Alert Overlay */
.pdm-custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.pdm-custom-alert-overlay.pdm-alert-show {
  opacity: 1;
  visibility: visible;
}

.pdm-custom-alert {
  background: #fff;
  border-radius: 15px;
  padding: 40px 30px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.7);
  transition: transform 0.3s ease;
}

.pdm-alert-show .pdm-custom-alert {
  transform: scale(1);
}

.pdm-alert-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #e37ef4 0%, #cd72dc 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  color: #fff;
  margin: 0 auto 20px;
  animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.pdm-alert-title {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  margin: 0 0 15px 0;
}

.pdm-alert-message {
  font-size: 16px;
  color: #666;
  line-height: 1.6;
  margin: 0 0 25px 0;
}

.pdm-alert-message strong {
  color: #e37ef4;
  font-weight: 600;
}

.pdm-alert-close {
  background: linear-gradient(135deg, #e37ef4 0%, #cd72dc 100%);
  color: #fff;
  border: none;
  padding: 15px 40px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(227, 126, 244, 0.4);
}

.pdm-alert-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(227, 126, 244, 0.6);
}

/* Disabled fields styling */
.pdm-field-disabled {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.pdm-field-disabled::after {
  content: "🔒";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 18px;
  opacity: 0.6;
}

.pdm-field-disabled .pdm-input {
  background-color: #f5f5f5 !important;
  cursor: not-allowed !important;
  border-color: #ddd !important;
}

/* Success message styling */
.pdm-message-success {
  animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* WooCommerce Variation Select Styling - Match .pdm-option-direct (Outline Style) */
.single-product .variations select,
.single-product .variations select#pa_taille,
.single-product table.variations select,
.single-product select#pa_taille,
.single-product select[name="attribute_pa_taille"] {
  display: inline-block;
  padding: 0 15px;
  font-size: 16px;
  height: 50px;
  line-height: 48px;
  font-weight: 700;
  text-transform: capitalize;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  vertical-align: middle;
  box-shadow: none !important;
  text-shadow: none !important;
  outline: none !important;
  font-family: var(--e-global-typography-primary-font-family, inherit);
  background: #fff !important;
  background-color: #fff !important;
  color: #e37ef4 !important;
  color: var(--primary-color, #e37ef4) !important;
  border: 2px solid #e37ef4 !important;
  border-color: var(--primary-color, #e37ef4) !important;
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e37ef4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 15px center !important;
  background-size: 20px !important;
  padding-right: 45px !important;
}

/* Remove any pseudo-elements added by theme on select and parent containers */
.single-product .variations select::before,
.single-product .variations select::after,
.single-product .variations select#pa_taille::before,
.single-product .variations select#pa_taille::after,
.single-product table.variations select::before,
.single-product table.variations select::after,
.single-product .variations .value::before,
.single-product .variations .value::after,
.single-product table.variations td::before,
.single-product table.variations td::after,
.single-product .variations td.value::before,
.single-product .variations td.value::after {
  display: none !important;
  content: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Ensure parent containers don't add background images */
.single-product .variations .value,
.single-product table.variations td,
.single-product .variations td.value {
  background-image: none !important;
  position: relative;
}

/* Custom "Autre" taille field styling */
.pdm-taille-autre-cell {
  padding: 0 !important;
  border: none !important;
}

.pdm-taille-autre-wrapper {
  padding: 15px;
  background: #f9f9f9;
  border-radius: 5px;
  border: 2px solid #e37ef4;
  animation: slideDown 0.3s ease-out;
}

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

.pdm-taille-autre-wrapper label {
  color: #333 !important;
  font-weight: 600 !important;
  margin-bottom: 8px !important;
}

.pdm-taille-autre-wrapper input {
  width: 100% !important;
  padding: 12px 15px !important;
  font-size: 14px !important;
  border: 2px solid #e37ef4 !important;
  border-radius: 5px !important;
  outline: none !important;
  transition: all 0.2s ease !important;
  background: #fff !important;
}

.pdm-taille-autre-wrapper input:focus {
  box-shadow: 0 0 0 3px rgba(227, 126, 244, 0.3) !important;
  border-color: #cd72dc !important;
}

.pdm-taille-autre-wrapper input::placeholder {
  color: #999 !important;
  font-style: italic;
}

.single-product .variations select:hover,
.single-product .variations select#pa_taille:hover,
.single-product table.variations select:hover,
.single-product select#pa_taille:hover,
.single-product select[name="attribute_pa_taille"]:hover {
  background-color: #e37ef4 !important;
  background-color: var(--primary-color, #e37ef4) !important;
  color: #fff !important;
  color: var(--white-color, #fff) !important;
  transform: translateY(-2px);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 15px center !important;
  background-size: 20px !important;
}

.single-product .variations select:focus,
.single-product .variations select#pa_taille:focus,
.single-product table.variations select:focus,
.single-product select#pa_taille:focus,
.single-product select[name="attribute_pa_taille"]:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(227, 126, 244, 0.3) !important;
}

/* Style the variation label to match */
.single-product .variations th.label,
.single-product table.variations th.label {
  font-weight: 700;
  color: var(--title-color, #333);
  font-family: var(--e-global-typography-primary-font-family, inherit);
  font-size: 16px;
  padding-bottom: 10px;
}

/* Ensure variation table has proper spacing */
.single-product table.variations {
  margin-bottom: 20px;
}

.single-product table.variations td,
.single-product table.variations th {
  padding: 10px 0;
}

/* ===== Alert "sheet" style (mockup) ===== */
.pdm-custom-alert.pdm-alert--sheet {
  max-width: 720px; /* plus large pour le tableau */
  padding: 48px 40px;
  border-radius: 28px; /* coins très arrondis */
  border: 2px solid #2e2e2e; /* fin liseré noir/gris */
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.pdm-alert-header {
  margin-bottom: 28px;
}

.pdm-alert-title {
  font-size: 32px; /* grand titre */
  line-height: 1.25;
  font-weight: 800;
  color: #2e2e2e;
  margin: 0 0 14px 0;
  text-align: center;
}

.pdm-alert-subtitle {
  font-size: 16px;
  line-height: 1.6;
  color: #444;
  text-align: center;
  margin: 0;
}

.pdm-alert-table-wrap {
  margin: 26px auto 28px;
  border: 2px solid #2e2e2e;
  border-radius: 12px;
  overflow: hidden; /* arrondis effectifs */
  background: #fff;
}

.pdm-alert-table {
  width: 100%;
  border-collapse: collapse; /* supprime les “interstices” */
  table-layout: fixed;
}

.pdm-alert-table thead th {
  font-weight: 700;
  padding: 14px 18px;
  text-align: left;
  background: #fafafa;
  color: #2e2e2e;
  border-bottom: 2px solid #2e2e2e; /* trait horizontal net */
}

.pdm-alert-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid #e8e8e8;
  vertical-align: middle;
  font-size: 15px;
  color: #2e2e2e;
  text-align: left;
}

.pdm-alert-table tbody tr:last-child td {
  border-bottom: none;
}

.pdm-td-label {
  width: 46%;
}

.pdm-td-value {
  width: 54%;
  color: #333;
}

.pdm-alert-actions {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* Harmonise le bouton avec le style mockup */
.pdm-alert-close {
  border-radius: 999px;
  padding: 14px 34px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 600px) {
  .pdm-custom-alert.pdm-alert--sheet {
    padding: 34px 22px;
    border-radius: 20px;
  }
  .pdm-alert-title {
    font-size: 24px;
  }
  .pdm-alert-table tbody td,
  .pdm-alert-table thead th {
    padding: 12px 14px;
  }
}
