:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-dark: #3730a3;
  --accent: #f59e0b;
  --bg: #eef1f8;
  --card-bg: #ffffff;
  --text: #1e2233;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #16a34a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 18px rgba(30, 41, 82, 0.08);
  --shadow-lg: 0 14px 40px rgba(30, 41, 82, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(124, 58, 237, 0.08), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(245, 158, 11, 0.08), transparent 40%),
    var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  background: linear-gradient(120deg, var(--primary-dark), var(--primary) 55%, var(--primary-2));
  color: #fff;
  padding: 26px 24px;
  box-shadow: var(--shadow-lg);
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
}

.topbar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% -20%, rgba(255,255,255,0.18), transparent 55%);
  pointer-events: none;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.topbar h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.edit-badge {
  background: linear-gradient(120deg, #ffd166, #ffb703);
  color: #7a4a00;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 3px 10px rgba(255, 183, 3, 0.4);
}

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

/* ---- Controls bar ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  background: var(--card-bg);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.view-switch {
  display: flex;
  gap: 4px;
  background: #f1f2fb;
  padding: 5px;
  border-radius: 999px;
}

.view-btn {
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
  transition: all 0.2s ease;
}

.view-btn:hover:not(.active) {
  color: var(--primary-dark);
  background: #e6e7fb;
}

.view-btn.active {
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(79, 70, 229, 0.45); }

.btn-secondary {
  background: #eef0fb;
  color: var(--primary-dark);
}
.btn-secondary:hover { background: #e3e5fa; }

.btn-danger {
  background: linear-gradient(120deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

/* ---- Legend ---- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--card-bg);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  background: #f6f7fc;
  padding: 7px 14px;
  border-radius: 999px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.legend-item:hover {
  background: #eef0fb;
  border-color: var(--border);
}

.legend-item input[type=checkbox] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

/* ---- Calendar card ---- */
.calendar-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.hidden { display: none !important; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 40, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px 26px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border-top: 5px solid var(--primary);
  animation: slideUp 0.2s ease;
}

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

.modal h2 {
  margin-top: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

#event-form label,
#settings-form label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

#event-form input,
#event-form select,
#event-form textarea,
#settings-form select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #fafbff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#event-form input:focus,
#event-form select:focus,
#event-form textarea:focus,
#settings-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #fff;
}

.row {
  display: flex;
  gap: 12px;
}
.row label { flex: 1; }

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.spacer { flex: 1; }

.form-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.settings-hint {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: -6px;
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(120deg, #1e2233, #111827);
  color: #fff;
  padding: 13px 24px;
  border-radius: 999px;
  z-index: 2000;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.toast-error { background: linear-gradient(120deg, #ef4444, #dc2626); }

/* ---- FullCalendar theming ---- */
.fc {
  direction: rtl;
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
}
.fc .fc-toolbar-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}
.fc .fc-button {
  background: #eef0fb !important;
  border: none !important;
  color: var(--primary-dark) !important;
  box-shadow: none !important;
  font-weight: 600;
  border-radius: 10px !important;
  transition: background 0.15s ease;
}
.fc .fc-button:hover {
  background: #e0e2f9 !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-today-button {
  background: linear-gradient(120deg, var(--primary), var(--primary-2)) !important;
  color: #fff !important;
}
.fc .fc-today-button:disabled {
  background: #eef0fb !important;
  color: var(--muted) !important;
  opacity: 0.6;
}
.fc-theme-standard td, .fc-theme-standard th {
  border-color: var(--border);
}
.fc .fc-col-header-cell {
  background: #f6f7fc;
  padding: 6px 0;
}
.fc .fc-col-header-cell-cushion {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.fc-day-today {
  background: rgba(79, 70, 229, 0.06) !important;
}
.fc .fc-daygrid-day-number {
  font-weight: 600;
  color: var(--text);
  padding: 6px 8px;
}
.fc-day-sat .fc-daygrid-day-number,
.fc-day-fri .fc-daygrid-day-number {
  color: var(--primary-2);
}
.fc-event {
  cursor: pointer;
  border: none !important;
  border-radius: 8px !important;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 1px 4px;
}
.fc-daygrid-event-dot { display: none; }
.fc-multimonth-title {
  font-weight: 800;
  color: var(--primary-dark);
}
.fc-multimonth {
  border-radius: 12px;
  overflow: hidden;
}

/* ---- תאריך עברי / חגים / פרשות ---- */
.hebrew-day-info {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: stretch;
  padding: 0 5px 5px;
  width: 100%;
  box-sizing: border-box;
}

.hebrew-date {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
  text-align: end;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holiday-badge,
.parasha-badge {
  font-size: 0.64rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  cursor: help;
}

.holiday-badge {
  background: linear-gradient(120deg, #fef3c7, #fde68a);
  color: #92400e;
  font-weight: 700;
}

.parasha-badge {
  background: linear-gradient(120deg, #ede9fe, #ddd6fe);
  color: #5b21b6;
  font-weight: 700;
}

/* גרסה קומפקטית - לתצוגת שנה, כשהתא צר יותר */
.hebrew-day-info.compact {
  gap: 1px;
  padding: 0 2px 3px;
}
.hebrew-day-info.compact .hebrew-date {
  font-size: 0.52rem;
}
.hebrew-day-info.compact .holiday-badge,
.hebrew-day-info.compact .parasha-badge {
  font-size: 0.5rem;
  padding: 0px 3px;
  border-radius: 6px;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .topbar { padding: 18px 16px; border-radius: 0 0 20px 20px; }
  .topbar h1 { font-size: 1.15rem; }
  .container { padding: 0 10px 40px; margin: 18px auto; }
  .controls { padding: 10px 12px; }
  .view-btn { padding: 8px 12px; font-size: 0.8rem; }
  .btn { padding: 9px 14px; font-size: 0.88rem; }
  .modal { padding: 20px 18px; }
  .calendar-wrap { padding: 12px; }
}
