/* Amazon Coupons Search - Page Styles */

:root {
  --bg-main: #f3f4f6;
  --bg-card: #ffffff;
  --border-card: rgba(0, 0, 0, 0.06);
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent-blue: #007aff;
  --accent-blue-dark: #0053c4;
  --accent-orange: #febd69;
  --accent-orange-dark: #f3a847;
  --accent-green: #16a34a;
  --badge-red: #ef4444;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

body {
  -webkit-font-smoothing: antialiased;
}

.search-app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */

.search-header {
  margin-bottom: 16px;
}

.search-header-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.search-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.header-separator {
  font-size: 16px;
  opacity: 0.8;
  margin: 0 2px;
}

.search-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* SEARCH BAR */

.search-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0 6px;
}

.search-input-container {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.5);
  overflow: hidden;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 14px 10px 16px;
  font-size: 14px;
  background: transparent;
  color: var(--text-main);
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-button {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  transition: background 0.15s ease, transform 0.15s ease;
}

.search-button:hover {
  background: rgba(59, 130, 246, 0.06);
  transform: translateY(-1px);
}

/* SEARCH ACTIONS (SORT & CHIPS) */

.search-actions-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.sort-and-brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.sort-buttons-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.keyword-chips-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Override existing Brand Toggle margin */
.brand-only-toggle {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  height: 32px;
}

.brand-only-toggle input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* Sort Buttons */
.sort-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: rgba(229, 231, 235, 0.5);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.sort-btn:hover {
  background: rgba(209, 213, 219, 0.7);
}

.sort-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* Keyword Chips */
.keyword-chip {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(156, 163, 175, 0.4);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.keyword-chip:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
}

/* MAIN */

.search-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* CARDS GRID */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

/* CARD */

.coupon-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-card);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  padding: 8px 10px 10px;
}

/* BODY */

.card-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 4px;
}

/* image + discount badge */

.card-image-frame {
  width: 100%;
  height: 150px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.badge-discount {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--badge-red);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

/* title */

.card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
  max-height: 4.05em;
  overflow: hidden;
}

/* FOOTER */

.card-footer {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  flex: 1 0 auto;
}

.card-expire {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.dot-active {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
}

.expire-label {
  font-weight: 500;
}

.expire-value {
  font-weight: 500;
  color: #374151;
}

/* PRICING */

.card-pricing {
  min-height: 22px;
  display: flex;
  align-items: center;
}

.card-pricing-row {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.price-old {
  font-size: 12px;
  color: #4b5563;
  text-decoration: line-through;
}

.price-final {
  display: inline-flex;
  align-items: flex-start;
  gap: 1px;
  color: #15803d;
  font-weight: 700;
}

.price-final-currency {
  font-size: 10px;
  line-height: 1;
  margin-top: 3px;
}

.price-final-dollars {
  font-size: 19px;
  line-height: 1;
}

.price-final-cents {
  font-size: 11px;
  line-height: 1;
  margin-top: 3px;
}

/* BUTTONS */

.card-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  justify-content: center;
}

.card-buttons.one-button {
  justify-content: center;
}

.btn-amazon {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Arial, sans-serif;
  text-decoration: none;
  min-width: 0;
}

.btn-amazon-wide {
  flex: 0 0 66%;
}

/* žёлтая (promo_link) */

.btn-amazon-primary {
  background: var(--accent-orange);
  border-color: var(--accent-orange-dark);
  color: #111827;
  box-shadow: 0 2px 6px rgba(253, 186, 116, 0.5);
}

.btn-amazon-primary:hover {
  background: var(--accent-orange-dark);
  transform: translateY(-1px);
}

.btn-amazon-primary:active {
  transform: translateY(0);
}

/* синяя (нет promo_link) */

.btn-amazon-secondary {
  background: #1d4ed8;
  border-color: #1e40af;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.btn-amazon-secondary:hover {
  background: #1e40af;
  transform: translateY(-1px);
}

.btn-amazon-secondary:active {
  transform: translateY(0);
}

/* EMPTY STATE */

.empty-state {
  grid-column: 1 / -1;
  padding: 40px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* PAGINATION */

.pagination {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.page-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #ffffff;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: #111827;
  min-width: 70px;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  background: #eef2ff;
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.5);
  transform: translateY(-1px);
}

.page-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.page-info {
  color: var(--text-muted);
}

/* FOOTER */

.search-footer {
  margin-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.search-footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

.search-footer a:hover {
  text-decoration: underline;
}

.footer-separator {
  opacity: 0.6;
}

/* LOADING PROGRESS */

.loading-progress-container {
  margin: 30px auto;
  max-width: 400px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.loading-progress-content {
  width: 100%;
  text-align: center;
}

.loading-progress-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.loading-progress-bar {
  width: 100%;
  height: 6px;
  background-color: rgba(229, 231, 235, 0.5);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent-blue);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.loading-progress-percent {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* RESPONSIVE */

@media (max-width: 768px) {
  .search-app {
    padding: 12px 10px 18px;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .search-header-top {
    align-items: flex-start;
  }

  .search-meta {
    flex-direction: column;
  }
}

/* DARK MODE */

@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #111827;
    --bg-card: #020617;
    --border-card: rgba(148, 163, 184, 0.4);
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.6);
  }

  body {
    background: radial-gradient(circle at top, #1f2937, #020617 55%);
  }

  .search-input-container {
    background: #020617;
    border-color: rgba(148, 163, 184, 0.5);
  }

  .search-input {
    color: #e5e7eb;
  }

  .search-input::placeholder {
    color: #6b7280;
  }

  .coupon-card {
    background: radial-gradient(circle at top left, #0b1120, #020617 60%);
    box-shadow: var(--shadow-soft);
  }

  .card-image-frame {
    background: #020617;
    border-color: rgba(148, 163, 184, 0.5);
  }

  .card-title {
    color: #e5e7eb;
  }

  .expire-value {
    color: #e5e7eb;
  }

  .price-old {
    color: #9ca3af;
  }

  .empty-state {
    color: #9ca3af;
  }

  .page-btn {
    background: #020617;
    color: #e5e7eb;
  }

  .page-btn:hover:not(:disabled) {
    background: #111827;
  }

  .search-footer {
    border-top-color: rgba(31, 41, 55, 0.9);
  }
}
