/* ============================================================
   style.css — Loan Calculator
   Light mode by default, dark mode via html[data-theme="dark"]
   ============================================================ */

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

/* ── CSS Variables: Light Mode (default) ── */
:root {
  --bg:       #f4f6fb;
  --surface:  #ffffff;
  --surface2: #eef1f8;
  --border:   #dde2ee;
  --gold:     #c89a10;
  --gold2:    #a87d08;
  --teal:     #009e7f;
  --blue:     #2563eb;
  --red:      #dc2626;
  --text:     #0d1b2e;
  --text2:    #5a6e8a;
  --text3:    #9aaabb;
  --radius:   18px;
  --shadow:   0 8px 40px rgba(0,0,0,0.08);
  --font-ar:  'Cairo', sans-serif;
  --font-en:  'Inter', sans-serif;
}

/* ── CSS Variables: Dark Mode ── */
html[data-theme="dark"] {
  --bg:       #0a0f1e;
  --surface:  #111827;
  --surface2: #1a2235;
  --border:   #1e2d45;
  --gold:     #f5c842;
  --gold2:    #e8a920;
  --teal:     #00d4aa;
  --blue:     #3b82f6;
  --red:      #ef4444;
  --text:     #f0f4ff;
  --text2:    #8899bb;
  --text3:    #4a5e7a;
  --shadow:   0 8px 40px rgba(0,0,0,0.5);
}

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

/* ── Base ── */
body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.25s, color 0.25s;
}

html[lang="en"] body  { font-family: var(--font-en); }

/* ── Background decoration ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(245,200,66,0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0,212,170,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  position: relative;
  z-index: 1;
}

/* ── Controls Bar (language + theme toggles) ── */
.controls-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

html[dir="rtl"] .controls-bar { justify-content: flex-start; }

.toggle-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text2);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-ar);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

html[lang="en"] .toggle-btn { font-family: var(--font-en); }

.toggle-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--gold);
}

/* ── Header ── */
header {
  text-align: center;
  padding: 36px 0 32px;
}

.header-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 20px rgba(245,200,66,0.35));
}

header h1 {
  font-family: 'Tajawal', sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

html[lang="en"] header h1 {
  font-family: var(--font-en);
  font-weight: 800;
}

header p {
  color: var(--text2);
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 300;
}

.site-footer {
  padding: 18px 20px 28px;
  text-align: center;
  color: var(--text2);
}

.footer-brand {
  font-family: 'Tajawal', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gold);
}

.footer-company {
  margin-top: 6px;
  font-size: 0.88rem;
}

html[lang="en"] .footer-brand {
  font-family: var(--font-en);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

html[lang="en"] .tab { font-family: var(--font-en); }

.tab.active {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #fff;
}

html[data-theme="dark"] .tab.active { color: #0a0f1e; }

.tab:not(.active):hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Panels ── */
.panel     { display: none; }
.panel.active { display: block; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Form ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
}

input[type="number"],
input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-en); /* always English font for numbers */
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  direction: ltr;
  text-align: right;
  transition: border-color 0.2s, background 0.25s, color 0.25s;
}

input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,200,66,0.1);
}

input::placeholder {
  color: var(--text3);
  font-weight: 400;
}

/* ── Button ── */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #fff;
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

html[data-theme="dark"] .btn { color: #0a0f1e; }
html[lang="en"] .btn { font-family: var(--font-en); font-weight: 700; }

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(200,154,16,0.35);
}

html[data-theme="dark"] .btn:hover {
  box-shadow: 0 8px 25px rgba(245,200,66,0.3);
}

.btn:active { transform: translateY(0); }

/* ── Error ── */
.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 10px;
  display: none;
  font-weight: 600;
}

.error-msg.show { display: block; }

/* ── Results ── */
.results { display: none; margin-top: 20px; }
.results.show { display: block; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.result-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, background 0.25s, border-color 0.25s, color 0.25s;
}

.result-item:hover { transform: translateY(-2px); }

/* Accent stripe — logical property mirrors in LTR/RTL automatically */
.result-item::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 4px;
  border-start-end-radius: 14px;
  border-end-end-radius: 14px;
}

.result-item.gold::before  { background: var(--gold); }
.result-item.teal::before  { background: var(--teal); }
.result-item.blue::before  { background: var(--blue); }
.result-item.red::before   { background: var(--red); }

.result-label {
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 6px;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: var(--font-en); /* always English numerals */
  direction: ltr;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

html[dir="rtl"] .result-value { flex-direction: row-reverse; }

.result-item.gold .result-value { color: var(--gold); }
.result-item.teal .result-value { color: var(--teal); }
.result-item.blue .result-value { color: var(--blue); }
.result-item.red  .result-value { color: var(--red); }

.result-sub {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 3px;
}

/* ── Progress Bar ── */
.progress-wrap {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.25s, border-color 0.25s;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 10px;
  font-weight: 600;
}

.progress-bar-bg {
  height: 12px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: 99px;
  transition: width 1s ease;
}

/* ── Timeline ── */
.timeline-items {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.timeline-item {
  background: var(--surface2);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  transition: background 0.25s;
}

.timeline-item .tl-label { font-size: 0.75rem; color: var(--text2); margin-bottom: 4px; }
.timeline-item .tl-val   { font-size: 1rem; font-weight: 700; color: var(--text); font-family: var(--font-en); }

/* ── Info Note ── */
.note {
  background: rgba(200,154,16,0.06);
  border: 1px solid rgba(200,154,16,0.18);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 16px;
  line-height: 1.6;
}

html[data-theme="dark"] .note {
  background: rgba(245,200,66,0.06);
  border-color: rgba(245,200,66,0.15);
}

.note strong { color: var(--gold); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.results.show .result-item                   { animation: fadeIn 0.4s ease forwards; }
.results.show .result-item:nth-child(2)      { animation-delay: 0.05s; }
.results.show .result-item:nth-child(3)      { animation-delay: 0.10s; }
.results.show .result-item:nth-child(4)      { animation-delay: 0.15s; }

/* ── Responsive ── */
@media (max-width: 560px) {
  .form-grid       { grid-template-columns: 1fr; }
  .results-grid    { grid-template-columns: 1fr; }
  .timeline-items  { grid-template-columns: 1fr; }
  header h1        { font-size: 1.8rem; }
  .tab             { font-size: 0.75rem; }
}
