/* ==========================================================================
   Coupons World - Clean, Modern & Mobile-First Design System
   Vanilla CSS | High Performance | Fully Responsive
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* --- CSS Variables & Theme Tokens --- */
:root {
  --font-arabic: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-english: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Brand Accents */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-glow: rgba(79, 70, 229, 0.18);
  --success: #10B981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger: #EF4444;
  
  /* Light Theme */
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-ticket: #F8FAFC;
  --border: #E2E8F0;
  --border-dashed: #CBD5E1;
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.09);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-page: #0B0F19;
  --bg-card: #151D2F;
  --bg-subtle: #1E293B;
  --bg-ticket: #0F1626;
  --border: #243048;
  --border-dashed: #334466;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.6);
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-arabic);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

html[lang="en"] body {
  font-family: var(--font-english);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, select {
  font-family: inherit;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Gradient Text */
.text-gradient {
  background: linear-gradient(135deg, #4F46E5 0%, #06B6D4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Clean Modern Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: all 0.25s ease;
}

[data-theme="dark"] .site-header {
  background: rgba(11, 15, 25, 0.9);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4F46E5, #06B6D4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  display: block;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tool-btn {
  height: 38px;
  padding: 0 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tool-btn-icon {
  width: 38px;
  padding: 0;
  justify-content: center;
  font-size: 1rem;
}

/* --- Hero Section --- */
.hero-compact {
  padding: 2.75rem 0 1.75rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--primary);
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero-heading {
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 0.65rem;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 1.75rem;
  line-height: 1.6;
}

/* Search Bar */
.search-wrapper {
  max-width: 620px;
  margin: 0 auto 1.5rem;
}

.search-box-unified {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.5rem 0.35rem 1.25rem;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

html[dir="rtl"] .search-box-unified {
  padding: 0.35rem 1.25rem 0.35rem 0.5rem;
}

.search-box-unified:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
}

.search-icon-svg {
  color: var(--text-light);
  font-size: 1.15rem;
  margin-right: 0.65rem;
}

html[dir="rtl"] .search-icon-svg {
  margin-right: 0;
  margin-left: 0.65rem;
}

.search-input-field {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  min-width: 0;
}

.search-clear {
  color: var(--text-light);
  padding: 0.4rem;
  display: none;
  font-size: 0.95rem;
}

.search-clear:hover {
  color: var(--danger);
}

.search-submit-btn {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Country Selector Bar --- */
.country-filter-section {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.country-pill {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  user-select: none;
}

.country-pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.country-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* --- Category Pills --- */
.category-filter-wrap {
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.category-filter-wrap::-webkit-scrollbar {
  display: none;
}

.category-pills-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .category-pills-row {
    justify-content: flex-start;
    flex-wrap: nowrap;
    padding: 0 0.25rem;
  }
}

.cat-btn {
  white-space: nowrap;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.cat-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.cat-btn.active {
  background: var(--text-main);
  color: var(--bg-page);
  border-color: var(--text-main);
}

[data-theme="dark"] .cat-btn.active {
  background: #FFFFFF;
  color: #0B0F19;
  border-color: #FFFFFF;
}

/* --- Brands Directory Grid --- */
.brands-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
  gap: 1.5rem;
  margin-bottom: 4rem;
}

/* --- BRAND CARD --- */
.brand-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.brand-card:hover {
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: var(--shadow-md);
}

/* Brand Card Top Row: Logo, Name, Badge, Store Link */
.brand-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.brand-logo-container {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 1px solid var(--border);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-logo-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-initial-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  font-weight: 800;
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  user-select: none;
}

.brand-meta {
  flex: 1;
  min-width: 0;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.store-link-btn {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  transition: all 0.2s ease;
}

.store-link-btn:hover {
  background: rgba(79, 70, 229, 0.1);
}

.brand-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- COUPONS BOX INSIDE BRAND CARD --- */
.brand-coupons-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.coupon-ticket-row {
  background: var(--bg-ticket);
  border: 1.5px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color 0.2s ease;
}

.coupon-ticket-row:hover {
  border-color: var(--primary);
}

.coupon-info-side {
  flex: 1;
  min-width: 0;
}

.coupon-discount-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.coupon-code-badge {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: 0.05em;
  display: inline-block;
  margin-bottom: 0.25rem;
}

/* Country Flags inside coupon */
.coupon-countries-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.country-flag-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Copy Code Action Button */
.btn-copy-code {
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: 0 2px 8px var(--primary-glow);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-copy-code:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-copy-code.copied {
  background: var(--success);
  box-shadow: 0 2px 8px var(--success-glow);
}

/* --- Empty Results State --- */
.empty-brands-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

/* --- Clean Footer --- */
.site-footer-clean {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 2rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-inner-clean {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
  .hero-heading {
    font-size: 1.75rem;
  }
  .hero-desc {
    font-size: 0.92rem;
  }
  .brands-feed {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .brand-card {
    padding: 1.1rem;
  }
  .coupon-ticket-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem;
  }
  .btn-copy-code {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.92rem;
  }
  .country-filter-section {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.4rem;
  }
  .country-pill {
    flex-shrink: 0;
  }
}
