/* ============================================================
   style.css – עיצוב מערכת ניהול פיננסי בעברית
   כל ההגדרות מוסברות בהערות עברית
   ============================================================ */

/* ===== משתני צבעים גלובליים ===== */
:root {
  --bg: #f0f2f5;           /* רקע כללי – אפור בהיר נעים */
  --surface: #ffffff;      /* רקע כרטיסים / פאנלים */
  --border: #e2e8f0;       /* גבולות עדינים */
  --text-main: #1a202c;    /* טקסט ראשי – כמעט שחור */
  --text-muted: #718096;   /* טקסט משני – אפור */
  --primary: #2563eb;      /* כחול ראשי */
  --primary-hover: #1d4ed8;
  --green: #059669;        /* ירוק – נכסים / חיובי */
  --green-bg: #ecfdf5;
  --red: #dc2626;          /* אדום – חובות / שלילי */
  --red-bg: #fef2f2;
  --amber: #d97706;        /* כתום – חשאיים */
  --amber-bg: #fffbeb;
  --blue: #2563eb;         /* כחול – השקעות */
  --blue-bg: #eff6ff;
  --purple: #7c3aed;       /* סגול – שווי נטו */
  --purple-bg: #f5f3ff;
  --radius: 14px;          /* עיגול פינות אחיד */
  --shadow: 0 2px 16px rgba(0,0,0,0.07); /* צל עדין */
  --sidebar-width: 220px;  /* רוחב סרגל צדי */
}

/* ===== איפוס בסיסי ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== גוף הדף: כיוון RTL ועברית ===== */
body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  direction: rtl;             /* כיוון ימין לשמאל */
  text-align: right;          /* יישור טקסט לימין */
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ===== ניהול מסכים: כל מסך מוסתר כברירת מחדל ===== */
.screen {
  display: none;
}

/* מסך פעיל מוצג */
/* .screen.active הוסר – כל מסך מוגדר בנפרד */

/* ============================================================
   מסך הרשמה / התחברות
   ============================================================ */

/* מרכוז ורקע מסך האימות */
#auth-screen.active {
  display: flex !important;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f2f5 50%, #d1fae5 100%);
  z-index: 999;
  overflow-y: auto;
}

/* תיבת ההתחברות */
.auth-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(37, 99, 235, 0.12);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

/* אזור הלוגו */
.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* אייקון הלוגו */
.brand-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .3rem;
}

/* שם המערכת */
.brand-name {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.5px;
}

/* תת-כותרת */
.brand-sub {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: .2rem;
}

/* לשוניות בחירה: התחברות / הרשמה */
.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.5rem;
}

/* כפתור לשונית */
.auth-tab {
  flex: 1;
  padding: .5rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
  font-size: .9rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all .2s;
}

/* לשונית פעילה */
.auth-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

/* טפסי אימות: מוסתרים כברירת מחדל */
.auth-form {
  display: none;
}

/* טופס פעיל */
.auth-form.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================================
   שדות טפסים – שימוש חוזר בכל המסכים
   ============================================================ */

/* עטיפת שדה + תווית */
.field-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* תווית שדה */
.field-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* שדה קלט */
.field-group input,
.field-group select {
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Heebo', sans-serif;
  font-size: .95rem;
  color: var(--text-main);
  background: var(--surface);
  direction: rtl;
  text-align: right;
  transition: border-color .2s;
  outline: none;
}

/* מצב פוקוס על שדות */
.field-group input:focus,
.field-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

/* ============================================================
   כפתורים
   ============================================================ */

/* כפתור ראשי */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .75rem 1.2rem;
  font-family: 'Heebo', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

/* כפתור משני (חזור) */
.btn-secondary {
  background: var(--bg);
  color: var(--text-main);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .7rem 1.2rem;
  font-family: 'Heebo', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* כפתור גוגל */
.btn-google {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .7rem;
  font-family: 'Heebo', sans-serif;
  font-size: .9rem;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--text-main);
  transition: background .2s;
}

.btn-google:hover {
  background: var(--bg);
}

