:root{
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;

  --sidebar: #0b1220;
  --sidebar-2: #0f1a30;
  --sidebarText: #e5e7eb;
  --sidebarMuted: rgba(229,231,235,.75);

  --primary: #0ea5e9;
  --primary-2: #22c55e;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);

  /* Sidebar widths */
  --sidebarW: 260px;
  --sidebarMiniW: 86px;
}

*{box-sizing:border-box}
html,body{height:100%}
html{ -webkit-text-size-adjust: 100%; }
body{
  margin:0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout base */
.app{
  display:flex;
  min-height:100vh;
}

/* Sidebar desktop */
.sidebar{
  width: var(--sidebarW);
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebarText);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  display:flex;
  flex-direction:column;
  gap: 14px;
  transition: width .22s ease;
}

.brand{
  display:flex; align-items:center; gap:10px;
  padding: 10px 10px;
  border-radius: 14px;
}
.brand .logo{
  width:34px;height:34px;border-radius:10px;
  background: rgba(14,165,233,.15);
  display:flex;align-items:center;justify-content:center;
  border: 1px solid rgba(14,165,233,.25);
  font-weight: 800;
}
.brand .title{font-weight:800; letter-spacing:.2px}
.brand .sub{font-size:12px;color:var(--sidebarMuted); margin-top:2px}

.nav{
  display:flex; flex-direction:column; gap:6px;
  margin-top:6px;
}
.nav a{
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebarText);
  text-decoration:none;
  opacity:.92;
}
.nav a:hover{ background: rgba(255,255,255,.06); }
.nav a.active{
  background: rgba(14,165,233,.16);
  border: 1px solid rgba(14,165,233,.22);
}
.nav .ico{
  width:20px; height:20px; display:inline-flex;
  align-items:center; justify-content:center;
  opacity:.95;
}
.sep{
  height:1px; background: rgba(255,255,255,.08);
  margin: 10px 8px;
}

.sidebarFooter{
  margin-top:auto;
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.sidebarFooter .name{font-weight:700}
.sidebarFooter .meta{font-size:12px;color:var(--sidebarMuted); margin-top:4px}

/* Conteúdo */
.main{
  flex:1;
  padding: 18px;
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbarLeft{display:flex; align-items:center; gap:10px;}
.pageTitle{font-size:18px; font-weight:800;}
.pageSub{font-size:12px; color: var(--muted); margin-top:2px}

.btnIcon{
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  cursor:pointer;
  box-shadow: 0 6px 18px rgba(15,23,42,.06);
  transition: transform .12s ease;
}
.btnIcon:hover{ transform: translateY(-1px); }

/* Cards / grid */
.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h3{margin:0 0 6px 0; font-size:14px; color: var(--muted); font-weight:700;}
.card .big{font-size:28px; font-weight:900; margin-top:6px;}
.card .muted{color: var(--muted); font-size:12px; margin-top:8px}

/* Drawer mobile */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.45);
  display:none;
  z-index: 60;
}
.drawer{
  position: fixed;
  top:0; left:0;
  height: 100vh;
  width: 84%;
  max-width: 320px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebarText);
  padding: 16px 12px;
  transform: translateX(-105%);
  transition: transform .22s ease;
  z-index: 70;
}
.drawer.open{ transform: translateX(0); }
.overlay.open{ display:block; }

/* Bottom nav mobile */
.bottomNav{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display:none;
  z-index: 50;
}
.bottomNav .wrap{
  height:100%;
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  align-items:center;
}
.bottomNav a{
  text-decoration:none;
  color: var(--muted);
  font-size: 11px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 4px;
  padding: 10px 0;
  font-weight: 600;
}
.bottomNav a.active{
  color: var(--primary);
  font-weight: 600;
}

/* Sidebar colapsável (desktop) */
.app.sidebar-collapsed .sidebar{ width: var(--sidebarMiniW); }
.app.sidebar-collapsed .sidebar .brand .title,
.app.sidebar-collapsed .sidebar .brand .sub,
.app.sidebar-collapsed .sidebar .nav a span:not(.ico),
.app.sidebar-collapsed .sidebar .sidebarFooter .name,
.app.sidebar-collapsed .sidebar .sidebarFooter .meta{ display:none; }

.app.sidebar-collapsed .sidebar .brand{ justify-content:center; }
.app.sidebar-collapsed .sidebar .brand .logo{ width:40px; height:40px; }
.app.sidebar-collapsed .sidebar .nav a{
  justify-content:center;
  padding: 12px 10px;
}
.app.sidebar-collapsed .sidebar .nav .ico{ width:22px; height:22px; }
.app.sidebar-collapsed .sidebar .nav a.active{ border-radius: 16px; }

/* Botões por breakpoint */
.btnIcon.desktopOnly{ display:inline-flex; }
@media (max-width: 980px){
  .btnIcon.desktopOnly{ display:none; }
}

/* Responsivo */
@media (max-width: 980px){
  .sidebar{ display:none; }
  .main{ padding-bottom: 86px; }
  .bottomNav{ display:block; }
  .topbar .btnIcon.mobileOnly{ display:inline-flex; }
}
@media (min-width: 981px){
  .topbar .btnIcon.mobileOnly{ display:none; }
}

/* Bottom nav PRETA no mobile */
@media (max-width: 980px){
  .bottomNav{
    background: rgba(10, 15, 25, .96);
    border-top: 1px solid rgba(255,255,255,.08);
  }
  .bottomNav a{
    color: rgba(229,231,235,.80);
  }
  .bottomNav a.active{
    color: #22d3ee;
  }
}

