/* ============================================================
   Supplier Directory — Main Stylesheet
   Direction: RTL (Arabic)
   ============================================================ */

:root {
  /* Deep charcoal + warm amber */
  --bg:           #0c0c0e;
  --bg-subtle:    #131316;
  --surface:      #1a1a1f;
  --surface-hover:#222228;
  --border:       #2a2a32;
  --accent:       #e8a825;
  --accent-soft:  rgba(232, 168, 37, 0.12);
  --accent-hover: #f0b840;
  --green:        #34d399;
  --green-soft:   rgba(52, 211, 153, 0.12);
  --red:          #f87171;
  --red-soft:     rgba(248, 113, 113, 0.1);
  --blue:         #60a5fa;
  --blue-soft:    rgba(96, 165, 250, 0.1);
  --text:         #f0ece4;
  --text-secondary:#a8a29e;
  --text-muted:   #6b6560;
  --font-display: 'Noto Kufi Arabic', serif;
  --font-body:    'IBM Plex Sans Arabic', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Grain overlay ──────────────────────────────────────── */

.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 12, 14, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

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

.logo-icon {
  color: var(--accent);
  font-size: 1.3rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; text-shadow: 0 0 12px var(--accent); }
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-btn.active {
  background: var(--surface);
  color: var(--accent);
}

.btn-scrape {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: var(--transition);
}

.btn-scrape:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-scrape.loading .btn-scrape-icon {
  animation: spin 0.8s linear infinite;
}

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

/* ── Main content ───────────────────────────────────────── */

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 64px - 60px);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Stats grid ─────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }
.stat-card:nth-child(4) { animation-delay: 0.24s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-primary::before  { background: var(--accent); }
.stat-accent::before   { background: var(--green); }
.stat-muted::before    { background: var(--red); }
.stat-info::before     { background: var(--blue); }

.stat-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.stat-number {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  margin-bottom: 0.3rem;
}

.stat-primary .stat-number  { color: var(--accent); }
.stat-accent .stat-number   { color: var(--green); }
.stat-muted .stat-number    { color: var(--red); }
.stat-info .stat-number     { color: var(--blue); }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Dashboard bottom ───────────────────────────────────── */

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}

.last-scraped-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.last-scraped-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.last-scraped-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
}

.recent-suppliers {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.recent-suppliers h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  transition: var(--transition);
}

.recent-item:hover {
  background: var(--surface-hover);
}

.recent-item-name {
  font-size: 0.88rem;
  font-weight: 500;
}

.recent-item-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.recent-item-link:hover { text-decoration: underline; }

/* ── Search bar ─────────────────────────────────────────── */

.search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  max-width: 480px;
  padding: 0.75rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Supplier cards grid ────────────────────────────────── */

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

.supplier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  opacity: 0;
  animation: fadeUp 0.4s ease forwards;
}

.supplier-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.supplier-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.supplier-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.supplier-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-active {
  background: var(--green-soft);
  color: var(--green);
}

.badge-pending {
  background: var(--red-soft);
  color: var(--red);
}

.supplier-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.supplier-meta-item {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.supplier-meta-item .icon {
  color: var(--text-muted);
  font-size: 0.7rem;
  width: 1rem;
  text-align: center;
}

.supplier-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-visit, .btn-profile {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-visit {
  background: var(--accent);
  color: var(--bg);
}

.btn-visit:hover {
  background: var(--accent-hover);
  letter-spacing: 0.02em;
}

.btn-profile {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-profile:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Pagination ─────────────────────────────────────────── */

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 2rem;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

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

/* ── Export view ────────────────────────────────────────── */

.export-panel {
  max-width: 560px;
  margin: 4rem auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
}

.export-panel h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.export-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.btn-export-csv {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 2rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  transition: var(--transition);
}

.btn-export-csv:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.export-icon { font-size: 1.2rem; }

.export-note {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Toast ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 1000;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ── Footer ─────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 2rem;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.footer-inner a:hover { text-decoration: underline; }
.footer-dot { opacity: 0.3; }

/* ── Empty state ────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .header-nav { display: none; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0 1rem; }
  .main-content { padding: 1rem; }
  .suppliers-grid { grid-template-columns: 1fr; }
  .stat-number { font-size: 1.8rem; }

  .header-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(12, 12, 14, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    justify-content: space-around;
    z-index: 100;
  }

  .nav-btn { font-size: 0.75rem; padding: 0.5rem 0.8rem; }
  .site-footer { padding-bottom: 4.5rem; }
}
