/* ============================================================
   Virtual Eyewear Try-On — Frontend CSS
   Professional Mobile-First Design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --ey-primary:     #0f0f23;
  --ey-accent:      #6c63ff;
  --ey-accent2:     #ff6584;
  --ey-gold:        #f59e0b;
  --ey-bg:          #f8f9fc;
  --ey-surface:     #ffffff;
  --ey-border:      #e4e6ef;
  --ey-text:        #1a1a2e;
  --ey-muted:       #8b8fa8;
  --ey-radius:      20px;
  --ey-radius-sm:   10px;
  --ey-shadow:      0 24px 64px rgba(15,15,35,0.22);
  --ey-shadow-sm:   0 4px 16px rgba(15,15,35,0.10);
  --ey-font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --ey-transition:  all 0.2s cubic-bezier(.4,0,.2,1);
  --ey-z:           100000;
  --ey-header-h:    52px;
  --ey-controls-h:  64px;
  --ey-panel-h:     148px;
  --ey-tabs-h:      42px;
  --ey-products-h:  200px;
}

/* ---- Trigger Buttons ---------------------------------------- */
.eyewear-tryon-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ey-font);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 22px;
  border-radius: 50px;
  border: 2px solid var(--ey-accent);
  background: var(--ey-accent);
  color: #fff;
  cursor: pointer;
  transition: var(--ey-transition);
  letter-spacing: 0.2px;
  margin: 8px 0;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.eyewear-tryon-trigger:hover {
  background: #5a52e0;
  border-color: #5a52e0;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(108,99,255,0.35);
}

.eyewear-loop-trigger {
  font-size: 12px;
  padding: 7px 16px;
  width: 100%;
  justify-content: center;
  margin-top: 6px;
}

#eyewear-home-cta {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}
.eyewear-float-cta {
  box-shadow: 0 8px 32px rgba(108,99,255,0.35);
  animation: eyewear-bounce 2.5s ease-in-out infinite;
}
@keyframes eyewear-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ---- Modal --------------------------------------------------- */
body.eyewear-modal-open { overflow: hidden; }

.eyewear-modal {
  position: fixed;
  inset: 0;
  z-index: var(--ey-z);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.eyewear-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10,10,20,0.8);
  backdrop-filter: blur(8px);
}

.eyewear-modal-container {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--ey-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  font-family: var(--ey-font);
  color: var(--ey-text);
  overflow: hidden;
}

@media (min-width: 768px) {
  .eyewear-modal {
    padding: 24px;
    align-items: center;
  }
  .eyewear-modal-container {
    border-radius: var(--ey-radius);
    max-height: 94vh;
    box-shadow: var(--ey-shadow);
  }
}

/* ---- Header -------------------------------------------------- */
.eyewear-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--ey-header-h);
  background: var(--ey-primary);
  color: #fff;
  flex-shrink: 0;
}

.eyewear-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--ey-font);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.eyewear-brand-icon {
  width: 32px;
  height: 32px;
  background: rgba(108,99,255,0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eyewear-header-actions {
  display: flex;
  gap: 6px;
}

.eyewear-btn-icon {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ey-transition);
  -webkit-tap-highlight-color: transparent;
}
.eyewear-btn-icon:hover { background: rgba(255,255,255,0.22); }

/* ---- Step: Camera ------------------------------------------- */
#eyewear-step-camera {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.eyewear-camera-area {
  flex: 1;
  position: relative;
  background: #060612;
  overflow: hidden;
}

#eyewear-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.eyewear-face-guide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.eyewear-face-oval {
  width: min(210px, 48vw);
  height: min(290px, 62vw);
  border: 2.5px dashed rgba(108,99,255,0.7);
  border-radius: 50%;
  animation: eyewear-pulse-oval 2s ease-in-out infinite;
}
@keyframes eyewear-pulse-oval {
  0%, 100% { border-color: rgba(108,99,255,0.6); }
  50%       { border-color: rgba(255,101,132,0.85); }
}

.eyewear-guide-text {
  margin-top: 14px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  background: rgba(0,0,0,0.45);
  padding: 6px 16px;
  border-radius: 50px;
}

#eyewear-camera-status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 50px;
  background: rgba(0,0,0,0.6);
  color: #fff;
}
.eyewear-status-error { background: var(--ey-accent2) !important; }

.eyewear-camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--ey-surface);
  border-top: 1px solid var(--ey-border);
  flex-shrink: 0;
}

/* ---- Buttons ------------------------------------------------- */
.eyewear-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--ey-font);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 50px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--ey-transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.eyewear-btn:active { transform: scale(0.97); }

.eyewear-btn-primary {
  background: var(--ey-accent);
  color: #fff;
  border-color: var(--ey-accent);
}
.eyewear-btn-primary:hover {
  background: #5a52e0;
  border-color: #5a52e0;
  box-shadow: 0 6px 20px rgba(108,99,255,0.4);
  color: #fff;
}

