/* ==========================================================================
   theme.css – תפריט עליון מודרני + התאמה לטלפון
   שכבת עיצוב בלבד. לא נוגע בעוגות/גרפים, בטבלאות או בתוכן הדוחות הפנימיים.
   להסרה מלאה: למחוק את שורת ה-link של theme.css ושל theme.js ב-index.html.
   ========================================================================== */
:root {
  --nav-h: 62px;
  --nav-brand: #006ba8;
  --nav-deep: #003a5c;
  --nav-soft: #e4f0f7;
  --nav-surface: #ffffff;
  --nav-line: #dbe6ee;
  --nav-fg: #1c2b38;
  --nav-muted: #5b7385;
  --nav-font: 'Heebo', Calibri, Helvetica, Arial, sans-serif;
  --nav-shadow: 0 10px 30px rgba(16, 42, 67, .18);
}

/* ---------- פס עליון (מחשב) ---------- */
.navigation {
  position: fixed;
  top: 0; right: 0; left: 0; bottom: auto;
  width: auto;
  height: var(--nav-h);
  padding: 0 20px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(100deg, var(--nav-deep), var(--nav-brand));
  box-shadow: 0 2px 14px rgba(0, 30, 50, .25);
  z-index: 99;
  direction: rtl;
  font-family: var(--nav-font);
}
.nav-menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 14px;
}
.brand { display: contents; }
.logo-image { order: 0; margin: 0 !important; display: flex; align-items: center; }
.logo-image img { height: 34px !important; width: auto !important; display: block; }
.nav-menu ul {
  order: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 100%;
  gap: 2px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.nav-menu ul li { margin: 0; height: 100%; align-items: center; position: relative; font-size: 15px; }
.nav-menu ul li.dropdown, .nav-menu ul li:not(.dropdown) { display: flex; }

/* פריטי התפריט העליון */
.nav-menu li > a,
.dropdown .dropbtn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 10px;
  font-family: var(--nav-font);
  font-size: 14.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, .93);
  background: transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-menu li > a:hover,
.dropdown:hover:not(.disabled) .dropbtn { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-menu li > a.is-active,
.dropdown.is-open .dropbtn { background: rgba(255, 255, 255, .20); color: #fff; }
.dropbtn i.fa { margin-inline-start: 4px; font-size: 12px; opacity: .85; }
.dropbtn:focus-visible, .nav-menu a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* אייקונים - אמוג'ים */
.nav-menu li a::before, .dropdown .dropbtn::before {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
  font-weight: 400;
  display: inline-block;
  width: 22px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  opacity: 1;
}
#homeBtn::before { content: "🏠"; }
#WaterMenuBtn::before { content: "💧"; }
#ElectricityMenuBtn::before { content: "⚡"; }
#SolaryMenuBtn::before { content: "☀️"; }
#projectslist .dropbtn::before { content: "📁"; }
#dashboardWater::before, #dashboardElectricity::before { content: "⚠️"; }
#Continuousfaults::before, #ContinuousfaultsElectricity::before { content: "⏳"; }
#communicationQualityWater::before, #communicationQualityElectricity::before { content: "📶"; }
#LeakageReport::before { content: "🚰"; }
a[href="#LeakageExplanContant"]::before { content: "ℹ️"; }
#TrialLeakageReport::before { content: "🧪"; }
#AiReport::before { content: "🤖"; }
#priceComparationElectricity::before { content: "💰"; }
#annualCostReport::before { content: "🧾"; }
#multiYearCostReport::before { content: "📈"; }
#yeshuvSummaryBtn::before { content: "🏘️"; }
#SolarySystemSummaryBtn::before { content: "🔆"; }
#DataStoredBtn::before { content: "🔋"; }
#dailyPowerBtn::before { content: "📊"; }
#MeterCountBtn::before { content: "🔢"; }

/* תפריטי משנה (פאנל נפתח) */
.dropdown-content-menu,
.dropdown-content.projectList {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  left: auto;
  width: auto;
  min-width: 250px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--nav-surface);
  color: var(--nav-fg);
  border: 1px solid var(--nav-line);
  border-radius: 14px;
  box-shadow: var(--nav-shadow);
  padding: 8px;
  z-index: 120;
}
.dropdown-content-menu.show { display: block; background: var(--nav-surface); }
.nav-menu li .dropdown-content-menu a,
.nav-menu li .dropdown-content a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--nav-fg);
  font-family: var(--nav-font);
  font-size: 14.5px !important;
  font-weight: 500;
  text-align: right;
  text-decoration: none;
  background: transparent;
}
.nav-menu li .dropdown-content-menu a:hover,
.nav-menu li .dropdown-content a:hover { background: var(--nav-soft); color: var(--nav-brand); }
.nav-menu li .dropdown-content-menu a.is-active { background: var(--nav-soft); color: var(--nav-brand); font-weight: 600; }
.dropdown-content li { margin: 0; }

