/* ------------------------------------------------------------------
   מערכת העלאת מסמכים - עיצוב ראשי (RTL)
------------------------------------------------------------------ */

:root {
  --navy: #1f3a5f;
  --navy-dark: #16304f;
  --navy-soft: #eef2f7;
  --text: #1a2430;
  --text-muted: #5f6c7b;
  --line: #dde3ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --green: #12703f;
  --green-bg: #e9f5ee;
  --amber: #8a6100;
  --amber-bg: #fdf4e3;
  --red: #a8271b;
  --red-bg: #fcecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Assistant", "Rubik", Arial, "Noto Sans Hebrew", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--navy); }

/* ------------------------------- מבנה כללי ------------------------------ */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 0;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.12);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

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

.topbar a, .topbar button.linklike {
  color: #dce6f2;
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 8px;
}

.topbar a:hover, .topbar button.linklike:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.container-narrow { max-width: 760px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

h1 { font-size: 1.6rem; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 12px; font-weight: 600; }

.subtitle { color: var(--text-muted); margin: 0; font-size: 0.98rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 20px;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-dark); }

.btn-secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--navy-soft); }

.btn-danger { background: #fff; color: var(--red); border-color: #efc9c4; }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); }

.btn-sm { font-size: 0.9rem; padding: 8px 14px; min-height: 38px; }

.btn-block { width: 100%; }

/* --------------------------------- טפסים -------------------------------- */

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }

input[type="text"], input[type="password"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  min-height: 46px;
}

input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.12);
}

.field { margin-bottom: 16px; }

.hint { color: var(--text-muted); font-size: 0.88rem; margin-top: 6px; }

/* -------------------------------- כרטיסים ------------------------------- */

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-card-name { font-size: 1.15rem; font-weight: 700; margin: 0; }

.client-card-meta { color: var(--text-muted); font-size: 0.92rem; }

.client-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ------------------------------ תגיות סטטוס ----------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.87rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-done { background: var(--green-bg); color: var(--green); }
.badge-partial { background: var(--amber-bg); color: var(--amber); }
.badge-empty { background: #eef1f5; color: var(--text-muted); }

/* -------------------------------- פס התקדמות ---------------------------- */

.progress {
  background: #e7ebf1;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-bar { background: var(--green); height: 100%; width: 0; transition: width 0.3s ease; }

/* ------------------------------ רשימת מסמכים ---------------------------- */

.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.doc-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.doc-item.is-done { border-color: #c7e3d3; background: #fbfefc; }

.doc-info { flex: 1 1 240px; min-width: 0; }

.doc-name { font-weight: 600; font-size: 1.05rem; margin: 0 0 4px; word-break: break-word; }

.doc-meta { color: var(--text-muted); font-size: 0.88rem; word-break: break-word; }

.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------- קישור אישי להעתקה -------------------------- */

.link-box {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--navy-soft);
  border: 1px solid #d5deea;
  border-radius: 10px;
  padding: 12px 14px;
}

.link-text {
  flex: 1 1 260px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  direction: ltr;
  text-align: left;
  word-break: break-all;
  color: var(--navy-dark);
}

/* -------------------------------- הודעות -------------------------------- */

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.alert-error { background: var(--red-bg); color: var(--red); border-color: #f0cbc6; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #c7e3d3; }
.alert-info { background: var(--navy-soft); color: var(--navy-dark); border-color: #d5deea; }

.toast {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
  font-weight: 600;
  max-width: calc(100vw - 44px);
}

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; }

/* ------------------------------ עורך מסמכים ----------------------------- */

.doc-editor-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.doc-editor-row input { flex: 1; }

.row-index {
  color: var(--text-muted);
  font-size: 0.9rem;
  min-width: 22px;
  text-align: center;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

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

/* -------------------------------- מודאל --------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25);
}

.modal h2 { margin-top: 0; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; flex-wrap: wrap; }

.hidden { display: none !important; }

/* ------------------------------ מסך הכניסה ------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

/* -------------------------------- דף לקוח ------------------------------- */

.client-header {
  background: linear-gradient(180deg, var(--navy) 0%, #24466f 100%);
  color: #fff;
  padding: 28px 0 32px;
}

.client-header-inner { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.client-office { font-size: 0.95rem; opacity: 0.85; margin: 0 0 6px; }

.client-title { font-size: 1.55rem; font-weight: 700; margin: 0 0 10px; }

.client-intro { margin: 0; opacity: 0.92; font-size: 1rem; }

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.summary-count { font-size: 1.2rem; font-weight: 700; }

.file-input { display: none; }

/* -------------------------------- נייד ---------------------------------- */

@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 20px 14px 56px; }
  h1 { font-size: 1.35rem; }
  .client-grid { grid-template-columns: 1fr; }
  .doc-item { align-items: stretch; }
  .doc-actions { width: 100%; }
  .doc-actions .btn { flex: 1 1 auto; }
  .client-card-actions .btn { flex: 1 1 auto; }
  .modal { padding: 18px; }
  .toast { inset-inline-start: 14px; inset-inline-end: 14px; text-align: center; }
}

/* --------------------------- מחלקות עזר לריווח --------------------------- */
/* משמשות במקום style בתוך ה-HTML, כדי לעמוד במדיניות ה-CSP המחמירה */

.u-mb-10 { margin-bottom: 10px; }
.u-mb-14 { margin-bottom: 14px; }
.u-mb-22 { margin-bottom: 22px; }
.u-mt-16 { margin-top: 16px; }
.u-m-0 { margin: 0; }
.u-hint-tight { margin-top: 0; margin-bottom: 10px; }
.u-center { text-align: center; }
.u-logo-center { margin: 0 auto 16px; }

/* תגית הסטטוס בכרטיס הלקוח נצמדת לתוכן ולא נמתחת לרוחב הכרטיס */
.client-card > .badge { align-self: flex-start; }

/* ------------------------------ מיתוג המשרד ----------------------------- */

.client-brand { margin-bottom: 12px; }

/* הלוגו נשמר ביחס ממדים מקורי ואינו משתלט על העמוד */
.client-logo {
  display: block;
  max-height: 60px;
  max-width: 210px;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.topbar-actions a.is-active { background: rgba(255, 255, 255, 0.16); color: #fff; }

.divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0 20px; }

/* --------------------------- לוגו במסך ההגדרות -------------------------- */

.logo-box {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.logo-preview {
  flex: 0 0 auto;
  width: 200px;
  height: 110px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.logo-empty { color: var(--text-muted); font-size: 0.9rem; }

.logo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 220px;
}

.logo-actions .hint { margin-top: 0; }

@media (max-width: 640px) {
  .client-logo { max-height: 48px; max-width: 160px; }
  .logo-box { flex-direction: column; align-items: stretch; }
  .logo-preview { width: 100%; height: 120px; }
  .logo-actions .btn { width: 100%; }
}
