/*
 * EmpireGlo Wishlist — Structural Styles Only
 * Version: 1.2.0
 *
 * PHILOSOPHY
 * ──────────
 * This file is STRUCTURE ONLY: layout, positioning, overflow, responsive.
 * Colors, fonts, backgrounds, shadows, and borders are intentionally absent —
 * they are provided by the active theme automatically.
 *
 * Action buttons carry WooCommerce's native `.button` / `.button.alt` class,
 * so they match the theme's button styles on every client site with zero setup.
 *
 * OPTIONAL per-client tweaks — add to child theme style.css:
 *   .egw-wishlist-wrap   { --egw-radius: 4px; }
 *   .egw-product-name    { font-weight: 700; }
 *   .egw-add-to-wishlist-btn { gap: 8px; }
 */

/* ── CSS Variables — defaults, overridden by inline style from plugin admin ── */
:root {
  --egw-accent: #c0392b;
  --egw-radius: 6px;
}

/* ── Accent-dependent rules (all other colours come from the theme) ── */

/* Heart turns accent when active */
.egw-add-to-wishlist-btn:hover { color: var(--egw-accent); }
.egw-add-to-wishlist-btn.egw-in-wishlist { color: var(--egw-accent); }

/* Popup heart icon */
.egw-popup-heart { color: var(--egw-accent); }

/* Product name hover */
.egw-product-name:hover { color: var(--egw-accent); }

/* Active pagination */
.egw-page-link.current,
.egw-page-link:hover { color: var(--egw-accent); }

/* Active wishlist nav tab */
.egw-wishlist-nav-item.active,
.egw-wishlist-nav-item:hover { color: var(--egw-accent); }

/* Wishlist card title hover */
.egw-wishlist-card-title a:hover { color: var(--egw-accent); }

/* Input/textarea focus ring */
.egw-qty-input:focus,
.egw-move-item-select:focus,
.egw-share-url-input:focus,
.egw-form-group input[type="text"]:focus,
.egw-form-group textarea:focus,
.egw-wishlist-dropdown:focus { outline: 2px solid var(--egw-accent); outline-offset: 1px; }

/* Editable title focus indicator */
.egw-wishlist-title.egw-title-editable[contenteditable="true"] {
  border-bottom: 1px solid var(--egw-accent);
}

/* Border radius from admin setting */
.egw-product-thumb  { border-radius: var(--egw-radius); }
.egw-modal-inner    { border-radius: var(--egw-radius); }
.egw-popup-card     { border-radius: var(--egw-radius); }
.egw-wishlist-card  { border-radius: var(--egw-radius); }
.egw-qty-input      { border-radius: calc(var(--egw-radius) / 2); }
.egw-move-item-select { border-radius: calc(var(--egw-radius) / 2); }
.egw-share-url-input  { border-radius: calc(var(--egw-radius) / 2); }
.egw-form-group input[type="text"],
.egw-form-group textarea { border-radius: calc(var(--egw-radius) / 2); }

/* ── Add-to-Wishlist button wrapper ── */
.egw-button-wrap {
  display: inline-block;
  vertical-align: middle;
}

/* ── Heart button — no visual opinion, just layout ── */
.egw-add-to-wishlist-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  color: inherit;
  font: inherit;
}

/* Heart SVG — scales with surrounding font size */
.egw-icon-heart {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: fill .15s, transform .15s;
}

.egw-in-wishlist .egw-icon-heart,
.egw-icon-heart.egw-heart-filled {
  fill: currentColor;
}

.egw-add-to-wishlist-btn:active .egw-icon-heart {
  transform: scale(1.3);
}

/* Spinner */
.egw-loading-spinner { display: inline-flex; }

.egw-spinner {
  width: 1em;
  height: 1em;
  animation: egw-spin 0.8s linear infinite;
}

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

/* Count badge (My Account nav) */
.egw-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  line-height: 1;
}

/* ── Wishlist page header ── */
.egw-wishlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
}

.egw-wishlist-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.egw-wishlist-title { margin: 0; }

.egw-wishlist-title.egw-title-editable { cursor: text; }

.egw-wishlist-title.egw-title-editable:focus,
.egw-wishlist-title.egw-title-editable[contenteditable="true"] {
  outline: none;
}

.egw-title-edit-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
}

.egw-wishlist-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Privacy badge */
.egw-privacy-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Wishlist table ── */
.egw-wishlist-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.egw-wishlist-table {
  width: 100%;
  border-collapse: collapse;
}