/* משתמש + התנתקות (בצד שמאל של הפס) */
.logout {
  order: 2;
  margin-inline-start: auto !important;
  white-space: nowrap;
  text-align: left;
}
.logout h2 { display: inline-block; margin: 0 0 0 10px !important; font-family: var(--nav-font); font-size: 15px; font-weight: 600; color: #fff; vertical-align: middle; }
.logout .btn {
  display: inline-block;
  margin: 0 !important;
  padding: 5px 16px;
  font-family: var(--nav-font);
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  vertical-align: middle;
}
.close, .toggle, .m-logo, .nav-scrim { display: none; }

/* התוכן מתחיל מתחת לפס */
.main { width: 100%; padding: calc(var(--nav-h) + 6px) 24px 48px; }

/* ==========================================================================
   טלפון / טאבלט: תפריט המבורגר + מגירה נפתחת מהצד
   ========================================================================== */
@media (max-width: 1180px) {
  :root { --nav-h: 54px; }
  .navigation { padding: 0 12px; justify-content: flex-start; gap: 12px; }
  .toggle {
    display: grid !important;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
  }
  .m-logo { display: block; height: 28px; }
  .m-logo img { height: 28px; width: auto; display: block; }

  .nav-menu {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    width: min(84vw, 330px);
    height: auto;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--nav-surface);
    color: var(--nav-fg);
    box-shadow: var(--nav-shadow);
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform .28s ease;
    z-index: 210;
  }
  body.menu-open .nav-menu { transform: none; }
  .nav-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(5, 15, 25, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 200;
  }
  body.menu-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }

  .close {
    display: grid !important;
    place-items: center;
    position: absolute;
    top: 14px; left: 14px;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 3;
  }
  .brand {
    display: block;
    background: linear-gradient(100deg, var(--nav-deep), var(--nav-brand));
    padding: 18px 16px 14px;
    flex: none;
  }
  .logo-image { justify-content: flex-start; }
  .logout { margin: 12px 0 0 !important; text-align: right; }
  .logout h2 { margin: 0 0 0 10px !important; }

  .nav-menu ul { flex-direction: column; align-items: stretch; height: auto; gap: 2px; padding: 10px; order: 0; }
  .nav-menu ul li { height: auto; display: block; }
  .nav-menu ul li.dropdown, .nav-menu ul li:not(.dropdown) { display: block; }
  .nav-menu li > a, .dropdown .dropbtn {
    width: 100%;
    padding: 12px;
    font-size: 15.5px;
    color: var(--nav-fg);
    text-align: right;
    border-radius: 11px;
  }
  .dropbtn i.fa { margin-inline-start: auto; }
  .nav-menu li > a:hover, .dropdown:hover:not(.disabled) .dropbtn { background: var(--nav-soft); color: var(--nav-fg); }
  .nav-menu li > a.is-active { background: var(--nav-soft); color: var(--nav-brand); }

  .dropdown-content-menu, .dropdown-content.projectList {
    position: static;
    min-width: 0;
    max-height: none;
    box-shadow: none;
    border: 0;
    border-inline-start: 2px solid var(--nav-line);
    border-radius: 0;
    margin: 0 20px 6px 0;
    padding: 2px 4px 2px 0;
    background: transparent;
  }
  .dropdown-content-menu.show { background: transparent; }
  .dropdown:hover:not(.disabled) .dropdown-content.projectList { display: block; }

  .main { padding: calc(var(--nav-h) + 6px) 12px 40px; }
}

