/* ══ سامانه پیامکی ═══════════════════════════════════════════════════════
   صفحه‌ی «مدیریت پیامک‌ها»: ستون رویدادها (چپ) + میزکار رویداد (راست) و
   دفتر ارسال تمام‌عرض زیر آن‌ها. رفتار در public/sms.js.
   ═══════════════════════════════════════════════════════════════════════ */

/* برچسب وضعیت — همه‌جای این صفحه یک شکل است */
.sms-pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.sms-pill.ok { background: #dcfce7; color: #15803d; }
.sms-pill.wt { background: #fef3c7; color: #b45309; }
.sms-pill.bad { background: #fee2e2; color: #b91c1c; }
.sms-pill.mu { background: var(--surface-2); color: var(--muted); }

/* شمارنده‌های سربرگ */
.sms-tot {
  display: flex; align-items: baseline; gap: 6px; padding: 4px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.sms-tot b { font-size: 16px; font-weight: 800; }
.sms-tot u { text-decoration: none; color: var(--muted); font-size: 12px; }
.sms-tot.wt b { color: var(--warning); }
.sms-tot.bad b { color: var(--danger); }

.sms-note {
  border: 1px solid var(--border); border-right: 3px solid var(--warning);
  background: var(--surface); border-radius: 10px; padding: 9px 13px;
  margin-bottom: 12px; font-size: 13px; color: var(--muted);
}
.sms-note b { color: var(--text); }
.sms-warn {
  background: #fee2e2; color: #b91c1c; border-radius: 8px;
  padding: 7px 11px; font-size: 13px; margin-bottom: 10px;
}

/* ── چیدمان: میزکار + ستون رویدادها ─────────────────────────────────── */
.sms-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .sms-wrap { grid-template-columns: 1fr; } }

.sms-side {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.sms-side h4 { margin: 0 0 7px; font-size: 12px; color: var(--muted); font-weight: 700; }
.sms-ev {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: right;
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 7px 9px; cursor: pointer; font-family: inherit; font-size: 13px;
  color: var(--muted); margin-bottom: 2px;
}
.sms-ev span { flex: 1; }
.sms-ev:hover { background: var(--surface-2); }
.sms-ev.on { color: var(--text); font-weight: 600; }
.sms-ev.sel { background: var(--surface-2); border-color: var(--border); color: var(--text); }
/* کلید کوچکِ ستون — فقط نشانه است، خاموش/روشن از میزکار انجام می‌شود */
.sms-sw { width: 24px; height: 13px; border-radius: 999px; background: #d7dbe3; position: relative; flex: none; }
.sms-sw::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.sms-sw.on { background: var(--success); }
.sms-sw.on::after { transform: translateX(-11px); }

.sms-lnk {
  display: block; padding: 6px 9px; border-radius: 8px;
  font-size: 13px; color: var(--muted);
}
.sms-lnk:hover { background: var(--surface-2); color: var(--text); }

/* ── میزکار رویداد ──────────────────────────────────────────────────── */
.sms-main {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0;
}
.sms-evhead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sms-evhead > div { flex: 1; min-width: 0; }
.sms-evhead h3 { margin: 0 0 2px; font-size: 16px; }
.sms-evhead p { margin: 0; font-size: 12.5px; color: var(--muted); }

.sms-toggle {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 5px 13px 5px 7px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
}
.sms-toggle i { width: 30px; height: 16px; border-radius: 999px; background: #d7dbe3; position: relative; }
.sms-toggle i::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.sms-toggle.on { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.sms-toggle.on i { background: var(--success); }
.sms-toggle.on i::after { transform: translateX(-14px); }
.sms-toggle:disabled { opacity: .55; cursor: not-allowed; }

.sms-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 820px) { .sms-grid2 { grid-template-columns: 1fr; } }

.sms-pane { border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; background: var(--surface-2); }
.sms-pane h5 { margin: 0 0 7px; font-size: 12px; color: var(--muted); font-weight: 700; }

/* متن پیامک — چپ‌چین نمی‌شود، ولی خط‌ها همان‌طور که تایپ شده می‌مانند */
.sms-ta {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  padding: 9px 11px; font-family: inherit; font-size: 13.5px; line-height: 2;
  color: var(--text); resize: vertical; white-space: pre-wrap;
}
.sms-ta:focus { outline: none; border-color: var(--primary); }
.sms-ta:disabled { background: var(--surface-2); color: var(--muted); }

.sms-vars { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.sms-var {
  border: 1px dashed #c9cfdb; background: var(--surface); color: var(--muted);
  border-radius: 6px; padding: 2px 8px; font-family: inherit; font-size: 11.5px;
  cursor: pointer; white-space: nowrap;
}
.sms-var:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); border-style: solid; }
.sms-var:disabled { cursor: default; opacity: .6; }

/* پیش‌نمایش: حبابِ گوشی */
.sms-prev { background: #e9edf3; border-radius: 10px; padding: 12px; min-height: 132px; }
.sms-bub {
  background: var(--surface); border-radius: 12px 12px 12px 3px; padding: 9px 12px;
  font-size: 13px; line-height: 2; box-shadow: var(--shadow); max-width: 100%;
  overflow-wrap: anywhere;
}
.sms-meter { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 7px; font-size: 12px; color: var(--muted); }
.sms-meter .bad { color: var(--danger); font-weight: 600; }

/* گیرنده و شرط ارسال */
.sms-cond { margin-top: 12px; }
.sms-cgrid { display: grid; grid-template-columns: 190px minmax(0, 1fr) minmax(0, 1fr) 210px; gap: 10px; }
@media (max-width: 900px) { .sms-cgrid { grid-template-columns: 1fr 1fr; } }
.sms-cgrid > label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sms-cgrid u { text-decoration: none; font-size: 12px; color: var(--muted); font-weight: 700; }
.sms-cgrid select, .sms-cgrid input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  padding: 7px 9px; font-family: inherit; font-size: 13px; color: var(--text);
}
.sms-cgrid select:disabled, .sms-cgrid input:disabled { background: var(--surface-2); color: var(--muted); }
.sms-hint { font-size: 12px; color: var(--muted); padding-top: 7px; }
.sms-win { display: flex; align-items: center; gap: 5px; }
.sms-win span { font-size: 12px; color: var(--muted); flex: none; }
.sms-win .sms-hh { text-align: center; }

.sms-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.sms-foot .spacer { flex: 1; }
.sms-recip { font-size: 12.5px; color: var(--muted); }

/* ── دفتر ارسال ─────────────────────────────────────────────────────── */
.sms-log {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); margin-top: 14px;
}
.sms-logh { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sms-logh h4 { margin: 0; font-size: 14px; }
.sms-logh .spacer { flex: 1; }
.sms-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

.sms-tbl { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.sms-tbl th {
  text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 700;
  padding: 0 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.sms-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sms-tbl tr:last-child td { border-bottom: none; }
.sms-tbl td.mu { color: var(--muted); white-space: nowrap; }
.sms-tbl td.ltr { direction: ltr; text-align: right; white-space: nowrap; }
.sms-tbl th:nth-child(1), .sms-tbl td:nth-child(1) { width: 120px; }
.sms-tbl th:nth-child(2), .sms-tbl td:nth-child(2) { width: 170px; }
.sms-tbl th:nth-child(3), .sms-tbl td:nth-child(3) { width: 130px; }
.sms-tbl th:nth-child(4), .sms-tbl td:nth-child(4) { width: 105px; }
.sms-tbl th:nth-child(5), .sms-tbl td:nth-child(5) { width: 82px; }
.sms-tbl th:last-child, .sms-tbl td:last-child { width: 96px; }
.sms-body { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── مودالِ حساب و ارسال آزمایشی ────────────────────────────────────── */
.sms-set { display: flex; flex-direction: column; gap: 12px; }
.sms-set > label { display: flex; flex-direction: column; gap: 4px; }
.sms-set u { text-decoration: none; font-size: 12px; color: var(--muted); font-weight: 700; }
.sms-set i { font-style: normal; font-size: 11.5px; color: var(--muted); }
.sms-set input[type="text"], .sms-set input[type="tel"], .sms-set textarea {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  padding: 8px 10px; font-family: inherit; font-size: 13px; color: var(--text); width: 100%;
}
.sms-set textarea { resize: vertical; line-height: 2; }
.sms-chk { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 13px; }
.sms-chk input { width: 16px; height: 16px; flex: none; }
.sms-creditrow { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.sms-credit { flex: 1; font-size: 13px; color: var(--muted); }

/* ── اپ‌های موبایل: لینک، فهرست گیرنده‌ها ───────────────────────────── */
.al-link {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
}
.al-link code {
  flex: 1; min-width: 0; direction: ltr; text-align: left; font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, Consolas, monospace;
}
.al-n { text-decoration: none; font-size: 11.5px; color: var(--muted); }
.al-lh { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.al-lh h5 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }
.al-lh .spacer { flex: 1; }

.al-people {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  max-height: 292px; overflow-y: auto;
}
.al-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px;
}
.al-row:last-child { border-bottom: none; }
.al-row:hover { background: var(--surface-2); }
.al-row.off { cursor: default; opacity: .72; }
.al-row.off:hover { background: transparent; }
.al-row input { width: 16px; height: 16px; flex: none; }
.al-who { flex: 1; min-width: 0; }
.al-who b { display: block; font-weight: 600; }
.al-who u { text-decoration: none; display: block; font-size: 11.5px; color: var(--muted); }
.al-ph { direction: ltr; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.al-num {
  width: 100%; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); padding: 8px 10px; font-family: inherit; font-size: 13px; color: var(--text);
}
.al-num:focus { outline: none; border-color: var(--primary); }
