/* AI Virtual Try-On - Frontend Styles */
:root {
    --aivt-primary:     #2563eb;
    --aivt-primary-h:   #1d4ed8;
    --aivt-secondary:   #64748b;
    --aivt-secondary-h: #475569;
    --aivt-danger:      #ef4444;
    --aivt-success:     #22c55e;
    --aivt-bg:          #ffffff;
    --aivt-overlay:     rgba(0, 0, 0, 0.6);
    --aivt-radius:      12px;
    --aivt-shadow:      0 20px 60px rgba(0, 0, 0, 0.3);
    --aivt-transition:  0.25s ease;
    --aivt-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ========== BUTTON ========== */
.aivt-button-wrapper {
    margin: 16px 0;
    width: 100%;
}

.aivt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: var(--aivt-font);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--aivt-transition), transform 0.1s, box-shadow var(--aivt-transition);
    text-decoration: none;
    white-space: nowrap;
}

.aivt-btn-primary {
    background: var(--aivt-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.aivt-btn-primary:hover {
    background: var(--aivt-primary-h);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
    color: #ffffff;
    text-decoration: none;
}

.aivt-btn-primary:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.aivt-btn-secondary {
    background: var(--aivt-secondary);
    color: #ffffff;
}

.aivt-btn-secondary:hover {
    background: var(--aivt-secondary-h);
    color: #ffffff;
    text-decoration: none;
}

.aivt-btn-outline {
    background: transparent;
    color: var(--aivt-primary);
    border: 2px solid var(--aivt-primary);
}

.aivt-btn-outline:hover {
    background: var(--aivt-primary);
    color: #ffffff;
    text-decoration: none;
}

.aivt-btn-full {
    width: 100%;
}

.aivt-btn-icon {
    font-size: 18px;
}

/* ========== MODAL ========== */
.aivt-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    direction: rtl;
    font-family: var(--aivt-font);
}

.aivt-modal.aivt-modal--open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.aivt-modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--aivt-overlay);
    backdrop-filter: blur(4px);
    animation: aivt-fade-in 0.2s ease;
}

.aivt-modal-content {
    position: relative;
    background: var(--aivt-bg);
    border-radius: var(--aivt-radius);
    box-shadow: var(--aivt-shadow);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    animation: aivt-slide-in 0.25s ease;
    z-index: 1;
}

.aivt-modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 20px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    color: #64748b;
    transition: background var(--aivt-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.aivt-modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.aivt-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 24px;
    text-align: center;
}

/* ========== UPLOAD AREA ========== */
.aivt-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--aivt-transition), background var(--aivt-transition);
    position: relative;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    margin-bottom: 16px;
}

.aivt-upload-area:hover,
.aivt-upload-area.aivt-drag-over {
    border-color: var(--aivt-primary);
    background: #eff6ff;
}

.aivt-upload-area.aivt-has-image {
    border-style: solid;
    border-color: var(--aivt-success);
    background: #f0fdf4;
    padding: 8px;
}

.aivt-upload-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}

.aivt-upload-placeholder p {
    margin: 4px 0;
    color: #475569;
    font-size: 15px;
}

.aivt-upload-placeholder .aivt-upload-sub {
    font-size: 13px;
    color: #94a3b8;
}

.aivt-preview-img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

/* ========== USAGE INFO ========== */
.aivt-usage-info {
    font-size: 13px;
    color: #64748b;
    text-align: center;
    margin-bottom: 12px;
    min-height: 20px;
}

.aivt-usage-info .aivt-usage-warning {
    color: #ef4444;
    font-weight: 600;
}

/* ========== LOADING ========== */
.aivt-spinner {
    width: 52px;
    height: 52px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--aivt-primary);
    border-radius: 50%;
    animation: aivt-spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.aivt-loading-text {
    text-align: center;
    color: #475569;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
}

.aivt-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.aivt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--aivt-primary), #60a5fa);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
    animation: aivt-progress-pulse 2.5s ease-in-out infinite;
}

/* ========== RESULT ========== */
.aivt-result-label {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 16px;
}

.aivt-result-img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    margin-bottom: 20px;
    display: block;
}

.aivt-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.aivt-result-actions .aivt-btn {
    flex: 1;
    min-width: 120px;
}

/* ========== ERROR ========== */
.aivt-error-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 12px;
}