/* ==========================================================================
   טלפון: התאמת התוכן (בלי לשנות את מראה העוגות והגרפים עצמם)
   ========================================================================== */
@media (max-width: 900px) {
  /* בסיס הגלילה: ב-style.css יש touch-action:none שחוסם גלילה במגע */
  body { touch-action: pan-x pan-y; }

  /* מסך התחברות */
  .container { width: 92vw; height: auto; min-height: 70vh; padding: 24px 0; }
  .photo { display: none; }
  .form-cont { width: 100%; margin-right: 0; height: auto; padding: 28px 0 36px; }
  .inner-form { width: 82%; margin-top: 0; }

  /* פריסות שמסודרות בשורה → עמודה */
  .row { flex-direction: column; }
  .row > div, .row > table { max-width: 100%; margin: 8px 0; }
  .grid-container { grid-template-columns: 1fr; }
  .grid-container .col { height: 340px; }
  .gauge { width: calc(50% - 16px); }
  #dashboardTable { width: 100%; float: none; }
  #todayKWHGraph, #pastWeekKWHGraph { width: 100%; float: none; display: block; margin-top: 10px; }
  .squares { flex-wrap: wrap; gap: 8px; }
  .square { width: calc(50% - 10px); margin: 0; }
  .section-title { width: 100%; text-align: center; }
  .navbar-time-selection { flex-wrap: wrap; gap: 8px; height: auto !important; padding: 8px; }
  .navbar-time-selection select, .navbar-time-selection input[type="date"], .navbar-time-selection button { margin: 0; }
  .leakage-form, .Ai-form { gap: 10px; padding: 12px; }
  .searchContainerWrapper { gap: 8px; }
  .chooseTime { width: 100%; }
  .header-container { flex-wrap: wrap; }

  /* טבלאות רחבות: גלילה אופקית בתוך הטבלה, לא בדף */
  .s-container table:not(.solarytable) { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-container { max-width: 100%; }
  h1 { font-size: 21px; }
  .selectedPROJ { font-size: 19px; }
  #tableSearchInput, .tableSearchInput { font-size: 17px; max-width: 60vw; }
  .excel { width: 30px; height: auto; }

  /* דוחות עלויות (שנתי / רב שנתי) */
  .cr-controls { gap: 8px; }
  .cr-sheet { width: 794px; }
  .cr-toolbar .cr-btn { flex: 1 1 130px; }
  .cr-mailbox input { min-width: 0; flex: 1 1 100%; }
  .trial-wrapper { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .nav-menu, .nav-scrim { transition: none; } }

/* ==========================================================================
   מסך התחברות מודרני (#home) - עיצוב בלבד, לא משנה את הלוגיקה של ההתחברות
   ========================================================================== */
.main:has(> #home:not([style*="none"])) {
  background:
    radial-gradient(900px 500px at 85% 0%, rgba(0, 107, 168, .18), transparent 60%),
    radial-gradient(700px 480px at 0% 100%, rgba(0, 170, 140, .14), transparent 60%),
    linear-gradient(160deg, #f3f8fc, #e6eff6);
  min-height: 100vh;
}
#home.container {
  width: min(1080px, 92vw);
  height: min(640px, 82vh);
  top: calc(50% + var(--nav-h) / 2);
  padding: 0;
  display: flex;
  flex-direction: row;
  justify-content: stretch;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 30px 70px rgba(10, 50, 80, .22), 0 2px 8px rgba(10, 50, 80, .08);
  overflow: hidden;
  color: var(--nav-fg);
  font-family: var(--nav-font);
}
#home .photo {
  position: relative;
  flex: 1 1 52%;
  width: auto;
  height: 100%;
  padding: 36px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #003a5c 0%, #006ba8 60%, #1b8fc9 100%);
}
#home .photo::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(420px 300px at 20% 10%, rgba(255, 255, 255, .16), transparent 70%),
    radial-gradient(360px 260px at 90% 95%, rgba(255, 255, 255, .10), transparent 70%);
  pointer-events: none;
}
#home .photo img {
  position: relative;
  width: 100%; height: auto; max-height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 18px 40px rgba(0, 20, 40, .35);
}
#home .form-cont {
  flex: 1 1 48%;
  width: auto; height: 100%;
  margin: 0;
  background: #fff;
  opacity: 1;
  border-radius: 0;
  display: flex;
  align-items: center;
}
#home .inner-form {
  width: min(78%, 360px);
  height: auto;
  margin: 0 auto;
}
#home .inner-form h1 {
  margin: 0 0 6px;
  font-family: var(--nav-font);
  font-size: 27px;
  font-weight: 700;
  color: var(--nav-deep);
  text-align: center;
}
#home .inner-form h1::after {
  content: "התחברות למערכת הניטור";
  display: block;
  margin-top: 6px;
  font-size: 14.5px;
  font-weight: 400;
  color: var(--nav-muted);
}
#home .social-login { display: none; }
#home .input-area { margin-top: 28px; }
#home .input-area input,
#home .password-input input {
  width: 100%;
  margin: 0 0 14px;
  padding: 14px 16px;
  box-sizing: border-box;
  background: #f1f6fa;
  border: 1.5px solid transparent;
  border-radius: 12px;
  color: var(--nav-fg);
  font-family: var(--nav-font);
  font-size: 16px;
  font-weight: 500;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
