/* ===== משתני עיצוב ===== */
:root {
  --bg: #0b0e14;
  --bg-soft: #0f131c;
  --card: #131824;
  --card-hover: #171d2c;
  --border: #222a3a;
  --border-light: #2c3650;
  --text: #e8ebf2;
  --text-soft: #aab2c5;
  --muted: #6b7488;
  --accent: #e11d2e;
  --accent-2: #ff3b3b;
  --accent-soft: rgba(225, 29, 46, 0.13);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 250px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: 'Heebo', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(99, 102, 241, 0.35); }

/* סקרולבר */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3244; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #37415a; }

button { font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 500;
}

.field input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== מבנה כללי ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== סרגל צד ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-soft);
  border-inline-start: none;
  border-inline-end: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(225, 29, 46, 0.3);
}

.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 10px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.13s, color 0.13s;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: start;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--card); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: #ff9d9d;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ===== אזור ראשי ===== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-title { font-size: 17px; font-weight: 700; margin: 0; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip-top {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 6px 12px 6px 8px;
  border-radius: 99px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.user-chip-top:hover { border-color: var(--border-light); }

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.role-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: #ff9d9d;
}

.role-badge.owner { background: var(--warning-soft); color: var(--warning); }

.discord-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(88, 101, 242, 0.1);
  border-bottom: 1px solid rgba(88, 101, 242, 0.3);
  color: var(--text-soft);
  font-size: 13px;
  padding: 10px 28px;
  flex-wrap: wrap;
}

.discord-banner span { display: flex; align-items: center; gap: 8px; }
.discord-banner svg { width: 16px; height: 16px; stroke: #5865f2; }

main.content {
  padding: 26px 28px 60px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== כרטיסים ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.card-title svg { width: 17px; height: 17px; stroke: var(--accent); }

.card-desc { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }

/* ===== רשת סטטיסטיקות ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s, transform 0.15s;
}

.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.indigo { background: var(--accent-soft); }
.stat-icon.indigo svg { stroke: #ff9d9d; }
.stat-icon.green { background: var(--success-soft); }
.stat-icon.green svg { stroke: var(--success); }
.stat-icon.amber { background: var(--warning-soft); }
.stat-icon.amber svg { stroke: var(--warning); }
.stat-icon.red { background: var(--danger-soft); }
.stat-icon.red svg { stroke: var(--danger); }

.stat-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===== טבלאות ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: start;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(34, 42, 58, 0.6);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(23, 29, 44, 0.6); }

.rank-cell { font-weight: 700; color: var(--muted); width: 40px; }
.rank-1 { color: #fbbf24; }
.rank-2 { color: #cbd5e1; }
.rank-3 { color: #d97706; }

/* ===== תגיות ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

.badge.success { background: var(--success-soft); color: var(--success); }
.badge.muted { background: rgba(107, 116, 136, 0.15); color: var(--muted); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: #ff9d9d; }

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== משתמש עם אווטאר ===== */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-chip img, .user-chip .avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar-fallback {
  background: linear-gradient(135deg, #374151, #4b5563);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #d1d5db;
}

.user-chip .uc-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-chip .uc-id { font-size: 11px; color: var(--muted); direction: ltr; text-align: end; }

/* ===== טפסים ===== */
.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-row input, .form-row select, .form-row textarea, .input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9.5px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-row input:focus, .form-row select:focus, .form-row textarea:focus, .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row input, .form-row textarea { flex: 1; min-width: 140px; }
.form-row select { min-width: 170px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.form-grid .field input, .form-grid .field select, .form-grid .field textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9.5px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  width: 100%;
}

.form-grid .field textarea { resize: vertical; min-height: 74px; }

.field-full { grid-column: 1 / -1; }

/* ===== כפתורים ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  padding: 9.5px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; stroke: currentColor; }
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
}

.btn.ghost:hover { border-color: var(--border-light); color: var(--text); opacity: 1; }

.btn.danger {
  background: transparent;
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.btn.danger:hover { background: var(--danger-soft); opacity: 1; }

.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.small svg { width: 13px; height: 13px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.13s;
}

.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.icon-btn:hover { color: var(--text); border-color: var(--border-light); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248, 113, 113, 0.4); background: var(--danger-soft); }

/* ===== צ'יפים לסינון ===== */
.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 6px 14px;
  border-radius: 99px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font);
  transition: all 0.13s;
}

.chip:hover { border-color: var(--border-light); color: var(--text); }

.chip.active {
  background: var(--accent-soft);
  border-color: rgba(225, 29, 46, 0.45);
  color: #ff9d9d;
}

/* ===== חיפוש ===== */
.search-box {
  position: relative;
  margin-bottom: 14px;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 38px 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
}

.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-box svg {
  position: absolute;
  top: 50%;
  inset-inline-start: 12px;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  stroke: var(--muted);
  pointer-events: none;
}

/* ===== טאבים פנימיים ===== */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.sub-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: color 0.13s, border-color 0.13s;
  margin-bottom: -1px;
}

.sub-tab:hover { color: var(--text-soft); }
.sub-tab.active { color: #ff9d9d; border-bottom-color: var(--accent); }

/* ===== מצב ריק ===== */
.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  stroke: #333d52;
  margin-bottom: 10px;
}

.empty-state p { margin: 0; font-size: 13.5px; }

/* ===== שלד טעינה ===== */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row { height: 46px; margin-bottom: 10px; }
.skeleton-card { height: 84px; }

/* ===== מודאל ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 26px;
  width: 480px;
  max-width: 100%;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: rise 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal.wide { width: 640px; }

.modal h3 { margin: 0 0 6px; font-size: 16.5px; }
.modal .modal-desc { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

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

/* ===== שיחת זיכרון ===== */
.chat-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px 2px;
}

.chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 13px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-bottom-left-radius: 4px;
}

.chat-msg .chat-time { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; }

/* ===== טוסטים ===== */
.toast-container {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 340px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.out { animation: toastOut 0.25s ease forwards; }

@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px); }
}

.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.toast.success svg { stroke: var(--success); }
.toast.error svg { stroke: var(--danger); }

/* ===== שונות ===== */
.text-muted { color: var(--muted); }
.text-small { font-size: 12px; }
.mono { direction: ltr; unicode-bidi: embed; font-family: Consolas, monospace; font-size: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mb-0 { margin-bottom: 0; }

.trig-reply {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.trig-reply:last-child { border-bottom: none; }
.icon-btn.small { width: 24px; height: 24px; flex-shrink: 0; }
.icon-btn.small svg { width: 11px; height: 11px; }

.note-text {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 480px;
  font-size: 13px;
  color: var(--text-soft);
}

.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.check-list .checkbox-row { padding: 3px 0; }

/* ===== מובייל ===== */
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    z-index: 90;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }

  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }

  .menu-toggle {
    display: inline-flex;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .menu-toggle svg { width: 18px; height: 18px; stroke: currentColor; }

  main.content { padding: 18px 16px 50px; }
  .topbar { padding: 12px 16px; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, 0.6);
    z-index: 80;
  }
}
