/* WPOptic Plugin Styles */

/* ── Variables ───────────────────────────────────────────────────────── */
:root {
  --wpoptic-primary: #2563eb;
  --wpoptic-primary-hover: #1d4ed8;
  --wpoptic-success: #16a34a;
  --wpoptic-warning: #d97706;
  --wpoptic-error: #dc2626;
  --wpoptic-gray-50: #f9fafb;
  --wpoptic-gray-100: #f3f4f6;
  --wpoptic-gray-200: #e5e7eb;
  --wpoptic-gray-300: #d1d5db;
  --wpoptic-gray-500: #6b7280;
  --wpoptic-gray-700: #374151;
  --wpoptic-gray-900: #111827;
  --wpoptic-radius: 8px;
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.wpoptic-form-container {
  max-width: 900px;
  margin: 0 auto;
}

.wpoptic-form-group {
  margin-bottom: 1.5rem;
}

.wpoptic-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--wpoptic-gray-700);
}

.wpoptic-form-group input[type="text"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--wpoptic-gray-300);
  border-radius: var(--wpoptic-radius);
  font-size: 0.938rem;
  transition: border-color 0.2s;
}

.wpoptic-form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--wpoptic-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Tags ────────────────────────────────────────────────────────────── */
.wpoptic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
  min-height: 1.5rem;
}

.wpoptic-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--wpoptic-gray-100);
  border: 1px solid var(--wpoptic-gray-200);
  border-radius: 999px;
  font-size: 0.813rem;
  color: var(--wpoptic-gray-700);
}

.wpoptic-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--wpoptic-gray-500);
  padding: 0 0.125rem;
}

.wpoptic-tag-remove:hover {
  color: var(--wpoptic-error);
}

/* ── Autocomplete dropdown ───────────────────────────────────────────── */
.wpoptic-ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--wpoptic-gray-200);
  border-radius: var(--wpoptic-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 2px;
}

.wpoptic-ac-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s;
}

.wpoptic-ac-item:hover,
.wpoptic-ac-item.highlighted {
  background: var(--wpoptic-gray-50);
}

.wpoptic-ac-icon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.wpoptic-ac-label {
  flex: 1;
  font-size: 0.875rem;
  color: var(--wpoptic-gray-900);
}

.wpoptic-ac-count {
  font-size: 0.75rem;
  color: var(--wpoptic-gray-500);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.wpoptic-btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  background: var(--wpoptic-primary);
  color: #fff;
  border: none;
  border-radius: var(--wpoptic-radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.wpoptic-btn:hover {
  background: var(--wpoptic-primary-hover);
  color: #fff;
}

.wpoptic-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.wpoptic-btn-secondary {
  background: var(--wpoptic-gray-100);
  color: var(--wpoptic-gray-700);
  border: 1px solid var(--wpoptic-gray-300);
}

.wpoptic-btn-secondary:hover {
  background: var(--wpoptic-gray-200);
  color: var(--wpoptic-gray-700);
}

.wpoptic-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Result states ───────────────────────────────────────────────────── */
.wpoptic-count-result,
.wpoptic-export-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--wpoptic-radius);
  font-size: 0.875rem;
}

.wpoptic-loading {
  color: var(--wpoptic-primary);
}

.wpoptic-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--wpoptic-gray-200);
  border-top-color: var(--wpoptic-primary);
  border-radius: 50%;
  animation: wpoptic-spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.wpoptic-success {
  color: var(--wpoptic-success);
}

.wpoptic-warning {
  color: var(--wpoptic-warning);
}

.wpoptic-error {
  color: var(--wpoptic-error);
}

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

/* ── Checkbox row ────────────────────────────────────────────────────── */
.wpoptic-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.wpoptic-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: normal;
  cursor: pointer;
}

/* ── Domain page ─────────────────────────────────────────────────────── */
.wpoptic-domain-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.wpoptic-domain-header {
  margin-bottom: 2rem;
}

.wpoptic-domain-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.wpoptic-meta {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: var(--wpoptic-gray-100);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--wpoptic-gray-500);
  margin-right: 0.5rem;
}

.wpoptic-status-reachable { background: #dcfce7; color: var(--wpoptic-success); }
.wpoptic-status-unreachable { background: #fef2f2; color: var(--wpoptic-error); }

.wpoptic-section {
  margin-bottom: 2rem;
}

.wpoptic-section h3 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: var(--wpoptic-gray-700);
}

.wpoptic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.wpoptic-contact-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  background: var(--wpoptic-gray-50);
  border-radius: var(--wpoptic-radius);
}

.wpoptic-contact-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.wpoptic-social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wpoptic-social-link {
  padding: 0.375rem 0.75rem;
  background: var(--wpoptic-gray-100);
  border-radius: var(--wpoptic-radius);
  text-decoration: none;
  color: var(--wpoptic-gray-700);
  font-size: 0.813rem;
  transition: background 0.2s;
}

