/* =====================================================================
   Fabulous Chat — theme
   White background, WhatsApp-green primary.
   ===================================================================== */
:root{
  --wa-green:      #25D366;
  --wa-green-600:  #1EBE5D;
  --wa-green-700:  #128C7E;
  --wa-teal:       #075E54;
  --wa-bubble:     #DCF8C6;
  --wa-chat-bg:    #EFEAE2;
  --ink:           #111b21;
  --muted:         #667781;
  --line:          #e9edef;
  --bg:            #ffffff;
  --sidebar-w:     248px;
}

*{ scrollbar-width: thin; }
html,body{ height:100%; }
body{
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size: 14.5px;
}

/* ---- Bootstrap primary override -------------------------------------- */
.btn-primary{
  --bs-btn-bg: var(--wa-green);
  --bs-btn-border-color: var(--wa-green);
  --bs-btn-hover-bg: var(--wa-green-600);
  --bs-btn-hover-border-color: var(--wa-green-600);
  --bs-btn-active-bg: var(--wa-green-700);
  --bs-btn-active-border-color: var(--wa-green-700);
  --bs-btn-disabled-bg: var(--wa-green);
  --bs-btn-disabled-border-color: var(--wa-green);
  font-weight:600;
}
.btn-outline-primary{
  --bs-btn-color: var(--wa-green-700);
  --bs-btn-border-color: var(--wa-green);
  --bs-btn-hover-bg: var(--wa-green);
  --bs-btn-hover-border-color: var(--wa-green);
  --bs-btn-active-bg: var(--wa-green-600);
}
a{ color: var(--wa-green-700); }
a:hover{ color: var(--wa-teal); }
.text-primary{ color: var(--wa-green-700) !important; }
.bg-primary{ background: var(--wa-green) !important; }
.form-control:focus,.form-select:focus{
  border-color: var(--wa-green);
  box-shadow: 0 0 0 .2rem rgba(37,211,102,.18);
}
.form-check-input:checked{
  background-color: var(--wa-green);
  border-color: var(--wa-green);
}
.card{ border-color: var(--line); border-radius: 14px; }
.badge.bg-success{ background: var(--wa-green) !important; }

/* ---- Brand badge ----------------------------------------------------- */
.brand-badge{
  width:44px;height:44px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  background: var(--wa-green); color:#fff; font-size:22px;
  box-shadow: 0 6px 16px rgba(37,211,102,.35);
}

/* ---- Auth pages ------------------------------------------------------ */
.auth-bg{
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(37,211,102,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(18,140,126,.10), transparent 55%),
    #ffffff;
  min-height:100vh;
}