.egw-wishlist-table th {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.egw-wishlist-table td {
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

/* Column widths */
.egw-col-check   { width: 36px; }
.egw-col-thumb   { width: 70px; }
.egw-col-price   { width: 90px;  white-space: nowrap; }
.egw-col-stock   { width: 100px; white-space: nowrap; }
.egw-col-qty     { width: 70px; }
.egw-col-date    { width: 90px;  white-space: nowrap; }
.egw-col-move    { width: 130px; }
.egw-col-actions { width: 160px; white-space: nowrap; text-align: right; }

td.egw-col-actions { text-align: right; vertical-align: middle; }

/* Product thumbnail */
.egw-product-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  display: block;
}

/* Product name link */
.egw-product-name {
  display: block;
  text-decoration: none;
  margin-bottom: 2px;
  color: inherit;
}

.egw-product-desc { display: block; }

/* Qty input */
.egw-qty-input {
  width: 56px;
  padding: 5px 6px;
  text-align: center;
  background: transparent;
}

/* Move-to select */
.egw-move-item-select {
  max-width: 120px;
  padding: 5px 6px;
  background: transparent;
}

/* ── Wishlist footer ── */
.egw-wishlist-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Pagination ── */
.egw-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.egw-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  text-decoration: none;
}

/* ── Empty state ── */
.egw-wishlist-empty     { text-align: center; padding: 60px 20px; }
.egw-empty-illustration { margin-bottom: 20px; }
.egw-empty-heart-svg    { width: 80px; height: 80px; opacity: 0.15; }
.egw-empty-title        { margin-bottom: 8px; }
.egw-empty-text         { margin-bottom: 24px; }

/* ── Multiple wishlists grid ── */
.egw-wishlists-overview { width: 100%; }

.egw-wishlists-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.egw-wishlists-title { margin: 0; }

.egw-wishlists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.egw-wishlist-card        { padding: 18px; }

.egw-wishlist-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.egw-wishlist-card-title   { margin: 0; }
.egw-wishlist-card-title a { text-decoration: none; color: inherit; }
.egw-wishlist-card-body    { margin-bottom: 14px; }
.egw-wishlist-card-footer  { display: flex; gap: 8px; }

/* Wishlist tabs nav */
.egw-wishlist-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 28px;
  padding-top: 16px;
}

.egw-wishlist-nav-label { margin-right: 4px; }

.egw-wishlist-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  text-decoration: none;
  color: inherit;
}

/* ── Share area ── */
.egw-share-area   { margin-bottom: 24px; padding: 14px 16px; }
.egw-share-heading { margin-bottom: 10px; }

.egw-social-share {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* Social network links — brand colors are fixed (they're the network's own brand) */
.egw-social-share-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 500;
  text-decoration: none;
  color: #fff;
}

.egw-social-share-link svg { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }

.egw-share-facebook  { background: #1877f2; }
.egw-share-twitter   { background: #1da1f2; }
.egw-share-whatsapp  { background: #25d366; }
.egw-share-pinterest { background: #e60023; }
.egw-share-email     { background: #555; }

.egw-share-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.egw-share-url-input {
  flex: 1;
  padding: 7px 10px;
  min-width: 0;
  background: transparent;
}

/* ── Modals ── */
.egw-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Overlay must have a background — it is the backdrop, not a design choice */
.egw-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}

/* Modal panel must be visible — white is neutral */
.egw-modal-inner {
  position: relative;
  background: #fff;
  padding: 28px;
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

.egw-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.3em;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  color: inherit;
}

.egw-modal-inner h3 { margin-top: 0; margin-bottom: 20px; }

.egw-form-group { margin-bottom: 14px; }

.egw-form-group label  { display: block; margin-bottom: 5px; }

.egw-form-group input[type="text"],
.egw-form-group textarea {
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  background: transparent;
}

.egw-share-copy-wrap  { display: flex; gap: 8px; margin-bottom: 16px; }
.egw-share-social-row { margin-bottom: 20px; }

.egw-share-email-form h4 {
  margin-bottom: 14px;
  padding-top: 16px;
}

.egw-email-share-notice {
  display: block;
  margin-top: 10px;
  padding: 8px 12px;
}

/* ── Popup (bottom-right toast) ── */
.egw-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  pointer-events: none;
}

/* Popup card must be visible */
.egw-popup-card {
  position: relative;
  background: #fff;
  padding: 22px;
  width: min(300px, calc(100vw - 32px));
  pointer-events: auto;
  animation: egw-slide-in 0.3s cubic-bezier(.16,1,.3,1);
}

@keyframes egw-slide-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.egw-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  color: inherit;
}

.egw-popup-icon { text-align: center; margin-bottom: 10px; }

.egw-popup-heart {
  width: 36px;
  height: 36px;
  fill: currentColor;
  animation: egw-heartbeat 0.5s ease;
}

@keyframes egw-heartbeat {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.egw-popup-message { text-align: center; margin: 0 0 14px; }

.egw-popup-wishlist-select         { margin-bottom: 12px; }
.egw-popup-wishlist-select label   { display: block; margin-bottom: 4px; }
.egw-wishlist-dropdown             { width: 100%; padding: 6px 8px; background: transparent; }

.egw-popup-actions { display: flex; flex-direction: column; gap: 8px; }

.egw-popup-actions .egw-btn,
.egw-popup-actions .button {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* ── Notices ── */
.egw-notice { padding: 12px 16px; margin-bottom: 16px; }

/* ── Disabled state ── */
.egw-btn:disabled,
button.egw-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Admin ── */
.egw-admin-wrap .nav-tab-wrapper { margin-bottom: 0; }
.egw-analytics-table th,
.egw-analytics-full-table th     { font-weight: 600; }

/* ── Image Overlay — button floating over product thumbnail ── */
.egw-product-image-wrap {
  position: relative;
  display: block;
  overflow: hidden;
}

.egw-image-overlay-wrap {
  position: absolute;
  z-index: 10;
  line-height: 1;
}

.egw-overlay-top-right    { top: 10px;    right: 10px; }
.egw-overlay-top-left     { top: 10px;    left: 10px;  }
.egw-overlay-bottom-right { bottom: 10px; right: 10px; }
.egw-overlay-bottom-left  { bottom: 10px; left: 10px;  }

.egw-image-overlay-wrap .egw-button-wrap { margin: 0; }

/* Ensure loop product cards have stacking context for overlay */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
  position: relative;
}

/* ── Single product page spacing ── */
.woocommerce div.product .egw-button-wrap {
  display: block;
  margin: 8px 0;
}

.woocommerce div.product form.cart + .egw-button-wrap {
  margin-top: 12px;
}

/* ── RTL ── */
[dir="rtl"] .egw-overlay-top-right    { right: auto; left: 10px; }
[dir="rtl"] .egw-overlay-top-left     { left: auto;  right: 10px; }
[dir="rtl"] .egw-overlay-bottom-right { right: auto; left: 10px; }
[dir="rtl"] .egw-overlay-bottom-left  { left: auto;  right: 10px; }
[dir="rtl"] .egw-wishlist-header-actions { justify-content: flex-end; }
[dir="rtl"] .egw-col-actions             { text-align: left; }

/* =========================================================================
   RESPONSIVE
   =========================================================================

   Mobile (≤600px): Slim row layout.
   Hides non-essential columns. Keeps: thumbnail | name | price | actions.
   ========================================================================= */
@media (max-width: 600px) {

  .egw-wishlist-wrap {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Hide non-essential columns */
  .egw-wishlist-table .egw-col-check,
  .egw-wishlist-table .egw-col-stock,
  .egw-wishlist-table .egw-col-qty,
  .egw-wishlist-table .egw-col-date,
  .egw-wishlist-table .egw-col-move {
    display: none !important;
  }

  .egw-wishlist-table th,
  .egw-wishlist-table td { padding: 10px 8px; }

  .egw-product-thumb { width: 48px; height: 48px; }
  .egw-col-thumb     { width: 56px; }
  .egw-col-price     { width: 70px; }

  .egw-col-actions   { width: auto; white-space: normal; text-align: right; }
  td.egw-col-actions { display: table-cell; }

  /* Stack cart + remove vertically */
  td.egw-col-actions .egw-btn-cart,
  td.egw-col-actions .button { display: block; width: 100%; margin-bottom: 4px; text-align: center; }
  td.egw-col-actions .egw-btn-remove { display: block; text-align: center; }

  /* Footer: full-width buttons */
  .egw-wishlist-footer               { flex-direction: column; align-items: stretch; }
  .egw-wishlist-footer .egw-btn,
  .egw-wishlist-footer .button       { width: 100%; text-align: center; }

  /* Header: stack */
  .egw-wishlist-header        { flex-direction: column; align-items: flex-start; }
  .egw-wishlist-header-actions { width: 100%; }

  /* Popup: centered at bottom */
  .egw-popup-overlay { align-items: flex-end; justify-content: center; padding: 0 12px 16px; }

  /* Multi-wishlist: single column */
  .egw-wishlists-grid { grid-template-columns: 1fr; }

  /* Modal: bottom sheet */
  .egw-modal       { align-items: flex-end; padding: 0; }
  .egw-modal-inner { padding: 20px 16px; width: 100%; max-height: 85vh; }
}

/* Tablet (601px – 900px) */
@media (min-width: 601px) and (max-width: 900px) {
  .egw-wishlist-table .egw-col-date,
  .egw-wishlist-table .egw-col-move { display: none; }

  .egw-wishlist-table th,
  .egw-wishlist-table td { padding: 10px; }
}

/* Very small phones */
@media (max-width: 420px) {
  .egw-product-desc { display: none; }

  .egw-share-url-row   { flex-direction: column; }
  .egw-share-url-input,
  .egw-copy-link-btn   { width: 100%; }
}
