/**
 * MealFlow - Global design system.
 *
 * v0.1.3 VISUAL REFRESH:
 * - Introduces a softer, modern visual language for all screens.
 * - Adds shared spacing, typography, button, card and dashboard rules.
 * - Keeps role-specific layout rules in their dedicated CSS files.
 *
 * IMPORTANT:
 * This file contains presentation only. No business logic belongs here.
 */

:root {
  --bg: #f4f7fb;
  --bg-soft: #eef4ff;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --text: #1d2939;
  --text-soft: #475467;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #4967f2;
  --primary-hover: #3d56d8;
  --primary-soft: #eef1ff;
  --success: #15803d;
  --danger: #b42318;
  --warning: #b54708;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --shadow-sm: 0 6px 20px rgba(16, 24, 40, 0.06);
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.09);
  --transition: 160ms ease;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Rubik", Arial, sans-serif;
  background:
    radial-gradient(circle at 90% 5%, rgba(73, 103, 242, 0.10), transparent 28%),
    radial-gradient(circle at 8% 28%, rgba(20, 184, 166, 0.07), transparent 24%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition),
    border-color var(--transition);
}

.btn:hover {
  text-decoration: none;
  border-color: #cfd5de;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.btn-primary {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), #6f7ff5);
  color: #fff;
  box-shadow: 0 10px 22px rgba(73, 103, 242, 0.22);
}