/* ---- App shell ------------------------------------------------------- */
.app{ display:flex; min-height:100vh; }
.sidebar{
  width: var(--sidebar-w); flex:0 0 var(--sidebar-w);
  background:#fff; border-right:1px solid var(--line);
  position:sticky; top:0; height:100vh; display:flex; flex-direction:column;
}
.sidebar .brand{
  padding:18px 18px 14px; display:flex; align-items:center; gap:10px;
  border-bottom:1px solid var(--line);
}
.sidebar .brand .name{ font-weight:800; letter-spacing:-.2px; }
.sidebar nav{ padding:12px 10px; flex:1; overflow:auto; }
.nav-link-fc{
  display:flex; align-items:center; gap:12px;
  padding:10px 12px; border-radius:10px; color:#3b4a54;
  text-decoration:none; font-weight:600; margin-bottom:2px;
}
.nav-link-fc i{ font-size:18px; width:20px; text-align:center; }
.nav-link-fc:hover{ background:#f2f5f6; color:var(--ink); }
.nav-link-fc.active{ background: rgba(37,211,102,.12); color: var(--wa-green-700); }
.sidebar .foot{ padding:12px; border-top:1px solid var(--line); }
.user-chip{ display:flex; align-items:center; gap:10px; }
.avatar{
  width:36px;height:36px;border-radius:50%;flex:0 0 36px;
  background: var(--wa-green-700); color:#fff; font-weight:700;
  display:flex;align-items:center;justify-content:center; font-size:13px;
}
.avatar.sm{ width:30px;height:30px;flex-basis:30px;font-size:11px; }

.main{ flex:1; min-width:0; display:flex; flex-direction:column; }
.topbar{
  height:60px; background:#fff; border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:14px; padding:0 22px; position:sticky; top:0; z-index:5;
}
.topbar h1{ font-size:18px; font-weight:800; margin:0; }
.content{ padding:22px; flex:1; }

/* ---- Stat cards ------------------------------------------------------ */
.stat{ background:#fff;border:1px solid var(--line);border-radius:14px;padding:18px; }
.stat .k{ color:var(--muted); font-size:12.5px; font-weight:600; text-transform:uppercase; letter-spacing:.4px; }
.stat .v{ font-size:28px; font-weight:800; margin-top:6px; }
.stat .ic{
  width:42px;height:42px;border-radius:11px;display:flex;align-items:center;justify-content:center;
  background:rgba(37,211,102,.12); color:var(--wa-green-700); font-size:20px;
}

/* ---- Conversation split view ---------------------------------------- */
.convo-wrap{ display:flex; height:calc(100vh - 60px); overflow:hidden; }
.convo-list{
  width:360px; flex:0 0 360px; border-right:1px solid var(--line);
  overflow:auto; background:#fff;
}
.convo-list .search{ padding:12px; border-bottom:1px solid var(--line); position:sticky; top:0; background:#fff; z-index:2; }
.convo-item{
  display:flex; gap:12px; padding:12px 14px; border-bottom:1px solid var(--line);
  cursor:pointer; text-decoration:none; color:inherit;
}
.convo-item:hover{ background:#f6f8f9; color:inherit; }
.convo-item.active{ background: rgba(37,211,102,.10); }
.convo-item .meta{ min-width:0; flex:1; }
.convo-item .name{ font-weight:700; display:flex; justify-content:space-between; gap:8px; }
.convo-item .name .t{ font-weight:500; color:var(--muted); font-size:12px; white-space:nowrap; }
.convo-item .snippet{ color:var(--muted); font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.chat-pane{ flex:1; display:flex; flex-direction:column; min-width:0; min-height:0; overflow:hidden; }
/* the messages/summary row fills the remaining height and never overflows.
   nowrap is essential: with the default wrap, the row grows to the message
   content height, so nothing scrolls — nowrap keeps the fixed height. */
.chat-pane > .row{ flex-wrap:nowrap; min-height:0; overflow:hidden; }
.chat-pane .col-lg-8{ min-height:0; display:flex; flex-direction:column; }
.chat-pane .col-lg-4{ min-height:0; overflow-y:auto; }
.chat-head{
  height:60px; flex:0 0 60px; border-bottom:1px solid var(--line); display:flex; align-items:center;
  gap:12px; padding:0 18px; background:#fff;
}
.chat-body{
  flex:1; min-height:0; overflow-y:auto; padding:22px;
  background:
    linear-gradient(rgba(239,234,226,.94),rgba(239,234,226,.94)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23d8cfc4'/%3E%3C/svg%3E");
}
.msg-row{ display:flex; margin-bottom:10px; }
.msg-row.out{ justify-content:flex-end; }
.bubble{
  max-width:66%; padding:8px 12px 20px; border-radius:10px; position:relative;
  box-shadow:0 1px .5px rgba(11,20,26,.13); font-size:14px; line-height:1.4; word-wrap:break-word;
}
.msg-row.in  .bubble{ background:#fff; border-top-left-radius:2px; }
.msg-row.out .bubble{ background:var(--wa-bubble); border-top-right-radius:2px; }
.bubble .time{ position:absolute; right:10px; bottom:5px; font-size:10.5px; color:var(--muted); }
.chat-empty{ flex:1; display:flex; align-items:center; justify-content:center; flex-direction:column; color:var(--muted); background:var(--wa-chat-bg); }

/* Composer pinned at the bottom of the chat column */
.chat-composer{ flex:0 0 auto; }
.chat-composer textarea{ max-height:120px; }

/* Full-height app views (chat / conversation list): lock to viewport so
   only the message area scrolls and the composer stays on screen. */
body.view-locked{ overflow:hidden; }
body.view-locked .app{ height:100vh; min-height:0; overflow:hidden; }
body.view-locked .main{ height:100vh; min-height:0; overflow:hidden; }

/* ---- Summary panel --------------------------------------------------- */
.summary-box{ background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px; }
.summary-box .lbl{ font-size:12px;text-transform:uppercase;letter-spacing:.4px;color:var(--muted);font-weight:700; }

/* ---- Misc ------------------------------------------------------------ */
.help-code{ background:#0b141a; color:#a7f3c9; border-radius:10px; padding:14px 16px; font-size:12.5px; overflow:auto; }
.table thead th{ color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.4px; }
.empty-state{ text-align:center; color:var(--muted); padding:60px 20px; }
.empty-state i{ font-size:40px; opacity:.5; }

@media (max-width: 992px){
  .sidebar{ position:fixed; z-index:1050; transform:translateX(-100%); transition:.2s; box-shadow:0 0 40px rgba(0,0,0,.2); }
  .sidebar.open{ transform:none; }
  .convo-list{ width:100%; flex-basis:100%; }
  .convo-wrap.has-active .convo-list{ display:none; }
  .convo-wrap:not(.has-active) .chat-pane{ display:none; }
  /* Chat view: give the chat + composer the full height; summary is desktop-only here */
  .chat-pane .row{ flex-wrap:nowrap; }
  .chat-pane .col-lg-8{ flex:1 1 100%; max-width:100%; }
  .chat-pane .col-lg-4{ display:none; }
}