#home .input-area input::placeholder { color: #7b8fa0; opacity: 1; }
#home .input-area input:focus {
  background: #fff;
  border-color: var(--nav-brand);
  box-shadow: 0 0 0 4px rgba(0, 107, 168, .14);
}
#home #login_btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(100deg, var(--nav-deep), var(--nav-brand));
  color: #fff;
  font-family: var(--nav-font);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 107, 168, .32);
  transition: transform .12s, box-shadow .12s;
}
#home #login_btn:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(0, 107, 168, .4); background: linear-gradient(100deg, var(--nav-deep), var(--nav-brand)); color: #fff; border: 0; }

@media (max-width: 900px) {
  #home.container {
    flex-direction: column;
    width: 92vw; height: auto; min-height: 0;
    top: calc(50% + var(--nav-h) / 2);
    border-radius: 22px;
  }
  #home .photo { display: none; }
  #home .form-cont { padding: 34px 0 38px; }
  #home .inner-form { width: 84%; }
  #home .inner-form h1 { font-size: 23px; }
}

/* ==========================================================================
   דוח שנתי / רב שנתי מפורט - התאמה לטלפון (הדף עצמו זורם לרוחב המסך;
   הטבלאות וגרף העמודות ממשיכים להיגלל הצידה כמו קודם)
   ========================================================================== */
@media (max-width: 760px) {
  .cr-sheet-wrap { padding: 10px 6px; border-radius: 12px; overflow-x: hidden; }
  .cr-sheet { width: 100% !important; max-width: 100%; border-radius: 8px; }
  .cr-head { padding: 18px 16px; gap: 12px; flex-direction: row; flex-wrap: wrap; justify-content: space-between; }
  .cr-title { font-size: 23px; }
  .cr-sub { font-size: 14px; }
  .cr-logo { height: 40px !important; max-width: 46%; object-fit: contain; }
  .cr-body { padding: 16px 14px 6px; }

  .cr-meter { grid-template-columns: 1fr; gap: 0; padding: 8px 12px; }
  .cr-meter div { gap: 10px; font-size: 14px; align-items: baseline; }
  .cr-meter span { min-width: 84px; flex: none; }
  .cr-meter b { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }

  .cr-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cr-kpis > .cr-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .cr-kpi { padding: 12px 12px; min-width: 0; }
  .cr-kpi b { font-size: 17px; overflow-wrap: anywhere; }
  .cr-kpis-2 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

  .cr-h3 { font-size: 16px; }
  .cr-splitbar { height: 30px; }
  .cr-splitbar > div { font-size: 12px !important; line-height: 30px !important; }
  .cr-note { overflow-wrap: anywhere; }

  .cr-logos { padding: 12px 14px 8px !important; }
  .cr-foot { padding: 10px 14px; flex-wrap: wrap; gap: 4px 12px; justify-content: center; }
  .cr-chart { padding: 10px 8px 6px; }
}
@media (max-width: 380px) {
  .cr-kpis, .cr-kpis-2 { grid-template-columns: 1fr !important; }
  .cr-kpis > .cr-kpi { grid-column: auto !important; }
}
