/* ============================================================
   BASE — Reset, Typography, Utility Classes
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-en);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background-color: var(--color-page-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body,
html[dir="rtl"] body {
  font-family: var(--font-ar);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* Skip-to-content link (accessibility) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 9999;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: 0; }

/* Headings */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: .5rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-base); }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── Utility classes ─────────────────────────── */

/* Text */
.text-primary    { color: var(--color-primary) !important; }
.text-success    { color: var(--color-success) !important; }
.text-warning    { color: var(--color-warning) !important; }
.text-danger     { color: var(--color-danger)  !important; }
.text-info       { color: var(--color-info)    !important; }
.text-muted      { color: var(--color-text-muted) !important; }

/* Background */
.bg-primary-light  { background-color: var(--color-primary-light) !important; }
.bg-success-light  { background-color: var(--color-success-light)  !important; }
.bg-warning-light  { background-color: var(--color-warning-light)  !important; }
.bg-danger-light   { background-color: var(--color-danger-light)   !important; }
.bg-info-light     { background-color: var(--color-info-light)     !important; }
.bg-surface        { background-color: var(--color-surface)        !important; }
.bg-page           { background-color: var(--color-page-bg)        !important; }

/* Border radius */
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-md { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }

/* Font size */
.fs-xs   { font-size: var(--font-size-xs)   !important; }
.fs-sm   { font-size: var(--font-size-sm)   !important; }
.fs-base { font-size: var(--font-size-base) !important; }
.fs-lg   { font-size: var(--font-size-lg)   !important; }

/* Font weight */
.fw-medium   { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold     { font-weight: 700 !important; }

/* Display */
.d-grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4); }

/* Truncate */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Required asterisk */
.required::after { content: " *"; color: var(--color-danger); }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--sp-4) 0;
}

/* Section heading inside a card */
.section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--color-border);
}