/* מפריד "או" */
.divider {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: var(--text-muted);
  font-size: .85rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* שורת שני כפתורים זה לצד זה */
.btn-row {
  display: flex;
  gap: .7rem;
  margin-top: .5rem;
}
.btn-row .btn-primary,
.btn-row .btn-secondary {
  flex: 1;
}

/* ============================================================
   מסך Onboarding
   ============================================================ */

/* מרכוז מסך Onboarding – position:fixed מבטיח מרכוז מלא */
#onboarding-screen.active {
  display: flex !important;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f2f5 50%, #d1fae5 100%);
  z-index: 999;
  overflow-y: auto;
}

/* תיבת Onboarding */
.onboarding-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(37, 99, 235, .12);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 480px;
}

/* כותרת Onboarding */
.onboarding-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.onboarding-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin: .5rem 0 .3rem;
}

.onboarding-header p {
  color: var(--text-muted);
  font-size: .9rem;
}

/* סרגל התקדמות */
.progress-bar {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-bottom: .4rem;
}

/* מילוי סרגל ההתקדמות – נשלט ע"י JS */
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .4s ease;
  width: 33%;
}

/* תווית שלב */
.progress-label {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

/* שלב Onboarding – מוסתר כברירת מחדל */
.onboarding-step {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

/* שלב פעיל */
.onboarding-step.active {
  display: flex;
}

.onboarding-step h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: .2rem;
}

/* רמז טקסטואלי */
.step-hint {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: -.5rem;
}

/* גריד כרטיסי מטרות */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
}

/* כרטיס מטרה בודד */
.goal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: .9rem .5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  user-select: none;
}

/* אייקון בכרטיס מטרה */
.goal-icon {
  font-size: 1.4rem;
}

/* הסתרת ה-checkbox המקורי */
.goal-card input[type="checkbox"] {
  display: none;
}

/* כרטיס מטרה שנבחר */
.goal-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--blue-bg);
  color: var(--primary);
}

/* ============================================================
   ניווט עליון (Navbar)
   ============================================================ */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}

/* לוגו בניווט */
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

/* אזור משתמש בניווט */
.navbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .9rem;
  color: var(--text-muted);
}

/* כפתור יציאה */
.btn-logout {
  background: var(--red-bg);
  color: var(--red);
  border: none;
  border-radius: 6px;
  padding: .35rem .8rem;
  font-family: 'Heebo', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.btn-logout:hover {
  background: #fecaca;
}

/* ============================================================
   פריסת הדשבורד: Sidebar + Main
   ============================================================ */

.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ===== סרגל צדי ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-left: 1.5px solid var(--border);   /* גבול בצד שמאל (RTL) */
  padding: 1.2rem .8rem;
  flex-shrink: 0;
}

/* ניווט בסרגל הצדי */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

/* פריט ניווט */
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .9rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: all .2s;
}

/* פריט ניווט פעיל */
.nav-item.active,
.nav-item:hover {
  background: var(--blue-bg);
  color: var(--primary);
  font-weight: 700;
}

/* אייקון בניווט */
.nav-icon {
  font-size: 1.1rem;
}

/* ===== תוכן ראשי ===== */
.main-content {
  flex: 1;
  padding: 1.8rem 2rem;
  overflow-y: auto;
}

/* ============================================================
   סקציות תוכן
   ============================================================ */

/* כל סקציה מוסתרת כברירת מחדל */
.content-section {
  display: none;
}

/* סקציה פעילה */
.content-section.active {
  display: block;
  animation: fadeIn .3s ease;
}

/* אנימציית הופעה */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* כותרת סקציה */
.section-header {
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

/* תאריך בסקירה */
.section-date {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ============================================================
   כרטיסי סיכום (Dashboard Cards)
   ============================================================ */

/* גריד 4 כרטיסים */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.8rem;
}

/* כרטיס בסיס */
.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1.5px solid var(--border);
  transition: transform .2s, box-shadow .2s;
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.1);
}

/* אייקון בכרטיס */
.card-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

/* מידע בכרטיס */
.card-info {
  flex: 1;
}

/* תווית הכרטיס */
.card-label {
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: .2rem;
}

/* ערך מספרי בכרטיס */
.card-value {
  font-size: 1.5rem;
  font-weight: 800;
  direction: ltr;   /* מספרים – שמאל לימין */
  text-align: right;
}

/* צבעי כרטיסים ייחודיים */
.card-liquid  { border-top: 4px solid var(--green);  }
.card-liquid .card-value { color: var(--green); }

.card-debt    { border-top: 4px solid var(--red);    }
.card-debt .card-value   { color: var(--red);   }

