/* ============================================================
   shared.css — Styles shared across all templates
   Supports LTR (en) and RTL (ar) via [dir] attribute
   ============================================================ */

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

/* ── CSS Variables ── */
:root {
  --primary:    #1a3a5c;
  --primary-lt: #2563a8;
  --accent:     #c8933a;
  --accent-lt:  #f0c060;
  --success:    #16a34a;
  --danger:     #dc2626;
  --warning:    #d97706;
  --bg:         #f4f6fb;
  --white:      #ffffff;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.16);
  --radius:     10px;
  --radius-lg:  18px;
}

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

body {
  background: var(--bg);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.7;
}

[dir="rtl"] body, body[dir="rtl"] {
  font-family: 'Tajawal', 'Cairo', Arial, sans-serif;
}
[dir="ltr"] body, body[dir="ltr"] {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
}

/* ── Typography ── */
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.3; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

/* ── Score Badges ── */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 36px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1rem;
  padding: 0 10px;
}
.score-excellent { background: #dcfce7; color: #15803d; border: 2px solid #86efac; }
.score-good      { background: #dbeafe; color: #1d4ed8; border: 2px solid #93c5fd; }
.score-average   { background: #fef9c3; color: #854d0e; border: 2px solid #fde047; }
.score-low       { background: #fee2e2; color: #b91c1c; border: 2px solid #fca5a5; }

/* ── Score Circle ── */
.score-circle {
  width: 90px; height: 90px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-weight: 800;
  background: conic-gradient(var(--primary-lt) 0% var(--pct, 99%), var(--gray-200) var(--pct, 99%) 100%);
  box-shadow: 0 0 0 6px white, 0 0 0 8px var(--primary-lt);
}
.score-circle .val { font-size: 1.6rem; color: var(--primary); line-height: 1; }
.score-circle .lbl { font-size: 0.65rem; color: var(--gray-600); }

/* ── Progress Bar ── */
.progress-wrap { background: var(--gray-200); border-radius: 99px; overflow: hidden; height: 10px; }
.progress-bar  { height: 100%; border-radius: 99px; transition: width .6s ease; }
.progress-bar.excellent { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress-bar.good      { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.progress-bar.average   { background: linear-gradient(90deg, #d97706, #fbbf24); }
.progress-bar.low       { background: linear-gradient(90deg, #dc2626, #f87171); }

/* ── Cards & Sections ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.section-header {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: .75rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
}
.section-header .icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.section-header h2 { color: var(--primary); font-size: 1.15rem; }

/* ── Table ── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.data-table th {
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  text-align: start;
  font-weight: 600;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
}
.data-table tr:nth-child(even) td { background: var(--gray-100); }
.data-table tr:hover td { background: #e8f0fe; }

/* ── Toolbar (print/back) ── */
.toolbar {
  position: fixed; top: 0; inset-inline-start: 0; width: 100%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1.5rem;
  z-index: 999;
  box-shadow: var(--shadow-md);
  gap: 1rem;
}
.toolbar .toolbar-title { font-weight: 700; font-size: .95rem; }
.toolbar .toolbar-btns { display: flex; gap: .5rem; align-items: center; }
.btn {
  padding: .45rem 1rem;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
  display: inline-flex; align-items: center; gap: .4rem;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-lt); color: var(--primary); }
.btn-ghost { background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.3); }
.btn-ghost:hover { background: rgba(255,255,255,.25); }

/* ── Page Wrapper ── */
.page-wrap { max-width: 1100px; margin: 0 auto; padding: 90px 1.5rem 2rem; }

/* ── Doc Header ── */
.doc-header {
  background: linear-gradient(135deg, var(--primary) 0%, #0f2847 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.doc-header::after {
  content: '';
  position: absolute; inset-inline-end: -40px; top: -40px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(200,147,58,.15);
}
.doc-header .logo-line {
  font-size: .8rem; opacity: .7; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: .5rem;
}
.doc-header h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: .3rem; }
.doc-header .subtitle { opacity: .8; font-size: .95rem; }
.doc-header .meta-row {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.2);
  font-size: .8rem; opacity: .85;
}
.doc-header .meta-item strong { display: block; opacity: .65; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── KPI / Axis Card ── */
.axis-card {
  border-radius: var(--radius);
  padding: 1.1rem;
  border: 2px solid var(--gray-200);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
}
.axis-card:hover { border-color: var(--primary-lt); box-shadow: var(--shadow-md); }
.axis-card .axis-name { font-weight: 700; color: var(--primary); font-size: .95rem; margin-bottom: .6rem; }
.axis-card .axis-score-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.axis-card .axis-description { font-size: .78rem; color: var(--gray-600); margin-top: .5rem; border-top: 1px solid var(--gray-200); padding-top: .5rem; }
.axis-card .benchmark-row { display: flex; justify-content: space-between; font-size: .75rem; color: var(--gray-400); margin-bottom: .25rem; }

/* ── Summary stats ── */
.stat-box {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
  background: var(--white);
  border: 2px solid var(--gray-200);
}
.stat-box .stat-val { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-box .stat-lbl { font-size: .75rem; color: var(--gray-600); margin-top: .25rem; }

/* ── Tag / Badge ── */
.tag {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.tag-green  { background: #dcfce7; color: #166534; }
.tag-blue   { background: #dbeafe; color: #1e40af; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.tag-red    { background: #fee2e2; color: #991b1b; }
.tag-gold   { background: #fef9c3; color: #713f12; }

/* ── Note card ── */
.note-card {
  border-inline-start: 4px solid var(--primary-lt);
  background: #eff6ff;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1rem;
  margin-bottom: .75rem;
  font-size: .9rem;
  color: var(--gray-800);
}
[dir="rtl"] .note-card { border-inline-start: none; border-inline-end: 4px solid var(--primary-lt); border-radius: var(--radius) 0 0 var(--radius); }

/* ── Chart containers ── */
.chart-container { position: relative; width: 100%; }

/* ── Print styles ── */
@media print {
  .toolbar { display: none !important; }
  .page-wrap { padding: 0 !important; max-width: 100% !important; }
  body { background: white !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .doc-header { border-radius: 0 !important; }
  a { text-decoration: none !important; }
  .no-print { display: none !important; }
  .page-break { page-break-before: always; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .doc-header { padding: 1.25rem; }
  .doc-header h1 { font-size: 1.3rem; }
  .page-wrap { padding-top: 75px; padding-inline: 1rem; }
}