/* Mobile Header */
.mobileHeader{ display:none; }
@media (max-width: 980px){
  .main{ padding-top: 86px; }

  .mobileHeader{
    display:flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 72px;
    padding: 0 14px;
    z-index: 55;
    background: rgba(10, 15, 25, .98);
    border-bottom: 1px solid rgba(255,255,255,.08);
    backdrop-filter: blur(10px);
    align-items:center;
    justify-content:space-between;
  }

  .mobileHeader .brandMini{
    display:flex;
    align-items:center;
    gap:10px;
    color: rgba(229,231,235,.92);
    font-weight: 800;
    letter-spacing:.2px;
  }

  .mobileHeader .logoMini{
    width:38px;height:38px;border-radius:12px;
    background: rgba(34,211,238,.14);
    border: 1px solid rgba(34,211,238,.22);
    display:flex;align-items:center;justify-content:center;
    font-weight: 900;
  }

  .mobileHeader .btnIcon{
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.12);
    color: #fff;
    box-shadow: none;
  }

  .topbar .btnIcon.mobileOnly{ display:none !important; }
}

/* Tirar negrito de botões gerais */
.btn{ font-weight: 600 !important; }
.aBtn{ font-weight: 600 !important; }

/* Scrollbar (Chrome/Edge/Safari) */
::-webkit-scrollbar{ width: 10px; height: 10px; }
::-webkit-scrollbar-track{
  background: rgba(15, 23, 42, .08);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb{
  background: rgba(14, 165, 233, .75);
  border-radius: 999px;
  border: 2px solid rgba(245, 247, 251, .9);
}
::-webkit-scrollbar-thumb:hover{ background: rgba(14, 165, 233, .95); }

/* Scrollbar (Firefox) */
*{
  scrollbar-width: thin;
  scrollbar-color: rgba(14, 165, 233, .75) rgba(15, 23, 42, .08);
}

/* Chats list */
.chatList{ display:flex; flex-direction:column; }
.chatItem{
  display:flex;
  gap: 12px;
  padding: 14px 16px;
  text-decoration:none;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.chatItem:hover{ background: rgba(2,132,199,.04); }

.avatar{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  font-weight: 900;
  color: #0284c7;
  background: rgba(14,165,233,.12);
  border: 1px solid rgba(14,165,233,.22);
  flex: 0 0 auto;
}

.chatInfo{ flex:1; min-width: 0; }
.chatTop{
  display:flex;
  justify-content:space-between;
  gap: 10px;
  align-items:center;
}
.chatName{ font-weight: 800; }
.chatTime{ font-size: 12px; color: var(--muted); white-space: nowrap; }
.chatPreview{
  margin-top: 4px;
  font-size: 13px;
  color: rgba(15,23,42,.72);
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chatArrow{
  display:flex;
  align-items:center;
  color: rgba(100,116,139,.9);
}

/* =========================
   CHAT (estilo WhatsApp)
   ========================= */

.chatWrap{
  max-width: 980px;
  margin: 0 auto;
}

.chatCard{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;

  height: clamp(520px, calc(100dvh - 260px), 720px);
  display: flex;
  flex-direction: column;
}

@media (max-width: 980px){
  .chatWrap{ max-width: 100%; }
  .chatCard{
    height: calc(100dvh - 220px);
    border-radius: 18px;
  }
}

.chatHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fafcff);
}

.chatHeaderLeft{
  display:flex; align-items:center; gap:12px;
  min-width: 0;
}

.chatAvatar{
  width: 42px; height: 42px;
  border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(14,165,233,.12);
  border: 1px solid rgba(14,165,233,.18);
  color: var(--text);
  font-weight: 700;
  flex: 0 0 auto;
}

.chatHeaderMeta{min-width:0}

.chatName{
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatStatus{
  font-size: 12px;
  color: var(--muted);
  display:flex; align-items:center; gap:8px;
}

.dot{
  width: 8px; height: 8px; border-radius: 999px;
  background: #94a3b8;
}
.dot.on{ background: #22c55e; }

.chatHeaderRight{
  display:flex; align-items:center; gap:12px;
}

.readToggle{
  display:flex; align-items:center; gap:10px;
  font-size: 12px;
  color: var(--muted);
  user-select:none;
}
.readToggle input{ transform: translateY(1px); }

.chatBody{
  flex: 1;
  overflow: auto;
  padding: 16px 14px;
  background:
    radial-gradient(1000px 500px at 20% 0%, rgba(14,165,233,.10), transparent 45%),
    radial-gradient(900px 500px at 80% 0%, rgba(34,197,94,.08), transparent 55%),
    #f7fbff;
}

.msgRow{
  display:flex;
  margin: 6px 0;
}
.msgRow.me{ justify-content:flex-end; }
.msgRow.them{ justify-content:flex-start; }

.bubble{
  max-width: min(78%, 520px);
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.25);
  background: #fff;
  color: var(--text);
  position: relative;
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
}

.bubble.me{
  background: rgba(14,165,233,.10);
  border-color: rgba(14,165,233,.22);
}

.msgText{
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.msgMeta{
  margin-top: 6px;
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap: 6px;
  color: rgba(100,116,139,.95);
  font-size: 11px;
}

.ticks{
  display:inline-flex;
  gap: 2px;
  line-height: 1;
}
.ticks i{
  font-size: 12px;
  opacity: .95;
}
.ticks.gray i{ color: #94a3b8; }
.ticks.blue i{ color: #0ea5e9; }

.chatComposer{
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  display:flex;
  align-items:flex-end;
  gap: 10px;
}

.chatInput{
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
  background: #fff;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  overflow: auto;
}

.chatInput:focus{
  border-color: rgba(14,165,233,.55);
  box-shadow: 0 0 0 4px rgba(14,165,233,.12);
}

.chatSend{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(14,165,233,.22);
}
.chatSend:hover{ filter: brightness(1.03); }
.chatSend i{ font-size: 14px; }