.card-invest  { border-top: 4px solid var(--blue);   }
.card-invest .card-value { color: var(--blue);  }

.card-networth { border-top: 4px solid var(--purple); }
.card-networth .card-value { color: var(--purple); }

/* ============================================================
   Accordion
   ============================================================ */

/* מיכל Accordion */
.accordion {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

/* כותרת Accordion – לחיצה פותחת/סוגרת */
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  cursor: pointer;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text-main);
  transition: background .2s;
  user-select: none;
}

.accordion-header:hover {
  background: var(--bg);
}

/* חץ Accordion */
.accordion-arrow {
  font-size: .8rem;
  color: var(--text-muted);
  transition: transform .3s;
}

/* חץ כשה-Accordion פתוח */
.accordion.open .accordion-arrow {
  transform: rotate(180deg);
}

/* גוף Accordion – מוסתר ומחכה */
.accordion-body {
  display: none;
  padding: 1rem 1.2rem;
  border-top: 1.5px solid var(--border);
  background: #fafbfc;
}

/* גוף Accordion פתוח */
.accordion.open .accordion-body {
  display: block;
}

/* ============================================================
   רשימת פריטים (בנקים, הלוואות וכו')
   ============================================================ */

/* מיכל רשימה */
.item-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: 1rem;
}

/* שורת פריט בודד */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem 1rem;
  font-size: .9rem;
  animation: fadeIn .2s ease;
}

/* שם הפריט */
.item-name {
  color: var(--text-main);
  font-weight: 500;
}

/* סכום הפריט */
.item-amount {
  font-weight: 700;
  direction: ltr;
}

/* כפתור מחיקת פריט */
.item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: .1rem .3rem;
  border-radius: 4px;
  transition: color .2s;
}

.item-delete:hover {
  color: var(--red);
}

/* שורת הוספת פריט חדש */
.add-item-row {
  display: flex;
  gap: .6rem;
  align-items: center;
}

/* שדות הוספה */
.add-item-row input {
  flex: 1;
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'Heebo', sans-serif;
  font-size: .88rem;
  direction: rtl;
  text-align: right;
  outline: none;
  transition: border-color .2s;
}

.add-item-row input:focus {
  border-color: var(--primary);
}

/* כפתור הוספה */
.btn-add {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .55rem .9rem;
  font-family: 'Heebo', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}

.btn-add:hover {
  background: var(--primary-hover);
}

/* ============================================================
   שורת סיכום (Total Bar)
   ============================================================ */

/* סרגל סיכום ירוק */
.total-bar {
  background: var(--green-bg);
  border: 1.5px solid #a7f3d0;
  border-radius: 10px;
  padding: .9rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--green);
  margin-top: .5rem;
}

/* גרסה אדומה (חובות) */
.total-bar-red {
  background: var(--red-bg);
  border-color: #fca5a5;
  color: var(--red);
}

/* גרסה כחולה (השקעות) */
.total-bar-blue {
  background: var(--blue-bg);
  border-color: #bfdbfe;
  color: var(--blue);
}

.total-bar strong {
  font-size: 1.2rem;
  direction: ltr;
}

/* ============================================================
   כרטיס גרף
   ============================================================ */

.chart-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

/* רמז מתחת לכותרת הגרף */
.chart-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* גרף מיני בסקירה */
.chart-mini-wrap {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--shadow);
}

.chart-mini-wrap h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .8rem;
}

/* ============================================================
   Responsive – עיצוב למובייל
   ============================================================ */

@media (max-width: 768px) {

  /* הסתרת הסרגל הצדי וניווט במגירה */
  .sidebar {
    display: none;
  }

  .main-content {
    padding: 1.2rem 1rem;
  }

  /* כרטיסים בשתי עמודות במובייל */
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* מטרות: 2 עמודות במובייל */
  .goals-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* שורת הוספה במובייל: שורות */
  .add-item-row {
    flex-direction: column;
  }

  .add-item-row input,
  .btn-add {
    width: 100%;
  }

  /* auth container */
  .auth-container {
    margin: 1rem;
    padding: 1.8rem 1.3rem;
  }
}

@media (max-width: 400px) {
  /* כרטיסים בעמודה אחת בטלפונים קטנים */
  .cards-grid {
    grid-template-columns: 1fr;
  }
}


/* דשבורד – block רגיל */
#dashboard-screen.active {
  display: block;
}