.eyewear-btn-outline {
  background: transparent;
  color: var(--ey-text);
  border-color: var(--ey-border);
}
.eyewear-btn-outline:hover {
  border-color: var(--ey-accent);
  color: var(--ey-accent);
}

.eyewear-btn-ghost {
  background: transparent;
  color: var(--ey-muted);
  border-color: transparent;
  font-weight: 500;
  padding: 7px 12px;
  font-size: 12px;
}
.eyewear-btn-ghost:hover {
  color: var(--ey-text);
  background: var(--ey-border);
}

.eyewear-btn-sm { padding: 7px 14px; font-size: 12px; }
.eyewear-full-width { width: 100%; justify-content: center; }

/* ================================================================
   STEP: TRY-ON  —  Mobile-First Full-Screen Layout
   ================================================================ */
#eyewear-step-tryon {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* On mobile: viewer fills available space, bottom sheet is fixed-height */
}

/* ---- Mobile layout: viewer fills screen, bottom is fixed ---- */
.eyewear-tryon-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* Viewer panel — full remaining height */
.eyewear-viewer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #060612;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.eyewear-canvas-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#eyewear-tryon-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.eyewear-detecting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(6,6,18,0.7);
  color: #fff;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
}

/* Retake button — overlay top-left */
.eyewear-retake-btn {
  position: absolute !important;
  top: 10px !important;
  left: 10px !important;
  background: rgba(0,0,0,0.55) !important;
  color: rgba(255,255,255,0.9) !important;
  border-color: rgba(255,255,255,0.2) !important;
  font-size: 12px !important;
  padding: 6px 12px !important;
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* ---- D-Pad adjustment controls — overlay bottom-right -------- */
.eyewear-adjust-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: 36px 36px 36px;
  grid-template-rows: 36px 36px;
  gap: 3px;
  z-index: 10;
}

.eyewear-adj-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ey-transition);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.eyewear-adj-btn:hover,
.eyewear-adj-btn:active {
  background: rgba(108,99,255,0.75);
  border-color: rgba(108,99,255,0.9);
  transform: scale(0.92);
}

/* D-pad positions */
.eyewear-adj-btn[data-action="move-left"]  { grid-column: 1; grid-row: 1; }
.eyewear-adj-btn[data-action="move-up"]    { grid-column: 2; grid-row: 1; }
.eyewear-adj-btn[data-action="move-right"] { grid-column: 3; grid-row: 1; }
.eyewear-adj-btn[data-action="move-down"]  { grid-column: 2; grid-row: 2; }

/* ---- Desktop: side-by-side ----------------------------------- */
@media (min-width: 768px) {
  .eyewear-tryon-layout {
    flex-direction: row;
  }
  .eyewear-viewer-panel {
    flex: 1;
  }
  .eyewear-adjust-controls {
    bottom: 14px;
    right: 14px;
  }
  .eyewear-product-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--ey-surface);
    border-left: 1px solid var(--ey-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 14px;
    overflow-y: auto;
  }
}

/* ---- Product panel (mobile: below canvas, hidden until selected) */
.eyewear-product-panel {
  background: var(--ey-surface);
  border-top: 1px solid var(--ey-border);
  padding: 12px 16px;
  flex-shrink: 0;
  gap: 10px;
  display: flex;
  flex-direction: column;
}

.eyewear-product-name {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: var(--ey-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eyewear-product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--ey-accent);
}

.eyewear-product-rating {
  color: var(--ey-gold);
  font-size: 13px;
  letter-spacing: 1.5px;
}

.eyewear-product-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

/* On mobile, product actions row */
@media (max-width: 767px) {
  .eyewear-product-panel {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 12px;
  }
  .eyewear-product-info {
    flex: 1;
    min-width: 0;
  }
  .eyewear-product-price { font-size: 15px; }
  .eyewear-product-name { font-size: 13px; }
  .eyewear-product-actions {
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
  }
  .eyewear-full-width { width: auto; }
  #eyewear-add-to-cart-btn {
    padding: 9px 16px;
    font-size: 13px;
  }
}

.eyewear-secondary-actions {
  display: flex;
  gap: 6px;
}
.eyewear-secondary-actions .eyewear-btn {
  flex: 1;
  justify-content: center;
  font-size: 12px;
  padding: 8px 10px;
}
@media (max-width: 767px) {
  .eyewear-secondary-actions { display: none; }
}

#eyewear-wishlist-btn.in-wishlist {
  background: #fff0f3;
  border-color: var(--ey-accent2);
  color: var(--ey-accent2);
}

.eyewear-cart-message {
  background: #f0fff6;
  border: 1px solid #6ee7b7;
  border-radius: var(--ey-radius-sm);
  padding: 10px 12px;
  font-size: 12px;
}
.eyewear-cart-links {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ---- AI Detection badge ------------------------------------- */
.eyewear-ai-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, rgba(108,99,255,0.9), rgba(255,101,132,0.9));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
  z-index: 10;
  display: none;
}
.eyewear-ai-badge.visible { display: block; }

