/* ===== Woodmart theme color integration ===== */
:root{
  /* Use Woodmart's primary color with fallback */
  --twp-primary: var(--wd-primary-color, #ec4a5a);
  --twp-primary-600: var(--wd-primary-color-darken, #d63f4e);
  
  /* Use Woodmart's text colors with fallbacks */
  --twp-gray-900: var(--wd-text-color, #1f2937);
  --twp-gray-700: var(--wd-text-color-alt, #374151);
  --twp-gray-600: var(--color-gray-600, #4b5563);
  --twp-gray-500: var(--color-gray-500, #6b7280);
  --twp-gray-300: var(--brdcolor-gray-300, #d1d5db);
  --twp-gray-200: var(--brdcolor-gray-200, #e5e7eb);
  --twp-gray-100: var(--bgcolor-gray-100, #f3f4f6);
  
  /* Keep consistent radius and shadows */
  --twp-radius-xl:22px;
  --twp-shadow-lg:0 20px 60px rgba(0,0,0,.18);
  --twp-shadow-sm:0 6px 18px rgba(0,0,0,.08);
}

.twp-modal-backdrop{
  position:fixed; inset:0;
  background:rgba(17,24,39,.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index:9998; display:none;
}
.twp-modal{
  position:fixed; inset:0; display:none;
  align-items:center; justify-content:center;
  padding:24px; z-index:9999;
}
.twp-card{
  background:#fff; border-radius:var(--twp-radius-xl);
  width:min(560px, 92vw);
  max-height: 85vh;
  box-shadow:var(--twp-shadow-lg);
  padding:22px 22px 18px;
  animation:twp-pop .18s ease-out both;
  display: flex;
  flex-direction: column;
}
@keyframes twp-pop{
  from{transform:translateY(8px) scale(.98); opacity:.0}
  to{transform:translateY(0) scale(1); opacity:1}
}

/* Header */
.twp-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 12px 0;
}

.twp-logo img {
  max-width: 140px;
  max-height: 45px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.twp-logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--twp-gray-900);
  text-align: center;
}

.twp-head h3{
  margin:8px 0 6px; font-size:22px; line-height:1.2;
  color:var(--twp-gray-900); font-weight:800; letter-spacing:.2px;
}
.twp-sub{margin:0; color:var(--twp-gray-500); font-size:14.5px}

/* Badge (matches “Weekly Discounts” chip look) */
.twp-badge{
  display:inline-flex; align-items:center; gap:8px;
  font-size:12px; font-weight:700; color:#0f5132;
  background:#d1fae5; /* minty */
  border:1px solid #a7f3d0; border-radius:9999px;
  padding:6px 10px;
}

/* Field */
.twp-row{margin-top:14px}
.twp-field{width:100%}
.twp-label{
  display:block; font-size:12px; font-weight:700;
  color:var(--twp-gray-600); margin:10px 0 6px;
}
.twp-row select{
  width:100%;
  height: 60px;
  padding:12px 42px 12px 14px;
  border:1px solid var(--twp-gray-200);
  border-radius:14px; background:#fff;
  color:var(--twp-gray-900); font-size:15px;
  box-shadow:var(--twp-shadow-sm);
  appearance:none; -webkit-appearance:none;
  background-image:
    linear-gradient(transparent,transparent),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 8 10 12 14 8'/></svg>");
  background-repeat:no-repeat;
  background-position: right 12px center, 0 0;
  background-size: 22px 22px, 0 0;
}
.twp-row select:focus{
  outline:none; border-color:var(--twp-primary);
  box-shadow:0 0 0 4px rgba(236,74,90,.12), var(--twp-shadow-sm);
}

/* Actions */
.twp-actions{
  display:flex; gap:10px; justify-content:flex-end;
  margin-top:16px; padding-top:12px; border-top:1px solid var(--twp-gray-100);
}
.button{
  border:1px solid var(--twp-gray-200);
  background:#fff; color:var(--twp-gray-700);
  padding:10px 16px; border-radius:9999px;
  font-weight:700; font-size:14px; cursor:pointer;
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
.button:focus{outline:none; box-shadow:0 0 0 4px rgba(17,24,39,.08)}
.button:hover{transform:translateY(-1px); box-shadow:var(--twp-shadow-sm)}

.button.twp-ghost{
  background:#fafafa;
}
.button.twp-ghost:hover{
  background:#f5f5f5;
}

.button.twp-primary{
  background:var(--twp-primary); color:#fff;
  border-color:var(--twp-primary);
  box-shadow:0 6px 14px rgba(236,74,90,.28);
}
.button.twp-primary:hover{background:var(--twp-primary-600); border-color:var(--twp-primary-600)}
.button.twp-primary:active{transform:translateY(0) scale(.99)}

/* Close (top-right floating chip) */
.twp-close{
  position:absolute; top:10px; right:10px;
  width:34px; height:34px; border-radius:9999px;
  border:1px solid var(--twp-gray-200);
  background:#fff; color:var(--twp-gray-700);
  font-size:20px; line-height:1; display:grid; place-items:center;
  cursor:pointer; box-shadow:var(--twp-shadow-sm);
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.twp-close:hover{transform:translateY(-1px)}
.twp-close:focus{outline:none; box-shadow:0 0 0 4px rgba(17,24,39,.08)}

/* Show/Hide */
.twp-modal.active,.twp-modal-backdrop.active{display:flex}

/* Flag Grid - One-Click Country Selector */
.twp-flag-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
  padding: 5px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}

.twp-country-flag {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  min-height: 90px;
  background: #fff;
  border: 2px solid var(--twp-gray-200);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  box-shadow: var(--twp-shadow-sm);
}

.twp-country-flag:hover {
  border-color: var(--twp-primary);
  background: rgba(236, 74, 90, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(236, 74, 90, 0.16);
}

.twp-country-flag:focus {
  outline: none;
  border-color: var(--twp-primary);
  box-shadow: 0 0 0 4px rgba(236, 74, 90, 0.12), var(--twp-shadow-sm);
}

.twp-country-flag:active {
  transform: translateY(0) scale(0.98);
}

.twp-country-flag.twp-current {
  border-color: var(--twp-primary);
  background: rgba(236, 74, 90, 0.08);
  box-shadow: 0 0 0 3px rgba(236, 74, 90, 0.18);
}

.twp-country-flag.twp-current::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: var(--twp-primary);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.twp-flag-icon {
  width: 40px;
  height: 30px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.twp-flag-icon.fi {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.twp-flag-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--twp-gray-900);
  text-align: center;
  line-height: 1.2;
}

.twp-flag-currency {
  font-size: 11px;
  font-weight: 600;
  color: var(--twp-gray-500);
  background: var(--twp-gray-100);
  padding: 2px 8px;
  border-radius: 9999px;
  margin-top: 2px;
}

/* Loading Overlay */
.twp-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--twp-radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.twp-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--twp-gray-200);
  border-top-color: var(--twp-primary);
  border-radius: 50%;
  animation: twp-spin 0.8s linear infinite;
}

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

.twp-loading-text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--twp-gray-700);
}

/* Responsive Design */
@media (max-width: 640px) {
  .twp-card {
    padding: 16px 14px 14px;
    width: 94vw;
    max-height: 88vh;
  }
  
  .twp-logo {
    margin: 0 0 10px 0;
  }
  
  .twp-logo img {
    max-width: 110px;
    max-height: 36px;
  }
  
  .twp-logo-text {
    font-size: 17px;
  }
  
  .twp-head h3 {
    font-size: 18px;
    margin: 4px 0 4px;
  }
  
  .twp-sub {
    font-size: 12px;
  }
  
  .twp-flag-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
    max-height: calc(88vh - 90px);
  }
  
  .twp-country-flag {
    min-height: 68px;
    padding: 8px 5px;
    gap: 4px;
    border-width: 1.5px;
    border-radius: 10px;
  }
  
  .twp-flag-icon {
    width: 30px;
    height: 22.5px;
  }
  
  .twp-flag-name {
    font-size: 10px;
    line-height: 1.1;
    font-weight: 600;
  }
  
  .twp-flag-currency {
    font-size: 8.5px;
    padding: 1px 5px;
    margin-top: 1px;
  }
  
  .twp-country-flag.twp-current::after {
    width: 18px;
    height: 18px;
    font-size: 11px;
    top: 4px;
    right: 4px;
  }
}

@media (max-width: 380px) {
  .twp-card {
    padding: 12px 10px 10px;
    width: 96vw;
  }
  
  .twp-logo {
    margin: 0 0 8px 0;
  }
  
  .twp-logo img {
    max-width: 95px;
    max-height: 32px;
  }
  
  .twp-logo-text {
    font-size: 15px;
  }
  
  .twp-head h3 {
    font-size: 16px;
  }
  
  .twp-sub {
    font-size: 11px;
  }
  
  .twp-flag-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
  }
  
  .twp-country-flag {
    min-height: 62px;
    padding: 6px 4px;
    border-radius: 8px;
  }
  
  .twp-flag-icon {
    width: 28px;
    height: 21px;
  }
  
  .twp-flag-name {
    font-size: 9px;
  }
  
  .twp-flag-currency {
    font-size: 8px;
    padding: 1px 4px;
  }
  
  .twp-country-flag.twp-current::after {
    width: 16px;
    height: 16px;
    font-size: 10px;
    top: 3px;
    right: 3px;
  }
}

/* Locked shipping country field */
.twp-locked-field input[readonly],
.twp-locked-field select[disabled] {
  background-color: #f5f5f5 !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}
.twp-locked-field .description {
  font-size: 0.875em;
  color: #666;
  margin-top: 0.5em;
}
.twp-change-country {
  color: #2271b1;
  text-decoration: underline;
  font-weight: 500;
}
.twp-change-country:hover {
  color: #135e96;
}