.aivt-error-message {
    text-align: center;
    color: var(--aivt-danger);
    font-size: 15px;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ========== SECTIONS ========== */
.aivt-section {
    padding: 4px 0;
}

/* ========== ANIMATIONS ========== */
@keyframes aivt-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes aivt-slide-in {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes aivt-progress-pulse {
    0%   { width: 10%; }
    50%  { width: 75%; }
    100% { width: 90%; }
}

/* ========== MOBILE ========== */
@media (max-width: 600px) {
    .aivt-modal-content {
        width: 96%;
        padding: 20px 16px;
    }

    .aivt-result-actions {
        flex-direction: column;
    }

    .aivt-result-actions .aivt-btn {
        width: 100%;
    }
}

/* ========== NOTICE ========== */
.aivt-notice {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 14px 16px;
    color: #78350f;
    font-size: 14px;
    text-align: center;
    margin: 8px 0 16px;
}

/* ========== CACHED BADGE ========== */
.aivt-cached-badge {
    text-align: center;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

/* ========== ELEMENTOR COMPAT ========== */
.elementor-widget-woocommerce-product-add-to-cart .aivt-button-wrapper,
.elementor .aivt-button-wrapper {
    margin-top: 12px;
}

/* Ensure modal sits above Elementor popups */
.aivt-modal {
    z-index: 999999 !important;
}

/* =========================
   1) כפתור "נסה עליי" כמו "הוספה לסל"
   ========================= */

.single-product form.cart,
.woocommerce div.product form.cart {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
}

.aivt-button-wrapper {
  display: inline-flex;
  align-items: stretch;
  margin: 0;
}

.aivt-open-modal.aivt-btn,
.single-product form.cart .single_add_to_cart_button,
.woocommerce div.product form.cart .single_add_to_cart_button {
  min-width: 170px;
  height: 56px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}

.aivt-open-modal.aivt-btn {
  white-space: nowrap;
}

/* =========================
   2) שלא יישבר/יזוז כפתור הוספה לסל
   ========================= */

.single-product form.cart .quantity,
.woocommerce div.product form.cart .quantity {
  margin-bottom: 0;
}

.single-product form.cart .single_add_to_cart_button,
.woocommerce div.product form.cart .single_add_to_cart_button {
  float: none;
}

/* =========================
   3) תיקון לכותרת במודל כדי שלא תהיה מתחת לאיקס
   ========================= */

#aivt-modal-content,
.aivt-modal-content {
  position: relative;
  padding-top: 44px;
}

#aivt-modal-close,
.aivt-modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
}

#aivt-upload-section .aivt-modal-title,
#aivt-result-section .aivt-modal-title,
#aivt-error-section .aivt-modal-title,
#aivt-modal h3 {
  display: block;
  margin: 0 48px 14px 48px;
  font-size: 18px;
  line-height: 1.5;
  text-align: center;
  word-break: break-word;
}

/* =========================
   4) מובייל
   ========================= */

@media (max-width: 767px) {
  .single-product form.cart,
  .woocommerce div.product form.cart {
    flex-direction: column;
    gap: 10px;
  }

  .aivt-button-wrapper,
  .aivt-open-modal.aivt-btn,
  .single-product form.cart .single_add_to_cart_button,
  .woocommerce div.product form.cart .single_add_to_cart_button {
    width: 100%;
    min-width: 100%;
  }

  #aivt-upload-section .aivt-modal-title,
  #aivt-result-section .aivt-modal-title,
  #aivt-error-section .aivt-modal-title,
  #aivt-modal h3 {
    margin: 0 40px 12px 40px;
    font-size: 16px;
    line-height: 1.45;
  }

  #aivt-modal-close,
  .aivt-modal-close {
    top: 12px;
    left: 12px;
  }
}

/* יישור מושלם בין הכפתורים */

.single-product form.cart,
.woocommerce div.product form.cart {
  display: flex;
  align-items: center !important;
  gap: 12px;
}

/* שני הכפתורים בדיוק באותו קו */
.aivt-open-modal.aivt-btn,
.single-product form.cart .single_add_to_cart_button {
  height: 50px !important;
  line-height: 50px !important;
  padding: 0 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ביטול מרווחים שגורמים לזוז */
.single-product form.cart .single_add_to_cart_button {
  margin: 0 !important;
}

.aivt-button-wrapper {
  margin: 0 !important;
  display: flex;
  align-items: center;
}
