/* =====================================================================
 * Diesel internal tools — shared design system.
 *
 * Used by every page under stock.diesel.co.il. Loaded via absolute path
 * so it works the same whether the page is at /index.php, /stockupdate26/...
 * or /media/... — link with: <link rel="stylesheet" href="/css/diesel-system.css">
 *
 * Page-specific styles (forms, gallery grid, etc.) live inline on each
 * page; this file holds the SHARED primitives only: reset, body, nav,
 * card, sections, buttons, history table, streaming progress UI, diff.
 * ===================================================================== */

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- Base ---------- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
}

a { color: inherit; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------- Top navigation ---------- */
.top-nav {
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
}
.nav-logos { display: flex; align-items: center; gap: 20px; }
.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #e2e8f0;
  font-weight: 700;
  font-size: 18px;
  padding: 8px 15px;
  border-radius: 8px;
  transition: all 0.3s;
}
.logo-link img { height: 32px; width: auto; filter: brightness(1.1); }
.logo-link:hover { background: rgba(59, 130, 246, 0.2); }
.logo-link.activated { color: #60a5fa; }
.logo-link.diesel { color: #ffffff; }

.nav-menu { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nav-link {
  padding: 10px 20px;
  text-decoration: none;
  color: #e2e8f0;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s;
  font-size: 14px;
}
.nav-link:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}
.nav-link.active {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: white;
}

/* ---------- Page wrapper ---------- */
.page-wrapper {
  min-height: calc(100vh - 70px);
  padding: 40px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
}
.page-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

/* ---------- Card (glass-morphism) ---------- */
.card {
  width: 100%;
  max-width: 820px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.4s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.card-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.card-header .meta {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 13px;
}
.card-header .meta span,
.card-header .meta time { font-variant-numeric: tabular-nums; }

.card-section {
  padding: 22px 28px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.card-section:last-child { border-bottom: 0; }
.card-section h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #60a5fa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-section .desc {
  margin: 0 0 14px;
  font-size: 14px;
  color: #e2e8f0;
  line-height: 1.55;
}
.card-section .status {
  font-size: 13px;
  color: #94a3b8;
}
.card-section .status strong {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.card-section .status .alert {
  color: #fbbf24;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  margin-left: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}
.btn:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}
.btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 8px 25px 0 rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}
.btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.3);
}
.btn.danger:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  box-shadow: 0 8px 25px 0 rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}
.btn.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
}
.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

/* ---------- Run history table ---------- */
.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}
.history th, .history td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  text-align: right;
  vertical-align: top;
  color: #e2e8f0;
}
.history th {
  color: #94a3b8;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(15, 23, 42, 0.4);
}
.history tr:last-child td { border-bottom: 0; }
.history .src {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
  font-weight: 600;
}
.history .src.cron {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.history .status-ok    { color: #22c55e; font-weight: 600; }
.history .status-warn  { color: #fbbf24; font-weight: 600; }
.history .status-error { color: #ef4444; font-weight: 600; }
.empty {
  color: #94a3b8;
  font-size: 13px;
  padding: 12px 0;
  font-style: italic;
}

/* ---------- Streaming progress steps ---------- */
.steps { list-style: none; margin: 0; padding: 18px 28px; }
.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  color: #94a3b8;
  font-size: 14px;
  transition: color 0.2s ease;
}
.steps li .icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  font-size: 11px; line-height: 1;
  flex-shrink: 0;
  color: #94a3b8;
  transition: all 0.2s ease;
  background: rgba(15, 23, 42, 0.4);
}
.steps li.running { color: #ffffff; }
.steps li.running .icon {
  border-color: #3b82f6;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
  animation: pulse 1.1s ease-in-out infinite;
}
.steps li.done { color: #e2e8f0; }
.steps li.done .icon {
  border-color: #10b981;
  background: #10b981;
  color: #ffffff;
}
.steps li.error .icon {
  border-color: #ef4444;
  background: #ef4444;
  color: #ffffff;
}
.steps li .label { flex: 0 0 auto; }
.steps li .extra {
  margin-right: auto;
  color: #94a3b8;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.65; }
}

/* ---------- Diff table (streaming page) ---------- */
.diff {
  margin: 0 28px 18px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.4);
  font-size: 13px;
}
.diff table { width: 100%; border-collapse: collapse; }
.diff th, .diff td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
}
.diff th {
  background: rgba(30, 41, 59, 0.8);
  color: #94a3b8;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.diff tr:last-child td { border-bottom: 0; }
.diff .sku { font-weight: 700; color: #ffffff; }
.diff .arrow { color: #94a3b8; padding: 0 6px; }
.diff .changed { background: rgba(251, 191, 36, 0.06); }
.diff .new-val { color: #60a5fa; font-weight: 700; }

/* ---------- Footer & CTAs (streaming page) ---------- */
.footer {
  padding: 16px 28px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  font-size: 13px;
}
.footer.done { color: #22c55e; }
.footer.error { color: #ef4444; }

.cta {
  padding: 20px 28px 24px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.cta a {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  transition: all 0.25s ease;
}
.cta a:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}
.cta a.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}
.cta a.primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 8px 25px 0 rgba(59, 130, 246, 0.4);
}
.cta a.danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.3);
}
.cta a.danger:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  box-shadow: 0 8px 25px 0 rgba(239, 68, 68, 0.4);
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .nav-container { padding: 12px 16px; flex-wrap: wrap; }
  .nav-menu { width: 100%; justify-content: flex-start; padding-top: 8px; }
  .nav-link { padding: 8px 12px; font-size: 13px; }
  .page-wrapper { padding: 24px 12px; }
  .card { border-radius: 16px; }
  .card-header, .card-section { padding-left: 18px; padding-right: 18px; }
  .history th, .history td { padding: 8px 4px; font-size: 12px; }
}
