/* ═══════════════════════════════════════════════
   RESET & TOKENS
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --indigo-900: #1e1b4b;
  --indigo-800: #2e2a6e;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-100: #e0e7ff;
  --indigo-50:  #eef2ff;

  /* Semantic */
  --green:      #10b981;
  --green-light:#d1fae5;
  --green-dark: #065f46;
  --orange:     #f59e0b;
  --orange-light:#fef3c7;
  --orange-dark: #92400e;
  --red:        #ef4444;
  --red-light:  #fee2e2;
  --red-dark:   #991b1b;

  /* Grays */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Surfaces */
  --bg:    #f0f4ff;
  --card:  #ffffff;
  --border: var(--gray-200);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-colored: 0 4px 14px rgba(99,102,241,.25);

  /* Misc */
  --sidebar-w: 248px;
  --r:    14px;
  --r-sm: 9px;
  --transition: 0.18s ease;
}

html { font-size: 15px; }

body {
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--gray-700);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}


/* ═══════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}


/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(175deg, var(--indigo-900) 0%, var(--indigo-800) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; right: 0;
  z-index: 200;
  border-left: 1px solid rgba(255,255,255,.06);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 26px 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.15);
}

.brand-icon svg {
  width: 22px; height: 22px;
  color: white;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 16.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 11.5px;
  color: rgba(255,255,255,.45);
  font-weight: 400;
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  padding: 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.55);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: right;
  direction: rtl;
}

.nav-btn:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.88);
}

.nav-btn.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.1);
}

.nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px; height: 18px;
}

/* Footer */
.sidebar-footer {
  padding: 18px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: rgba(255,255,255,.5);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,.25);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(16,185,129,.1); }
}


/* ═══════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════ */
.main-content {
  margin-right: var(--sidebar-w);
  flex: 1;
  padding: 36px 36px 60px;
  min-width: 0;
}

/* Pages */
.page { display: none; }
.page.active { display: block; animation: fadeUp .22s ease; }

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

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 30px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.6px;
  line-height: 1.2;
}

.page-header p {
  font-size: 13.5px;
  color: var(--gray-400);
  margin-top: 5px;
  font-weight: 400;
}

/* Outline button */
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.btn-outline svg {
  width: 15px; height: 15px;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.btn-outline:hover {
  border-color: var(--indigo-500);
  color: var(--indigo-600);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover svg { transform: rotate(-30deg); }
.btn-outline:active { transform: scale(.97); }

.btn-outline.loading svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════
   STATS ROW
═══════════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0; left: 0;
  height: 3px;
  background: var(--gray-200);
  border-radius: 0 0 var(--r) var(--r);
}

.stat-card.accent-green::after  { background: var(--green); }
.stat-card.accent-orange::after { background: var(--orange); }
.stat-card.accent-red::after    { background: var(--red); }

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-val {
  font-size: 36px;
  font-weight: 900;
  color: var(--gray-900);
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 12.5px;
  color: var(--gray-400);
  font-weight: 500;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.section-badge {
  background: var(--indigo-100);
  color: var(--indigo-600);
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
}


/* ═══════════════════════════════════════════════
   EVENT CARDS
═══════════════════════════════════════════════ */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all var(--transition);
}

.event-card:hover {
  border-color: var(--indigo-100);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Date block */
.ev-date {
  flex-shrink: 0;
  width: 58px;
  background: var(--indigo-50);
  border: 1.5px solid var(--indigo-100);
  border-radius: 12px;
  text-align: center;
  padding: 8px 4px 9px;
}

.ev-day {
  display: block;
  font-size: 26px;
  font-weight: 900;
  color: var(--indigo-600);
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.ev-month {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--indigo-500);
  letter-spacing: .5px;
  margin-top: 2px;
  text-transform: uppercase;
}

.ev-time {
  display: inline-block;
  font-size: 10.5px;
  color: var(--gray-400);
  background: var(--gray-100);
  border-radius: 5px;
  padding: 1px 5px;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* Info */
.ev-info { flex: 1; min-width: 0; }

.ev-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.ev-phone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--gray-400);
  background: var(--gray-100);
  border-radius: 6px;
  padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}

.ev-phone.missing {
  color: var(--red);
  background: var(--red-light);
}

/* Reminder badges */
.ev-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 72px;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  transition: all var(--transition);
}

.badge-icon { font-size: 17px; line-height: 1; }
.badge-lbl  { font-size: 10px; font-weight: 600; color: inherit; opacity: .85; }

.badge.sent {
  background: var(--green-light);
  color: var(--green-dark);
  border: 1.5px solid #a7f3d0;
}

.badge.pending {
  background: var(--orange-light);
  color: var(--orange-dark);
  border: 1.5px solid #fde68a;
}

.badge.idle {
  background: var(--gray-100);
  color: var(--gray-400);
  border: 1.5px solid var(--gray-200);
}

.badge.nophone {
  background: #fff;
  color: var(--gray-300);
  border: 1.5px dashed var(--gray-200);
}