/* ---- Filter tabs -------------------------------------------- */
.eyewear-filter-tabs {
  display: flex;
  overflow-x: auto;
  background: var(--ey-surface);
  border-top: 1px solid var(--ey-border);
  flex-shrink: 0;
  scrollbar-width: none;
  height: var(--ey-tabs-h);
  align-items: stretch;
}
.eyewear-filter-tabs::-webkit-scrollbar { display: none; }

.eyewear-filter-tab {
  flex-shrink: 0;
  padding: 0 16px;
  border: none;
  background: transparent;
  color: var(--ey-muted);
  font-family: var(--ey-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: var(--ey-transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.eyewear-filter-tab:hover { color: var(--ey-text); }
.eyewear-filter-tab.active {
  color: var(--ey-accent);
  border-bottom-color: var(--ey-accent);
  font-weight: 600;
}

/* ---- Products section --------------------------------------- */
.eyewear-products-section {
  background: var(--ey-surface);
  border-top: 1px solid var(--ey-border);
  flex-shrink: 0;
  padding: 10px 12px 10px;
}

.eyewear-products-search {
  margin-bottom: 8px;
}

.eyewear-products-search input {
  width: 100%;
  border: 1.5px solid var(--ey-border);
  border-radius: 50px;
  padding: 7px 16px;
  font-family: var(--ey-font);
  font-size: 13px;
  outline: none;
  transition: var(--ey-transition);
  box-sizing: border-box;
  background: var(--ey-bg);
  color: var(--ey-text);
}
.eyewear-products-search input:focus {
  border-color: var(--ey-accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
  background: #fff;
}

.eyewear-carousel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.eyewear-carousel-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--ey-border);
  border-radius: 50%;
  background: var(--ey-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ey-text);
  transition: var(--ey-transition);
  -webkit-tap-highlight-color: transparent;
}
.eyewear-carousel-arrow:hover {
  background: var(--ey-accent);
  color: #fff;
  border-color: var(--ey-accent);
}

.eyewear-products-grid {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.eyewear-products-grid::-webkit-scrollbar { display: none; }

.eyewear-products-loading,
.eyewear-no-results,
.eyewear-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 200px;
  color: var(--ey-muted);
  font-size: 13px;
  padding: 12px;
}

/* ---- Product Card ------------------------------------------- */
.eyewear-product-card {
  flex-shrink: 0;
  width: 110px;
  background: var(--ey-bg);
  border: 2px solid transparent;
  border-radius: var(--ey-radius-sm);
  cursor: pointer;
  transition: var(--ey-transition);
  scroll-snap-align: start;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.eyewear-product-card:hover {
  border-color: var(--ey-accent);
  box-shadow: var(--ey-shadow-sm);
  transform: translateY(-2px);
}
.eyewear-product-card.selected {
  border-color: var(--ey-accent);
  background: rgba(108,99,255,0.06);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.18);
}

.eyewear-card-img-wrap {
  position: relative;
  width: 100%;
  height: 72px;
  background: #f0f0f8;
  overflow: hidden;
}
.eyewear-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
  transition: var(--ey-transition);
}
.eyewear-product-card:hover .eyewear-card-img-wrap img { transform: scale(1.06); }

.eyewear-card-wish {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ey-muted);
  transition: var(--ey-transition);
  padding: 0;
  z-index: 2;
}
.eyewear-card-wish:hover,
.eyewear-card-wish.in-wishlist { color: var(--ey-accent2); }

.eyewear-out-of-stock {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: rgba(0,0,0,0.58);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  text-align: center;
  padding: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.eyewear-card-info {
  padding: 5px 7px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.eyewear-card-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--ey-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.eyewear-card-price {
  font-size: 11px;
  font-weight: 700;
  color: var(--ey-accent);
  line-height: 1;
}
.eyewear-card-stars {
  font-size: 9px;
  color: var(--ey-gold);
  line-height: 1;
}

/* ---- Spinner ------------------------------------------------ */
.eyewear-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--ey-border);
  border-top-color: var(--ey-accent);
  border-radius: 50%;
  animation: eyewear-spin 0.65s linear infinite;
}
@keyframes eyewear-spin { to { transform: rotate(360deg); } }

/* ---- Toast -------------------------------------------------- */
.eyewear-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: calc(var(--ey-z) + 10);
  padding: 11px 22px;
  border-radius: 50px;
  font-family: var(--ey-font);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.eyewear-toast-success { background: #10b981; }
.eyewear-toast-error   { background: var(--ey-accent2); }
.eyewear-toast-info    { background: var(--ey-accent); }

/* ---- WooCommerce -------------------------------------------- */
.woocommerce .eyewear-tryon-trigger {
  margin-left: 10px;
  vertical-align: middle;
}