.btn-primary:hover {
  border-color: var(--primary-hover);
  background: linear-gradient(135deg, var(--primary-hover), #5e6ee7);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.btn-small {
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.muted {
  color: var(--muted);
}

.form-message {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.94rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px max(18px, calc((100vw - 1100px) / 2));
  background: rgba(255, 255, 255, 0.90);
  border-bottom: 1px solid rgba(228, 231, 236, 0.85);
  backdrop-filter: blur(14px);
}

.topbar strong {
  font-size: 1.02rem;
  font-weight: 700;
}

.dashboard {
  width: min(1100px, calc(100% - 28px));
  margin: 28px auto 64px;
}

.dashboard h1 {
  margin: 0 0 20px;
  font-size: clamp(1.65rem, 3vw, 2.2rem);
}

.hero-card,
.summary-card,
.panel-card,
.action-card {
  background: var(--surface);
  border: 1px solid rgba(228, 231, 236, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.page-section-title {
  margin: 26px 0 12px;
  color: var(--text-soft);
  font-size: 1rem;
  font-weight: 700;
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 14px;
  }

  .dashboard {
    width: min(100% - 22px, 1100px);
    margin-top: 18px;
  }

  .btn {
    min-height: 48px;
  }
}


/**
 * Global application version footer.
 * Every MealFlow screen uses the same centralized APP_VERSION value.
 */
.app-version-footer {
  width: 100%;
  padding: 18px 12px 22px;
  text-align: center;
  color: #98a2b3;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}


/**
 * Global reusable password visibility UI.
 * RTL-safe and shared by every MealFlow password input.
 */
.password-input-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.password-input-wrap > input {
  width: 100%;
  padding-left: 48px !important;
}
.password-eye-button {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #667085;
  cursor: pointer;
  z-index: 2;
}
.password-eye-button:hover {
  background: #f2f4f7;
  color: #344054;
}
.password-eye-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.password-eye-button.is-visible {
  color: #4967f2;
}


/* v0.2.2 forgot-password flow */
.forgot-password-link,
.auth-back-link {
  display: inline-block;
  margin-top: 12px;
  color: #4967f2;
  text-decoration: none;
  font-weight: 600;
}
.reset-request-status {
  margin-top: 18px;
  padding: 15px;
  border: 1px solid #dbe2ff;
  border-radius: 14px;
  background: #f8f9ff;
}
.reset-request-status p {
  margin: 6px 0 12px;
  color: #667085;
}

/* v0.3.3 global responsive modal scrolling */
.modal-overlay,.dialog-overlay,.overlay{overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-block:max(10px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-bottom))}
.modal,.dialog,.modal-card,.dialog-card,[role="dialog"]{box-sizing:border-box;max-width:100%;max-height:calc(100dvh - 20px)!important;overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
@supports not (height:100dvh){.modal,.dialog,.modal-card,.dialog-card,[role="dialog"]{max-height:calc(100vh - 20px)!important}}
@media(max-width:640px){.modal,.dialog,.modal-card,.dialog-card,[role="dialog"]{width:min(100%,calc(100vw - 16px))!important}}


/* ================================================================
   v0.4.4 - Visual refresh: brighter, softer, modern MealFlow UI
   ================================================================ */

:root {
  --mf-gradient: linear-gradient(135deg, #4967f2 0%, #7a5af8 52%, #16b8a6 120%);
  --mf-gradient-soft: linear-gradient(135deg, rgba(73,103,242,.11), rgba(122,90,248,.08), rgba(22,184,166,.08));
}

/* More alive top bar without becoming noisy. */
.topbar {
  min-height: 68px;
  padding-top: 11px;
  padding-bottom: 11px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.94), rgba(247,249,255,.92));
  border-bottom: 1px solid rgba(180,190,220,.35);
  box-shadow: 0 8px 28px rgba(36,49,96,.08);
}

.topbar::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 3px;
  background: var(--mf-gradient);
  opacity: .85;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title strong,
.topbar > strong {
  position: relative;
  font-size: 1.04rem;
  letter-spacing: -.01em;
}

.topbar-title strong::before,
.topbar > strong::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-inline-end: 8px;
  border-radius: 50%;
  background: var(--mf-gradient);
  box-shadow: 0 0 0 5px rgba(73,103,242,.09);
  vertical-align: 1px;
}

/* Shared inputs/selects: remove the old square "system form" feel. */
input,
select,
textarea {
  border-radius: 14px;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  min-height: 48px;
  border: 1px solid #d8deea;
  background: rgba(255,255,255,.98);
  color: var(--text);
  padding: 11px 13px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(16,24,40,.025);
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease,
    background .16s ease;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: #b8c2d6;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: #7587f5;
  box-shadow: 0 0 0 4px rgba(73,103,242,.10);
  background: #fff;
}

/* Native date input still looks integrated rather than rectangular. */
input[type="date"],
input[type="time"] {
  border-radius: 14px !important;
  padding-inline: 14px;
  cursor: pointer;
}

/* Full screen loading state */
.mealflow-loading-overlay {
  position: fixed;
  z-index: 99999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 38%, rgba(73,103,242,.14), transparent 30%),
    rgba(244,247,251,.82);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.mealflow-loading-overlay[hidden] {
  display: none !important;
}

.mealflow-loader-card {
  width: min(330px, calc(100vw - 32px));
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 28px 24px 24px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 24px 70px rgba(36,49,96,.18);
  text-align: center;
}

.mealflow-loader-card strong {
  margin-top: 6px;
  font-size: 1.04rem;
}

.mealflow-loader-card > span {
  color: var(--muted);
  font-size: .86rem;
}

.mealflow-loader-mark {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.mealflow-loader-mark span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
  animation: mfLoaderBounce .9s infinite ease-in-out;
}

.mealflow-loader-mark span:nth-child(2) {
  animation-delay: .12s;
  background: #7a5af8;
}

.mealflow-loader-mark span:nth-child(3) {
  animation-delay: .24s;
  background: #16b8a6;
}

@keyframes mfLoaderBounce {
  0%, 100% { transform: translateY(0) scale(.9); opacity: .55; }
  50% { transform: translateY(-9px) scale(1.08); opacity: 1; }
}

.is-mealflow-loading body {
  overflow: hidden;
}

/* v0.4.5 */
[hidden]{display:none!important}

/* Keep the current screen title geometrically centered while Back/Logout stay at edges. */
.topbar{position:sticky}
.topbar>.topbar-title{flex:1;display:grid;grid-template-columns:1fr auto 1fr;align-items:center}
.topbar>.topbar-title>a:first-child{justify-self:start}
.topbar>.topbar-title>strong{justify-self:center;white-space:nowrap}
.topbar>.topbar-title+button{margin-inline-start:12px}
@media(min-width:641px){
  .topbar:has(>.topbar-title)>.topbar-title{
    position:absolute;left:50%;transform:translateX(-50%);
    width:min(720px,60vw);pointer-events:none;
  }
  .topbar:has(>.topbar-title)>.topbar-title>*{pointer-events:auto}
  .topbar:has(>.topbar-title)>.topbar-title>a:first-child{
    position:fixed;right:max(18px,calc((100vw - 1100px)/2));
  }
  .topbar:has(>.topbar-title)>button{margin-inline-start:auto}
}


/* ================================================================
   v0.4.6 - No-flicker first paint
   ================================================================ */
html.mf-boot-loading body {
  overflow: hidden;
}
html.mf-boot-loading body > * {
  visibility: hidden !important;
}
html.mf-boot-loading body::before {
  content: "";
  visibility: visible !important;
  position: fixed;
  z-index: 99998;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(73,103,242,.14), transparent 30%),
    #f4f7fb;
}
html.mf-boot-loading body::after {
  content: "טוען נתונים · אנא המתן...";
  visibility: visible !important;
  position: fixed;
  z-index: 99999;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  min-width: 230px;
  padding: 22px 26px;
  border: 1px solid rgba(180,190,220,.5);
  border-radius: 22px;
  background: #fff;
  color: #475467;
  box-shadow: 0 24px 70px rgba(36,49,96,.16);
  text-align: center;
  font-weight: 700;
}

/* ================================================================
   v0.4.6 - Desktop topbar correction
   Back | exact centered page title | Logout
   ================================================================ */
.topbar:has(> .topbar-title) {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  align-items: center !important;
}
.topbar:has(> .topbar-title) > .topbar-title {
  display: contents !important;
  position: static !important;
  width: auto !important;
  transform: none !important;
}
.topbar:has(> .topbar-title) > .topbar-title > a:first-child {
  grid-column: 1 !important;
  justify-self: start !important;
  position: static !important;
  inset: auto !important;
  transform: none !important;
  margin: 0 !important;
  white-space: nowrap;
}
.topbar:has(> .topbar-title) > .topbar-title > strong {
  grid-column: 2 !important;
  justify-self: center !important;
  position: static !important;
  inset: auto !important;
  transform: none !important;
  margin: 0 !important;
  white-space: nowrap;
  text-align: center;
}
.topbar:has(> .topbar-title) > #logoutBtn,
.topbar:has(> .topbar-title) > button:last-child {
  grid-column: 3 !important;
  justify-self: end !important;
  position: static !important;
  margin: 0 !important;
}

@media (max-width: 640px) {
  .topbar:has(> .topbar-title) {
    grid-template-columns: auto 1fr auto !important;
    gap: 8px !important;
  }
  .topbar:has(> .topbar-title) > .topbar-title > strong {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* v0.4.9 - synchronized Israel application clock */
.system-israel-clock {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 4px;
  padding: 5px 10px;
  border: 1px solid rgba(180,190,220,.42);
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  color: #475467;
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(36,49,96,.04);
}
@media (max-width: 640px) {
  .system-israel-clock {
    width: max-content;
    max-width: 92vw;
    font-size: .7rem;
    margin-inline: auto;
  }
}

/* v0.4.31 - install cards for Admin/Kitchen PWAs */
.role-install-card{
  position:fixed;z-index:1400;inset-inline:14px;bottom:14px;
  display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:center;
  max-width:760px;margin-inline:auto;padding:12px;border-radius:20px;
  background:rgba(255,255,255,.97);box-shadow:0 18px 50px rgba(31,41,55,.20);
  border:1px solid rgba(120,130,160,.18);backdrop-filter:blur(14px);
}
.role-install-card[hidden]{display:none}
.role-install-admin{border-color:rgba(55,106,255,.22)}
.role-install-kitchen{border-color:rgba(52,191,129,.25)}
.role-install-icon{width:56px;height:56px;border-radius:16px;box-shadow:0 8px 20px rgba(40,50,90,.15)}
.role-install-copy{display:grid;gap:3px;min-width:0}
.role-install-copy strong{font-size:.92rem}
.role-install-copy span,.role-install-copy small{font-size:.75rem;line-height:1.45;color:var(--muted)}
.role-install-actions{display:flex;gap:6px}
.role-install-actions .btn{min-height:36px;padding:7px 11px;white-space:nowrap}
@media(max-width:620px){
  .role-install-card{grid-template-columns:auto 1fr}
  .role-install-actions{grid-column:1/-1}
  .role-install-actions .btn{flex:1}
}


/* ================================================================
   v0.4.38 - Compact two-line date/time in all MealFlow applications
   Line 1: weekday + time | Line 2: date
   ================================================================ */
[data-server-time],
[data-date-time],
.server-time,
.server-clock,
.topbar-time,
.date-time,
.datetime-display,
.clock-display{
  display:inline-flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  gap:1px !important;
  max-width:125px !important;
  min-width:82px !important;
  line-height:1.08 !important;
  white-space:normal !important;
  text-align:center !important;
  font-size:.72rem !important;
}

[data-server-time] .time-line,
[data-date-time] .time-line,
.server-time .time-line,
.server-clock .time-line,
.topbar-time .time-line,
.date-time .time-line,
.datetime-display .time-line,
.clock-display .time-line{
  display:block !important;
  font-size:.74rem !important;
  font-weight:700 !important;
  white-space:nowrap !important;
}

[data-server-time] .date-line,
[data-date-time] .date-line,
.server-time .date-line,
.server-clock .date-line,
.topbar-time .date-line,
.date-time .date-line,
.datetime-display .date-line,
.clock-display .date-line{
  display:block !important;
  font-size:.65rem !important;
  opacity:.78 !important;
  white-space:nowrap !important;
}

@media(max-width:480px){
  [data-server-time],
  [data-date-time],
  .server-time,
  .server-clock,
  .topbar-time,
  .date-time,
  .datetime-display,
  .clock-display{
    max-width:105px !important;
    font-size:.67rem !important;
  }
}

/* v0.4.39 - actual two-line Israel clock */
.system-israel-clock{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  gap:1px !important;
  width:max-content !important;
  max-width:min(150px, 88vw) !important;
  white-space:normal !important;
  text-align:center !important;
  padding:4px 10px !important;
}
.system-israel-clock .israel-clock-line{
  display:block !important;
  width:100%;
  white-space:nowrap !important;
  text-align:center !important;
  line-height:1.12 !important;
}
.system-israel-clock .israel-clock-primary{
  font-size:.70rem !important;
  font-weight:700 !important;
}
.system-israel-clock .israel-clock-date{
  margin-top:1px !important;
  font-size:.62rem !important;
  font-weight:600 !important;
  opacity:.82 !important;
}
@media(max-width:640px){
  .system-israel-clock{
    max-width:120px !important;
    margin-inline:auto !important;
  }
}


/* ================================================================
   v0.4.45 - hard guarantee: Israel clock is always two real lines.
   Line 1: weekday + time
   Line 2: date
   ================================================================ */
.system-israel-clock{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  white-space:normal !important;
}
.system-israel-clock > .israel-clock-line{
  display:block !important;
  flex:0 0 auto !important;
  width:100% !important;
  white-space:nowrap !important;
  text-align:center !important;
}
.system-israel-clock > .israel-clock-primary{
  order:1 !important;
}
.system-israel-clock > .israel-clock-date{
  order:2 !important;
}

/* v0.4.47 - compact legal navigation */
.legal-links{display:flex;justify-content:center;flex-wrap:wrap;gap:6px 12px;margin:12px auto 0;padding:0 14px;font-size:.75rem;color:var(--muted)}
.legal-links a{color:var(--text-soft);font-weight:600}

/* v0.4.48 - progressive student registration: one primary action per step */
.registration-create-step[hidden] { display: none !important; }
.registration-create-step { margin-top: .25rem; }
.registration-create-hint { margin: 0 0 .6rem; font-size: .92rem; }
.otp-panel.is-verified .otp-send-button,
.otp-panel.is-verified .otp-verify-area { display: none !important; }
.otp-panel.is-verified { border-color: rgba(34, 197, 94, .38); }


/* v0.4.58 - Abush brand assets */
.app-brand-logo {
  display: block;
  width: min(210px, 64vw);
  max-height: 165px;
  object-fit: contain;
  margin: 2px auto 18px;
}
.app-brand-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.app-brand-inline img {
  width: 42px;
  height: 36px;
  object-fit: contain;
  flex: 0 0 auto;
}
.app-brand-inline span {
  min-width: 0;
}
@media (max-width: 640px) {
  .app-brand-logo {
    width: min(180px, 58vw);
    max-height: 140px;
    margin-bottom: 14px;
  }
  .app-brand-inline { gap: 6px; }
  .app-brand-inline img { width: 36px; height: 31px; }
}

/* v0.4.68 - shared bounded-history pagination */
.history-load-more-wrap{display:flex;justify-content:center;padding:14px 0 2px}
.history-load-more-wrap [hidden]{display:none!important}
