/* GroupCast : design inspire WhatsApp, sombre + vert */

:root {
  --bg: #0b141a;
  --bg-panel: #111b21;
  --bg-card: #1a262e;
  --bg-card-hover: #20303a;
  --border: #2a3942;
  --text: #e9edef;
  --text-muted: #8696a0;
  --green: #00a884;
  --green-dark: #008f72;
  --green-soft: rgba(0, 168, 132, 0.14);
  --amber: #f5b941;
  --red: #f15c6d;
  --blue: #53bdeb;
  --bubble: #005c4b;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(0, 168, 132, 0.12), transparent),
    var(--bg);
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: min(380px, 90vw);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .logo { justify-content: center; margin-bottom: 8px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 26px; }
.login-card input {
  width: 100%;
  margin-bottom: 14px;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.logo-mark {
  background: linear-gradient(135deg, var(--green), #02735e);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0.5px;
}
.logo-text { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }

nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.nav-muted { font-size: 13px; }

.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.mode-badge {
  background: rgba(245, 185, 65, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 185, 65, 0.4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  padding: 7px;
  border-radius: 8px;
}

.main {
  flex: 1;
  padding: 34px 40px 80px;
  max-width: 1060px;
}

/* ---------- Vues ---------- */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.view-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.section-title { font-size: 16px; font-weight: 600; margin: 26px 0 14px; }

/* ---------- Composants ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  padding: 11px 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green); color: #06241d; }
.btn-primary:hover { background: #06bf98; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger-ghost { background: transparent; color: var(--red); border: 1px solid transparent; }
.btn-danger-ghost:hover { border-color: var(--red); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 7px; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; align-items: center; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 11px 13px;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--green); }
.group-search { margin-bottom: 8px; }
textarea { resize: vertical; line-height: 1.5; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 18px 0 7px;
}
.field-label:first-child { margin-top: 0; }
.sel-count {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--accent, #25d366);
}

.form-error { color: var(--red); font-size: 13px; margin-top: 12px; }
.form-feedback { font-size: 13px; margin-top: 14px; }
.form-feedback.ok { color: var(--green); }
.form-feedback.err { color: var(--red); }
.hint { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.hint code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------- Cartes ---------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card:hover { background: var(--bg-card-hover); }
.seq-setup.card:hover { background: var(--bg-card); }

.msg-card { display: flex; flex-direction: column; gap: 10px; }
.msg-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg-when { font-weight: 600; font-size: 14px; }
.msg-groups { color: var(--text-muted); font-size: 13px; }
.msg-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 130px;
  overflow: auto;
}
.msg-actions { display: flex; gap: 8px; }
.msg-error { color: var(--red); font-size: 13px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 4px 9px;
  border-radius: 99px;
  text-transform: uppercase;
}
.badge.scheduled { background: rgba(83, 189, 235, 0.14); color: var(--blue); }
.badge.sending { background: rgba(245, 185, 65, 0.14); color: var(--amber); }
.badge.sent { background: var(--green-soft); color: var(--green); }
.badge.partial { background: rgba(245, 185, 65, 0.14); color: var(--amber); }
.badge.failed { background: rgba(241, 92, 109, 0.14); color: var(--red); }
.badge.canceled { background: rgba(134, 150, 160, 0.14); color: var(--text-muted); }
.badge.seq { background: rgba(83, 189, 235, 0.1); color: var(--blue); text-transform: none; letter-spacing: 0; }

.stat-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 120px;
}
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lab { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.filter-row { display: flex; gap: 8px; margin-bottom: 18px; }
.chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 7px 15px;
  cursor: pointer;
}
.chip.active { background: var(--green-soft); color: var(--green); border-color: var(--green); }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 50px 20px;
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Composer ---------- */
.compose-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 34px;
  align-items: start;
}
@media (max-width: 980px) { .compose-grid { grid-template-columns: 1fr; } }

.group-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
}
.group-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.group-check:hover { background: var(--bg-card-hover); }
.group-check input { width: auto; accent-color: var(--green); }
.group-check .count { color: var(--text-muted); font-size: 12px; margin-left: auto; }

/* Telephone / apercu WhatsApp */
.compose-preview { position: sticky; top: 30px; }
.wa-phone {
  background: #0b141a;
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.wa-header {
  background: #202c33;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.wa-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #0e7490);
}
.wa-group-name { font-size: 14px; font-weight: 600; }
.wa-group-sub { font-size: 12px; color: var(--text-muted); }
.wa-chat {
  min-height: 280px;
  padding: 20px 14px;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 18px 18px;
}
.wa-bubble {
  background: var(--bubble);
  border-radius: 10px;
  border-top-left-radius: 2px;
  padding: 8px 10px 6px;
  max-width: 92%;
  width: fit-content;
}
.wa-image { width: 100%; border-radius: 7px; margin-bottom: 6px; display: block; }
.wa-text { font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.wa-meta { text-align: right; font-size: 11px; color: rgba(233, 237, 239, 0.6); margin-top: 3px; }

/* ---------- Sequence ---------- */
.seq-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
  margin-bottom: 6px;
}
@media (max-width: 800px) { .seq-form-grid { grid-template-columns: 1fr; } }

.draft-card .draft-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.draft-card .draft-label { font-weight: 600; font-size: 14px; flex: 1; }
.draft-card input[type="datetime-local"] { width: auto; }
.draft-card textarea { font-size: 13.5px; }
.draft-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.draft-toggle input { width: auto; accent-color: var(--green); }
.draft-card.excluded { opacity: 0.45; }

/* ---------- Groupes ---------- */
.group-card { display: flex; align-items: center; gap: 14px; }
.group-card .g-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #0e7490);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #06241d;
}
.group-card .g-name { font-weight: 600; font-size: 15px; }
.group-card .g-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.group-card .g-actions { margin-left: auto; }
.group-card.group-disabled { opacity: 0.55; }
.create-group-card { margin-bottom: 18px; }
.create-group-card:hover { background: var(--bg-card); }
.invite-panel { margin-top: 16px; }
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-row input { flex: 1; color: var(--green); font-weight: 600; }
.tz-hint { margin: 6px 0 0; font-size: 12px; }
.tz-hint .tz-warn { color: var(--amber); }

/* Recurrence */
.repeat-row { display: flex; gap: 10px; align-items: center; }
.repeat-row select { width: auto; }
.repeat-row input[type="date"] { width: auto; }

/* Panneaux de groupe (bienvenue, membres) */
.group-card-wrap { display: flex; flex-direction: column; gap: 12px; }
.group-card-wrap .group-card { display: flex; align-items: center; gap: 14px; }
.g-welcome-on { color: var(--green); }
.g-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.members-head { display: flex; align-items: center; justify-content: space-between; }
.members-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.member-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 6px 10px;
  background: rgba(0,0,0,0.18); border-radius: 6px;
}

/* Badge clics */
.badge.clicks { background: rgba(0, 168, 132, 0.12); color: var(--green); text-transform: none; letter-spacing: 0; }

/* Media row du composer */
.media-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.media-row input[type="file"] { width: auto; padding: 8px; font-size: 13px; }

/* Badge non-lus dans la nav */
.nav-badge {
  background: var(--green); color: #06241d;
  font-size: 11px; font-weight: 700;
  border-radius: 99px; padding: 1px 7px; margin-left: 6px;
}

/* Boite de reception */
.inbox-grid {
  display: grid; grid-template-columns: 300px 1fr; gap: 16px;
  align-items: start; min-height: 420px;
}
@media (max-width: 860px) { .inbox-grid { grid-template-columns: 1fr; } }
.inbox-chats { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow: auto; }
.chat-item {
  font-family: inherit; text-align: left; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text);
}
.chat-item:hover { background: var(--bg-card-hover); }
.chat-item.active { border-color: var(--green); }
.chat-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.chat-last { color: var(--text-muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot { background: var(--green); color: #06241d; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 6px; }
.inbox-thread {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 420px;
}
.thread-title { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.thread-msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; }
.thread-bubble {
  background: #202c33; border-radius: 10px; border-top-left-radius: 2px;
  padding: 8px 11px; max-width: 78%; width: fit-content; font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word;
}
.thread-bubble.mine { background: var(--bubble); align-self: flex-end; border-radius: 10px; border-top-right-radius: 2px; }
.thread-from { font-size: 11px; color: var(--blue); font-weight: 600; margin-bottom: 2px; }
.thread-time { font-size: 10px; color: rgba(233,237,239,0.5); text-align: right; margin-top: 3px; }
.thread-reply { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.sio-report { border-top: 1px solid var(--border); padding-top: 12px; }
.g-warn { color: var(--amber); font-size: 13px; }
.group-check-off { opacity: 0.5; cursor: not-allowed; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Modeles ---------- */
.tpl-card .tpl-head { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tpl-card .tpl-head input[type="text"] { flex: 1; min-width: 200px; }
.tpl-offset { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.tpl-offset input { width: 80px; }

/* ---------- Reglages ---------- */
.setting-card { display: flex; align-items: center; gap: 14px; }
.setting-card .s-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.s-dot.ok { background: var(--green); }
.s-dot.warn { background: var(--amber); }
.s-dot.bad { background: var(--red); }
.setting-card .s-title { font-weight: 600; font-size: 14px; }
.setting-card .s-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    gap: 10px;
    padding: 12px;
  }
  .sidebar .logo-text { display: none; }
  nav { flex-direction: row; }
  .nav-item { white-space: nowrap; padding: 9px 12px; }
  .sidebar-footer { flex-direction: row; }
  .main { padding: 22px 16px 60px; }
}