.wpoptic-social-link:hover {
  background: var(--wpoptic-gray-200);
}

/* ── Tech cards ──────────────────────────────────────────────────────── */
.wpoptic-tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.wpoptic-tech-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem;
  background: var(--wpoptic-gray-50);
  border: 1px solid var(--wpoptic-gray-200);
  border-radius: var(--wpoptic-radius);
}

.wpoptic-tech-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}

.wpoptic-tech-placeholder {
  background: var(--wpoptic-gray-200);
}

.wpoptic-tech-info strong {
  display: block;
  font-size: 0.813rem;
}

.wpoptic-tech-category {
  font-size: 0.688rem;
  color: var(--wpoptic-gray-500);
}

/* ── Empty / error states ────────────────────────────────────────────── */
.wpoptic-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  max-width: 480px;
  margin: 2rem auto;
}

.wpoptic-empty-icon {
  color: var(--wpoptic-gray-300);
  margin-bottom: 1rem;
}

.wpoptic-empty-state h3 {
  font-size: 1.25rem;
  color: var(--wpoptic-gray-700);
  margin-bottom: 0.5rem;
}

.wpoptic-empty-state p {
  color: var(--wpoptic-gray-500);
  font-size: 0.938rem;
  line-height: 1.6;
}

.wpoptic-error-detail {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--wpoptic-gray-300);
  font-family: monospace;
  word-break: break-all;
}

.wpoptic-error-box {
  padding: 1.5rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--wpoptic-radius);
  text-align: center;
}

/* ── Domain page: contact grid ──────────────────────────────────────── */
.wpoptic-contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.wpoptic-contact-label {
  font-size: 0.688rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wpoptic-gray-500);
  margin-bottom: 0.125rem;
}

.wpoptic-contact-value {
  font-size: 0.938rem;
  color: var(--wpoptic-gray-900);
  word-break: break-all;
}

.wpoptic-domain-info-header {
  margin-bottom: 2rem;
}

.wpoptic-domain-info-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.wpoptic-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ── Spinner loading ─────────────────────────────────────────────────── */
.wpoptic-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--wpoptic-gray-500);
}

.wpoptic-loading-state p {
  margin-top: 1rem;
  font-size: 0.938rem;
}

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

/* ── Skeleton loading ────────────────────────────────────────────────── */
.wpoptic-skeleton {
  background: linear-gradient(90deg, var(--wpoptic-gray-100) 25%, var(--wpoptic-gray-50) 50%, var(--wpoptic-gray-100) 75%);
  background-size: 200% 100%;
  animation: wpoptic-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--wpoptic-radius);
}

.wpoptic-skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.wpoptic-skeleton-title { height: 2rem; width: 60%; margin-bottom: 1rem; }
.wpoptic-skeleton-card { height: 60px; margin-bottom: 0.75rem; }

@keyframes wpoptic-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Exports table ───────────────────────────────────────────────────── */
.wpoptic-exports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.wpoptic-exports-table th,
.wpoptic-exports-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--wpoptic-gray-200);
}

.wpoptic-exports-table th {
  font-weight: 600;
  color: var(--wpoptic-gray-500);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wpoptic-status-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.wpoptic-status-completed { background: #dcfce7; color: var(--wpoptic-success); }
.wpoptic-status-processing { background: #dbeafe; color: var(--wpoptic-primary); }
.wpoptic-status-pending { background: #fef3c7; color: var(--wpoptic-warning); }
.wpoptic-status-failed { background: #fef2f2; color: var(--wpoptic-error); }

/* ── Credits ─────────────────────────────────────────────────────────── */
.wpoptic-credits-card {
  padding: 1.5rem;
  background: var(--wpoptic-gray-50);
  border: 1px solid var(--wpoptic-gray-200);
  border-radius: var(--wpoptic-radius);
  text-align: center;
}

.wpoptic-credits-amount {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--wpoptic-primary);
  margin: 0.5rem 0;
}

.wpoptic-credits-label {
  color: var(--wpoptic-gray-500);
  font-size: 0.875rem;
}

/* ── Homepage Search ─────────────────────────────────────────────────── */
.wpoptic-search-wrapper {
  max-width: 600px;
  margin: 0 auto;
}

.wpoptic-search-form {
  position: relative;
}

.wpoptic-search-container {
  display: flex;
  gap: 0;
}

.wpoptic-search-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 2px solid var(--wpoptic-gray-200);
  border-right: none;
  border-radius: var(--wpoptic-radius) 0 0 var(--wpoptic-radius);
  font-size: 1rem;
  color: var(--wpoptic-gray-900);
  transition: border-color 0.2s;
}

.wpoptic-search-input:focus {
  outline: none;
  border-color: var(--wpoptic-primary);
}

.wpoptic-search-input::placeholder {
  color: var(--wpoptic-gray-500);
}

.wpoptic-search-btn {
  padding: 0.875rem 1.5rem;
  background: var(--wpoptic-primary);
  color: #fff;
  border: 2px solid var(--wpoptic-primary);
  border-radius: 0 var(--wpoptic-radius) var(--wpoptic-radius) 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.wpoptic-search-btn:hover {
  background: var(--wpoptic-primary-hover);
  border-color: var(--wpoptic-primary-hover);
}

.wpoptic-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--wpoptic-gray-200);
  border-radius: var(--wpoptic-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  margin-top: 4px;
  max-height: 400px;
  overflow-y: auto;
}

.wpoptic-search-group-label {
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.688rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wpoptic-gray-500);
  background: var(--wpoptic-gray-50);
  border-top: 1px solid var(--wpoptic-gray-200);
}

.wpoptic-search-group-label:first-child {
  border-top: none;
  border-radius: var(--wpoptic-radius) var(--wpoptic-radius) 0 0;
}

.wpoptic-search-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  text-decoration: none;
  color: var(--wpoptic-gray-900);
  cursor: pointer;
  transition: background 0.1s;
}

.wpoptic-search-item:hover,
.wpoptic-search-item.highlighted {
  background: var(--wpoptic-gray-50);
}

.wpoptic-search-item-icon {
  flex-shrink: 0;
  font-size: 1.125rem;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
}

.wpoptic-search-item-icon--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wpoptic-gray-100);
  font-size: 0.75rem;
}

