/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; margin: 0; }
h1, h2, h3 { margin: 0; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid;
  grid-template-columns: 240px 1fr auto;
  align-items: center;
  height: 60px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px;
  background: #1e40af; color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
.brand-name { font-weight: 600; color: #111827; }

.topbar-nav { display: flex; align-items: center; }
.topbar-search {
  width: 100%; max-width: 480px;
  padding: 9px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.topbar-search:focus { border-color: #1e40af; background: #fff; }

.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: #4b5563; font-size: 13px; }
.user-avatar {
  width: 34px; height: 34px;
  background: #1e40af; color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  border-radius: 50%;
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 60px);
}

/* ===== Sidebar ===== */
.sidebar {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
  padding: 20px 12px;
}
.side-nav li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: #4b5563;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.side-nav li:hover { background: #f3f4f6; color: #111827; }
.side-nav li.active { background: #eff6ff; color: #1e40af; font-weight: 600; }
.side-nav .ico { color: #9ca3af; font-size: 10px; }
.side-nav li.active .ico { color: #1e40af; }
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  font-size: 11px; color: #9ca3af;
}

/* ===== Main ===== */
.main { padding: 32px 40px; max-width: 1200px; }

.welcome { margin-bottom: 24px; }
.welcome h1 {
  font-size: 24px; font-weight: 600;
  color: #111827;
}
.welcome .subtitle { color: #6b7280; margin-top: 4px; }

/* ===== Cards de KPI ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 20px;
}
.card-label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.4px; }
.card-value { font-size: 28px; font-weight: 700; color: #111827; margin: 4px 0; }
.card-foot { font-size: 12px; color: #6b7280; }

/* ===== Painéis ===== */
.row-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .row-2 { grid-template-columns: 1fr; }
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.panel h2 { font-size: 14px; font-weight: 600; color: #111827; }
.link { color: #1e40af; font-size: 12px; font-weight: 500; }
.link:hover { text-decoration: underline; }

.news-list li { padding: 12px 0; border-top: 1px solid #f3f4f6; }
.news-list li:first-child { border-top: 0; padding-top: 0; }
.news-list strong { color: #111827; font-size: 13px; }
.news-meta { display: block; font-size: 11px; color: #9ca3af; margin: 2px 0 6px; }
.news-list p { margin: 0; color: #4b5563; font-size: 13px; }

.agenda li {
  display: flex; gap: 14px;
  padding: 9px 0;
  border-top: 1px solid #f3f4f6;
  font-size: 13px;
}
.agenda li:first-child { border-top: 0; padding-top: 0; }
.agenda .time { font-weight: 600; color: #1e40af; min-width: 48px; }
.agenda .title { color: #374151; }

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.shortcut {
  display: block;
  padding: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.shortcut:hover { border-color: #1e40af; background: #eff6ff; color: #1e40af; }

/* =====================================================
   Chat widget
   ===================================================== */
.chat-fab {
  position: fixed;
  right: 24px; bottom: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #1e40af;
  color: #fff;
  border: 0;
  box-shadow: 0 8px 22px rgba(30, 64, 175, 0.35);
  display: grid; place-items: center;
  z-index: 100;
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(30, 64, 175, 0.4); }
.chat-fab:active { transform: translateY(0); }

.chat-window {
  position: fixed;
  right: 24px; bottom: 92px;
  width: 380px;
  height: min(560px, calc(100vh - 120px));
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 101;
  transform-origin: bottom right;
  animation: chat-slide-up 0.22s ease-out;
}
@keyframes chat-slide-up {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-window[hidden] { display: none; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #fff;
}
.chat-title { display: flex; align-items: center; gap: 10px; }
.chat-status-dot {
  width: 9px; height: 9px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25);
}
.chat-name { font-weight: 600; font-size: 14px; }
.chat-subtitle { font-size: 11px; opacity: 0.85; margin-top: 1px; }

.chat-actions { display: flex; gap: 4px; }
.chat-icon-btn {
  background: transparent;
  border: 0;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 7px;
  display: grid; place-items: center;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
}
.chat-icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg.user {
  align-self: flex-end;
  background: #1e40af;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}
.msg.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.msg.empty {
  align-self: center;
  background: transparent;
  border: 0;
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
  padding: 24px 12px;
  white-space: normal;
}

/* indicador "digitando..." */
.msg.typing { padding: 12px 14px; }
.msg.typing .dot {
  display: inline-block;
  width: 6px; height: 6px;
  margin: 0 1.5px;
  background: #9ca3af;
  border-radius: 50%;
  animation: blink 1.2s infinite both;
}
.msg.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg.typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* simples bold para *texto* (mensagens do bot) */
.msg.bot strong { font-weight: 600; color: #111827; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}
.chat-input {
  flex: 1;
  resize: none;
  max-height: 100px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  line-height: 1.4;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: #1e40af; }
.chat-input:disabled { background: #f9fafb; color: #9ca3af; }

.chat-send {
  background: #1e40af;
  color: #fff;
  border: 0;
  border-radius: 9px;
  width: 40px;
  display: grid; place-items: center;
  transition: background 0.15s;
}
.chat-send:hover:not(:disabled) { background: #1d4ed8; }
.chat-send:disabled { background: #9ca3af; cursor: not-allowed; }

/* ===== Responsivo ===== */
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-nav { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .chat-window { right: 12px; left: 12px; width: auto; bottom: 84px; }
  .chat-fab { right: 16px; bottom: 16px; }
}