/* ═══════════════════════════════════════════════
   LOADER & EMPTY STATE
═══════════════════════════════════════════════ */
.loader-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 72px 24px;
  color: var(--gray-400);
  font-size: 13.5px;
}

.loader {
  width: 34px; height: 34px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--indigo-500);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--gray-400);
}

.empty-icon { font-size: 52px; margin-bottom: 14px; line-height: 1; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; line-height: 1.6; }


/* ═══════════════════════════════════════════════
   TEMPLATES PAGE
═══════════════════════════════════════════════ */
.tpl-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.tpl-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 26px 28px;
  transition: box-shadow var(--transition);
}

.tpl-card:hover { box-shadow: var(--shadow-md); }

/* Card head */
.tpl-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.tpl-badge {
  width: 48px; height: 48px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.tpl-badge.indigo { background: var(--indigo-50); }
.tpl-badge.orange { background: var(--orange-light); }
.tpl-badge.yellow { background: #fef9c3; }

.tpl-card-head h3 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 3px;
}

.tpl-card-head p {
  font-size: 12.5px;
  color: var(--gray-400);
  line-height: 1.4;
}

/* Vars */
.tpl-vars {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 13px;
  font-size: 12px;
  color: var(--gray-400);
  flex-wrap: wrap;
}

.chip {
  background: var(--indigo-50);
  color: var(--indigo-600);
  border: 1px solid var(--indigo-100);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
}

/* Textarea */
.tpl-input {
  width: 100%;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  color: var(--gray-700);
  direction: rtl;
  line-height: 1.65;
  resize: vertical;
  transition: all var(--transition);
  outline: none;
}

.tpl-input:focus {
  border-color: var(--indigo-500);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--indigo-100);
}

/* Preview */
.tpl-preview {
  margin-top: 14px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: var(--r-sm);
}

.preview-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: #16a34a;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 7px;
}

.preview-bubble {
  font-size: 13.5px;
  color: var(--gray-700);
  white-space: pre-wrap;
  line-height: 1.65;
  min-height: 20px;
}

/* Save bar */
.save-bar {
  position: sticky;
  bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: 16px 22px;
  margin-top: 8px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--indigo-600);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 11px 22px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-colored);
}

.btn-primary svg {
  width: 16px; height: 16px; flex-shrink: 0;
}

.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
  transform: translateY(-1px);
}

.btn-primary:active { transform: scale(.97); }

.save-msg {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}


/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 100px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none;
  z-index: 9999;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }


/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { padding: 20px 16px 60px; }
  .ev-badges { flex-wrap: wrap; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}


/* ═══════════════════════════════════════════════
   DAY NAME ON EVENT CARD
═══════════════════════════════════════════════ */
.ev-dayname {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--indigo-500);
  letter-spacing: .4px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════
   TIME PICKER (Templates page)
═══════════════════════════════════════════════ */
.time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
  padding: 11px 14px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
}

.time-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}

.time-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.time-select {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  cursor: pointer;
  transition: border-color var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  min-width: 58px;
}

.time-select:focus {
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 3px var(--indigo-100);
}

.time-colon {
  font-size: 18px;
  font-weight: 800;
  color: var(--gray-400);
  line-height: 1;
}

/* ═══════════════════════════════════════════════
   SETTINGS PAGE
═══════════════════════════════════════════════ */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.settings-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 26px 28px;
  transition: box-shadow var(--transition);
}

.settings-card:hover { box-shadow: var(--shadow-md); }

.settings-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.settings-icon {
  width: 48px; height: 48px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.settings-icon svg { width: 22px; height: 22px; }

.green-icon  { background: var(--green-light);  color: var(--green-dark); }
.purple-icon { background: var(--indigo-50);    color: var(--indigo-600); }

.settings-card-head h3 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 3px;
}

.settings-card-head p {
  font-size: 12.5px;
  color: var(--gray-400);
}

/* API status badge */
.api-status-badge {
  margin-right: auto;
  margin-left: 0;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 100px;
  white-space: nowrap;
}

.api-status-badge.configured {
  background: var(--green-light);
  color: var(--green-dark);
}

.api-status-badge.not-configured {
  background: var(--gray-100);
  color: var(--gray-400);
}

/* Fields */
.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

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

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Webhook type badges */
.webhook-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 13px;
  flex-shrink: 0;
}
.indigo-badge  { background: rgba(99,102,241,.12); }
.orange-badge  { background: rgba(249,115,22,.12); }
.yellow-badge  { background: rgba(234,179,8,.12);  }

.field-input {
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray-800);
  direction: ltr;
  text-align: left;
  transition: all var(--transition);
  outline: none;
  padding-left: 70px; /* room for show button */
}

.field-input:focus {
  border-color: var(--indigo-500);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--indigo-100);
}

.field-input:not([type="password"]) { padding-left: 14px; }

.btn-show-pass {
  position: absolute;
  left: 10px;
  bottom: 9px;
  background: var(--gray-100);
  border: none;
  border-radius: 5px;
  padding: 3px 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-show-pass:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

/* Info note */
.settings-info {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  color: var(--gray-400);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  line-height: 1.5;
}

.settings-info svg { flex-shrink: 0; margin-top: 1px; }
