/* Base */
html { scroll-behavior: smooth; }

/* Visual refresh — smoother transitions + refined shadows everywhere */
button, a, input, select, textarea {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 180ms;
}

/* Refined card shadows — more subtle at rest, warmer on hover */
.surface {
  background: white;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.7);
}
.card-hover {
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
.card-hover:hover {
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.08), 0 10px 24px -8px rgba(30, 64, 175, 0.12);
  transform: translateY(-2px);
  border-color: rgba(191, 219, 254, 0.8);
}

/* Button refinements */
.btn-refined {
  position: relative;
  overflow: hidden;
}
.btn-refined::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.25), transparent 50%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.btn-refined:hover::after { opacity: 1; }

/* Security — disable text selection & dragging on protected content */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}
.no-select img, .secure-content img { pointer-events: none; }
/* Disable context menu visual hint */
body.secure-mode { -webkit-touch-callout: none; }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(1200px 600px at 0% 0%, rgba(59, 130, 246, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(245, 158, 11, 0.06), transparent 60%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  min-height: 100vh;
}

* { box-sizing: border-box; }

/* Hebrew numbers stay LTR inside RTL */
.ltr-num { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* Custom scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Utility animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-slide-up { animation: slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.animate-fade-in { animation: fadeIn 0.4s ease-out both; }
.animate-slide-in { animation: slideInRight 0.35s ease-out both; }
.animate-pulse-soft { animation: pulse-soft 2s ease-in-out infinite; }

/* Delays for staggered */
.delay-75 { animation-delay: 75ms; }
.delay-150 { animation-delay: 150ms; }
.delay-225 { animation-delay: 225ms; }
.delay-300 { animation-delay: 300ms; }
.delay-500 { animation-delay: 500ms; }

/* Gradient borders */
.gradient-border {
  position: relative;
  background: white;
  border-radius: 16px;
}
.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 1.5px;
  background: linear-gradient(135deg, #2563eb, #60a5fa 40%, #f59e0b);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Card hover */
.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px -12px rgba(30, 64, 175, 0.18);
}

/* Beautiful buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37, 99, 235, 0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: #1e40af;
}
.btn-ghost:hover { background: #eff6ff; }
.btn-outline {
  background: white;
  color: #1e40af;
  border: 1px solid #dbeafe;
}
.btn-outline:hover { background: #eff6ff; border-color: #bfdbfe; }
.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.btn-danger:hover { background: #fecaca; }
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.22);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(16, 185, 129, 0.32); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Inputs */
.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  color: #0f172a;
  transition: all 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.input::placeholder { color: #94a3b8; }
.textarea { min-height: 90px; resize: vertical; }

/* Fancy field group */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}
.field-label .required { color: #dc2626; margin-right: 0.2rem; }

/* Dashboard stat card */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.04);
  border: 1px solid rgba(30, 64, 175, 0.06);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent, #3b82f6), transparent);
}
.stat-card .stat-value {
  font-size: 1.5rem;       /* desktop: text-2xl */
  line-height: 2rem;
  white-space: nowrap;
  overflow: visible;       /* don't truncate — shrink font on mobile instead */
}

/* Sidebar nav link */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 500;
  color: #475569;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-link:hover { background: #f1f5f9; color: #1e40af; }
.nav-link.active {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

/* Timeline */
.timeline-step {
  position: relative;
  padding-right: 2rem;
}
.timeline-step::before {
  content: '';
  position: absolute;
  right: 0.55rem;
  top: 1.6rem;
  bottom: -0.5rem;
  width: 2px;
  background: #e2e8f0;
}
.timeline-step:last-child::before { display: none; }

/* Modal overlay — always viewport-centered, fixed to viewport */
.modal-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
  padding: 1rem;
  /* No overflow on overlay - content handles its own scroll */
}
.modal-content {
  background: white;
  border-radius: 18px;
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 25px 75px -10px rgba(15, 23, 42, 0.3);
  animation: fadeIn 0.25s ease-out;
  display: flex;
  flex-direction: column;
}
/* Prevent body scroll when modal open */
body.modal-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 2rem;
  text-align: center;
  transition: all 0.2s;
  background: #f8fafc;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.active {
  border-color: #3b82f6;
  background: #eff6ff;
}

/* Tooltip — smart positioning, shows below by default, wraps if long */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #0f172a;
  color: white;
  font-size: 0.72rem;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  word-break: break-word;
  max-width: 280px;
  min-width: 120px;
  text-align: right;
  pointer-events: none;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  line-height: 1.4;
}
/* Variant: position above when element is near bottom of page */
[data-tip-pos="top"]:hover::after {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Print layout for payment PDF */
@media print {
  body { background: white; }
  .no-print { display: none !important; }
}

/* Mobile responsive */
@media (max-width: 1023px) {
  aside.w-64 {
    position: fixed !important;
    inset: 0 0 0 auto !important;
    transform: translateX(100%);
    z-index: 50;
    transition: transform 0.25s ease-out;
    box-shadow: -8px 0 24px rgba(0,0,0,0.1);
  }
  aside.w-64.translate-x-0 {
    transform: translateX(0) !important;
  }
  /* Prevent any wide descendant (table, tab bar) from pushing the whole
     page horizontally. Fixed sidebar expects to sit at viewport edge —
     if main overflows, it detaches visually. Clip here, then let
     specific wide surfaces scroll internally below. */
  html, body { overflow-x: clip; }
  main { min-width: 0; max-width: 100%; overflow-x: clip; }
  main > div { min-width: 0; max-width: 100%; }
  /* Tables inside cards: scroll horizontally inside the card */
  .surface:has(> table.data-table),
  .surface:has(> div > table.data-table),
  .surface:has(> * > * > table.data-table) {
    overflow-x: auto;
  }
  /* Stat-card grids must not leak either */
  .grid { min-width: 0; }
  /* Make tables + dashboards usable on mobile */
  .data-table { font-size: 0.75rem; }
  .data-table th, .data-table td { padding: 0.5rem 0.4rem; }
  .surface { border-radius: 12px; }
  /* Smaller text blocks on mobile */
  h1.font-black { font-size: 1.5rem !important; line-height: 1.2 !important; }
  h2.font-black { font-size: 1.25rem !important; }
  /* KPI cards smaller */
  .stat-card { padding: 0.75rem 0.9rem; }
  .stat-card .stat-value {
    font-size: 1.05rem;    /* was 1.5rem — fit in narrow 2-col grid */
    line-height: 1.25;
    letter-spacing: -0.01em;
  }
  .stat-card .stat-icon { padding: 0.4rem !important; }
  .stat-card .stat-icon svg { width: 18px; height: 18px; }
}
@media (max-width: 640px) {
  /* Hide less-critical header items on small screens */
  .text-xs.hidden.md\:flex { display: none !important; }
}

/* Logo wheat decoration */
.wheat-accent {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -40px;
  width: 40px;
  opacity: 0.35;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #1e40af, #3b82f6, #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Soft surface */
.surface {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(30, 64, 175, 0.05);
  border: 1px solid rgba(30, 64, 175, 0.05);
}

/* Table-like rows */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table thead th {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-align: right;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }

/* Progress bar */
.progress {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width 0.6s ease-out;
}
.progress-fill.warning { background: linear-gradient(90deg, #f59e0b, #dc2626); }
.progress-fill.full { background: linear-gradient(90deg, #10b981, #059669); }

/* Checkbox custom */
.custom-check {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  cursor: pointer;
  background: white;
}
.custom-check.checked {
  background: #2563eb;
  border-color: #2563eb;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.stepper-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}
.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid #e2e8f0;
  font-weight: 700;
  font-size: 0.85rem;
  color: #64748b;
  flex-shrink: 0;
}
.stepper-circle.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.stepper-circle.done {
  background: #10b981;
  color: white;
  border-color: #10b981;
}
.stepper-label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}
.stepper-label.active { color: #1e40af; font-weight: 600; }
.stepper-line {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  border-radius: 2px;
}
.stepper-line.done { background: #10b981; }

/* Logo haredi authority (inline styling) */
.authority-logo-text {
  font-family: 'Heebo', 'Assistant', sans-serif;
  font-weight: 900;
  color: #1e40af;
  line-height: 0.92;
  letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════════
   Accessibility (נגישות) — WCAG 2.1 AA / IS 5568
   ═══════════════════════════════════════════════════════════════ */

/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link — visible when focused */
.a11y-skip-link {
  position: fixed;
  top: -50px;
  right: 16px;
  z-index: 9999;
  padding: 10px 18px;
  background: #1d4ed8;
  color: white;
  font-weight: 700;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.15s;
}
.a11y-skip-link:focus {
  top: 0;
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

/* Accessibility menu trigger */
.a11y-trigger {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9998;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1d4ed8;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30, 64, 175, 0.35);
  cursor: pointer;
  border: 3px solid white;
  transition: transform 0.15s, box-shadow 0.15s;
}
.a11y-trigger:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(30, 64, 175, 0.5); }
.a11y-trigger:focus-visible { outline: 3px solid #fbbf24; outline-offset: 3px; }

/* Accessibility panel */
.a11y-panel {
  position: fixed;
  bottom: 88px;
  left: 20px;
  z-index: 9998;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
  animation: a11y-slide-in 0.2s ease-out;
}
@keyframes a11y-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Font-size scaling — set on <html> data-a11y-size */
html[data-a11y-size="large"]   { font-size: 18px; }
html[data-a11y-size="xlarge"]  { font-size: 20px; }
/* default: 16px */

/* High-contrast mode — enhance text/background contrast */
html[data-a11y-contrast="high"] body {
  background: #fff !important;
}
html[data-a11y-contrast="high"] .surface {
  border: 2px solid #000 !important;
  box-shadow: none !important;
  background: #fff !important;
}
html[data-a11y-contrast="high"] .text-slate-500,
html[data-a11y-contrast="high"] .text-slate-400 { color: #1e293b !important; }
html[data-a11y-contrast="high"] .text-slate-600 { color: #0f172a !important; }
html[data-a11y-contrast="high"] .text-slate-700 { color: #000 !important; }
html[data-a11y-contrast="high"] a,
html[data-a11y-contrast="high"] button {
  outline-offset: 2px;
}
html[data-a11y-contrast="high"] .text-xs,
html[data-a11y-contrast="high"] .text-\[10px\],
html[data-a11y-contrast="high"] .text-\[11px\] { font-size: 13px !important; }

/* Highlight links */
html[data-a11y-highlight-links] a {
  text-decoration: underline !important;
  font-weight: 700 !important;
}
html[data-a11y-highlight-links] button:not([class*="bg-"]):not([class*="rounded-full"]) {
  text-decoration: underline;
}

/* Reduced motion */
html[data-a11y-reduced-motion] *,
html[data-a11y-reduced-motion] *::before,
html[data-a11y-reduced-motion] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Keyboard focus rings — visible and accessible */
*:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Honor OS-level reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
