/* القيم الأساسية */
:root {
  --bg1:#f6fbff; --bg2:#e9f2ff; --card:#ffffff;
  --primary:#0b5ed7; --accent:#06a66b; --muted:#5b6a75;
  --text:#102028; --border:#e6eef9; --grid:#e6eaf1;
}

* { box-sizing: border-box; font-family: "Tajawal", sans-serif; }
html, body { height: 100%; margin: 0; padding: 0; color: var(--text); }

body {
  background:
    radial-gradient(1000px 600px at 10% 10%, #eaf6ff 0%, transparent 25%),
    radial-gradient(900px 500px at 90% 90%, #f0fff4 0%, transparent 20%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}

.container { max-width: 1200px; margin: 28px auto; padding: 24px; }

header {
  display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  margin-bottom: 18px; align-items: center;
}

.hero { max-width: 740px; }
h1 { margin: 0 0 6px; font-size: 2rem; color: var(--primary); }
.tagline { color: var(--muted); margin-top: 6px; font-size: 1rem; }
.copyright { color: #778894; font-size: .9rem; }

/* زر تبديل مودرن */
.theme-toggle {
  --toggle-bg:#eff3f7; --toggle-ring:#cfd6e3; --thumb:#ffffff;
  --sun:#f59e0b; --moon:#64748b;
  display: inline-flex; align-items: center; gap: 10px;
  background: transparent; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: 12px;
}
.toggle-text { font-weight: 700; color: #334155; }
.toggle-track {
  position: relative; width: 78px; height: 36px; border-radius: 999px;
  background: var(--toggle-bg); box-shadow: inset 0 0 0 1px var(--toggle-ring);
  display: inline-flex; align-items: center; justify-content: space-between; padding: 0 10px;
}
.toggle-icon { font-size: 16px; line-height: 1; opacity: .9; }
.toggle-thumb {
  position: absolute; top: 3px; right: 3px; width: 30px; height: 30px;
  border-radius: 999px; background: var(--thumb); box-shadow: 0 6px 18px rgba(0,0,0,.15);
  transition: transform .25s ease;
}
/* عند تفعيل الوضع الداكن تتحرك الكرة لليسار */
body.dark .toggle-thumb { transform: translateX(-42px); }
body.dark .toggle-text { color: #dbe4f3; }
body.dark .theme-toggle { --toggle-bg:#1f2430; --toggle-ring:#323a49; --thumb:#0f172a; }
body.dark .sun { opacity: .5; }
body.dark .moon { opacity: 1; color: #e2e8f0; }

/* المقدمة والحاسبة */
.content-flex {
  display: flex; gap: 24px; align-items: flex-start; justify-content: space-between;
  margin-top: 14px; flex-wrap: wrap;
}

.intro-box {
  flex: 1 1 42%;
  background: linear-gradient(180deg,#ffffff,#f7fbff);
  padding: 20px; border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.05);
  line-height: 1.9;
}
.intro-box h2 { color: #0b5ed7; margin: 0 0 10px; }

.intro-table-wrap { margin-top: 14px; }
.source { color:#6b7785; font-size: .9rem; }
.source a { color:#0b5ed7; text-decoration: none; }
.source a:hover { text-decoration: underline; }

/* البطاقة (الحاسبة + الرسم) */
.card {
  flex: 1 1 54%;
  display: grid; grid-template-columns: 1fr; gap: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), var(--card));
  border-radius: 16px; padding: 22px; box-shadow: 0 14px 40px rgba(15,30,50,0.08);
}

.inputs label { display: block; color: var(--muted); margin-top: 12px; margin-bottom: 6px; }
input[type="number"] {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  font-size: 1rem; background: linear-gradient(180deg,#fff,#fbfdff); color: var(--text);
}
.controls { display: flex; gap: 12px; margin-top: 10px; }
.btn {
  background: var(--primary); color: #fff; padding: 12px 16px; border-radius: 12px;
  border: none; font-weight: 700; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 6px 18px rgba(11,78,171,0.12);
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(11,78,171,0.16); }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--border); }

/* النتائج */
.result-box {
  margin-top: 18px; background: linear-gradient(90deg,rgba(6,166,107,0.10),rgba(11,94,215,0.06));
  border-left: 6px solid var(--accent); border-radius: 14px; padding: 18px;
  display: none; flex-direction: column; gap: 12px;
}
.result-box.active { transform: scale(1.02); transition: .4s; }
.results-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-tile { background:#ffffff; border:1px solid #eef4ff; border-radius:12px; padding:12px; box-shadow:0 6px 18px rgba(0,0,0,0.04); }
.result-title { color:#5b6a75; font-size:.95rem; margin-bottom:6px; }
.result-large { font-size:1.55rem; font-weight:800; color:var(--primary); }
.result-sub { color:#5b6a75; font-size:.95rem; }

/* الرسم البياني */
.chart-card { background: linear-gradient(180deg,#ffffff,#fbfdff); padding: 12px; border-radius: 12px; border: 1px solid #eef6ff; box-shadow: 0 4px 16px rgba(0,0,0,0.04); }
canvas { width: 100% !important; height: 360px !important; border-radius: 8px; }

/* الجدول + إخلاء المسؤولية داخل المقدمة */
.small-table {
  margin: 10px 0 8px; width: 100%; border-collapse: collapse; font-size: .82rem;
  background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid #eef2fa;
}
.small-table th, .small-table td { border: 1px solid #eef2fa; padding: 8px 10px; text-align: center; }
.small-table th { background: #f0f7ff; color:#102028; }
.small-table td { color:#102028; }
.small-table tr:nth-child(even) td { background:#fafcff; }

.disclaimer {
  margin-top: 10px; padding: 12px; border-radius: 10px;
  background: #fff7f0; border: 1px solid #ffe6cf; color: #5b5f66; font-size: .95rem; line-height: 1.8;
}

footer { margin-top: 18px; text-align: center; color: #778894; font-size: .92rem; }

/* الوضع الداكن */
body.dark {
  background: radial-gradient(1200px 600px at 25% 15%, #1e1e1e 0%, #141414 45%, #0f0f0f 100%);
  color: #eaeaea;
}
body.dark .hero h1 { color: #8ab4ff; }
body.dark .tagline { color: #cfd6e2; }
body.dark .card { background: #1b1b1d; color: #eaeaea; box-shadow: 0 0 20px rgba(0,0,0,0.45); }
body.dark input[type="number"] { background: #2a2c31; color: #fff; border-color: #3a3f4a; }
body.dark .btn { background: #06a66b; }
body.dark .btn-secondary { background: #2a2c31; color: #fff; border: 1px solid #454a56; }
body.dark .result-tile { background: #22252b; border-color: #353b46; color: #eee; }
body.dark .result-title { color: #c7ced9; }
body.dark .result-sub { color: #c9d0db; }
body.dark .chart-card { background: #1b1b1d; border-color: #303646; box-shadow: 0 6px 18px rgba(0,0,0,0.35); }

/* المقدمة + الجدول في الداكن */
body.dark .intro-box { background: #1c1d21; color: #e7eaf2; box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
body.dark .intro-box h2 { color: #8ab4ff; }
body.dark .small-table { background:#121417; color:#e8ecf3; border:1px solid #2a2f37; }
body.dark .small-table th { background:#1b222c; color:#eef2f8; border-color:#2a2f37; }
body.dark .small-table td { color:#e6ebf2; border-color:#2a2f37; background:#131820; }
body.dark .small-table tr:nth-child(even) td { background:#161c26; }
body.dark .small-table tr:hover td { background:#1c2432; }
body.dark .disclaimer { background:#2b1f1a; border-color:#583c2f; color:#e0c7b1; }

/* استجابة */
@media (max-width: 1020px) {
  .content-flex { flex-direction: column; }
  .intro-box, .card { width: 100%; }
}