img.wpoptic-search-item-icon {
  background: var(--wpoptic-gray-50);
}

.wpoptic-search-item-name {
  flex: 1;
  font-size: 0.875rem;
}

.wpoptic-search-item-name strong {
  color: var(--wpoptic-primary);
}

.wpoptic-search-item-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--wpoptic-gray-500);
}

.wpoptic-search-domain {
  background: #eff6ff;
  border-bottom: 1px solid var(--wpoptic-gray-200);
}

.wpoptic-search-domain:hover {
  background: #dbeafe;
}

.wpoptic-search-loading {
  padding: 0.75rem;
  text-align: center;
  color: var(--wpoptic-gray-500);
  font-size: 0.813rem;
}

/* ── Lead Gen: Pricing section ──────────────────────────────────────── */
.wpoptic-lead-gen-wrapper .pricing-section {
  transition: all 0.3s ease-in-out;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}

.wpoptic-lead-gen-wrapper .pricing-section.show {
  opacity: 1;
  max-height: 2000px;
}

/* ── Lead Gen: Volume discount table ────────────────────────────────── */
.wpoptic-lead-gen-wrapper .volume-discount-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.875rem;
}

.wpoptic-lead-gen-wrapper .volume-discount-table thead tr {
  background: #e9ecef;
}

.wpoptic-lead-gen-wrapper .volume-discount-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: #323639;
  border: 1px solid #dee2e6;
}

.wpoptic-lead-gen-wrapper .volume-discount-table th:nth-child(2),
.wpoptic-lead-gen-wrapper .volume-discount-table th:nth-child(3) {
  text-align: right;
}

.wpoptic-lead-gen-wrapper .volume-discount-table td {
  padding: 8px 12px;
  border: 1px solid #dee2e6;
}

.wpoptic-lead-gen-wrapper .volume-discount-table td:nth-child(3) {
  text-align: right;
}

.wpoptic-lead-gen-wrapper .volume-discount-table tbody tr {
  transition: background 0.2s;
}

.wpoptic-lead-gen-wrapper .volume-discount-table tbody tr:hover {
  background: #f8f9fa;
}

.wpoptic-lead-gen-wrapper .volume-discount-table .discount-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.wpoptic-lead-gen-wrapper .discount-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 0.25rem 0.625rem 0.125rem;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  color: rgb(34, 197, 94);
  background-color: rgba(39, 39, 42, 0.8);
  text-transform: uppercase;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .wpoptic-grid {
    grid-template-columns: 1fr;
  }
  .wpoptic-tech-grid {
    grid-template-columns: 1fr 1fr;
  }
  .wpoptic-actions {
    flex-direction: column;
  }
}

/* ── Legacy homepage search dropdown ────────────────────────────────── */
/* Prevent Elementor sections from clipping the search results dropdown */
#popup-search-results {
  z-index: 99999 !important;
}

/* Elementor containers wrapping the search need overflow visible */
.elementor-element:has(#popup-search-input),
.elementor-element:has(#popup-search-results) {
  overflow: visible !important;
}
.elementor-element:has(#popup-search-input) > .elementor-widget-wrap,
.elementor-element:has(#popup-search-input) > .elementor-container,
.elementor-element:has(#popup-search-results) > .elementor-widget-wrap,
.elementor-element:has(#popup-search-results) > .elementor-container {
  overflow: visible !important;
}
/* Walk up to the section level */
.elementor-section:has(#popup-search-input),
.elementor-section:has(#popup-search-results),
.e-con:has(#popup-search-input),
.e-con:has(#popup-search-results) {
  overflow: visible !important;
}
