/*

 */

/* ============================================================
   INTEGRAVET — Tema de marca
   Cores: turquesa #0baab9 (primária) | slate #2f4656 (texto)
   ============================================================ */

:root {
  --cui-primary:             #0baab9;
  --cui-primary-rgb:         11, 170, 185;
  --cui-primary-text-emphasis: #076e78;
  --cui-primary-bg-subtle:   #d5f3f6;
  --cui-primary-border-subtle: #9ee5ec;
  --cui-link-color:          #0baab9;
  --cui-link-hover-color:    #0990a0;
  --iv-slate:                #2f4656;
  --iv-turquoise:            #0baab9;
  --iv-active-bg:            #e6f7f9;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  --cui-sidebar-bg:                         #ffffff;
  --cui-sidebar-color:                      #2f4656;
  --cui-sidebar-brand-bg:                   #ffffff;
  --cui-sidebar-brand-color:                #2f4656;
  --cui-sidebar-nav-title-color:            #9aacb8;
  --cui-sidebar-nav-link-color:             #2f4656;
  --cui-sidebar-nav-link-icon-color:        #6b8fa8;
  --cui-sidebar-nav-link-bg:                transparent;
  --cui-sidebar-nav-link-hover-color:       #0baab9;
  --cui-sidebar-nav-link-hover-bg:          #f0fbfc;
  --cui-sidebar-nav-link-hover-icon-color:  #0baab9;
  --cui-sidebar-nav-link-active-color:      #0baab9;
  --cui-sidebar-nav-link-active-bg:         #e6f7f9;
  --cui-sidebar-nav-link-active-icon-color: #0baab9;
  --cui-border-color:                       #e4e8ec;
  background-color: #ffffff !important;
  border-right-color: #e4e8ec !important;
}

/* Garante que sidebar-dark não sobrescreva o tema claro */
.sidebar.sidebar-dark,
.sidebar-dark .sidebar {
  background-color: #ffffff !important;
  --cui-body-bg: #ffffff;
  --cui-body-color: #2f4656;
  --cui-emphasis-color: #2f4656;
  --cui-secondary-color: #6b8fa8;
  --cui-tertiary-color: #9aacb8;
  --cui-tertiary-bg: #f0fbfc;
  --cui-border-color: #e4e8ec;
}

.sidebar-header {
  background-color: #ffffff !important;
  border-bottom-color: #e4e8ec !important;
}

.sidebar .nav-title {
  color: #7a9ab0 !important;
  font-size: 0.70rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.10em !important;
  text-transform: uppercase !important;
  padding-top: 1.1rem !important;
  padding-bottom: 0.35rem !important;
  margin-top: 0.25rem !important;
  border-top: 1px solid #e4e8ec;
  cursor: default;
  transition: color 0.15s ease;
  user-select: none;
}
.sidebar .nav-title:first-child {
  border-top: none !important;
  padding-top: 0.5rem !important;
}
.sidebar .nav-title:hover {
  color: #0baab9 !important;
}
.sidebar .nav-title i {
  transition: color 0.15s ease;
  opacity: 0.7;
}
.sidebar .nav-title:hover i {
  color: #0baab9 !important;
  opacity: 1;
}

.sidebar .nav-link {
  color: #2f4656 !important;
  font-size: 0.875rem;
}
.sidebar .nav-link:hover {
  color: #0baab9 !important;
  background-color: #f0fbfc !important;
}
.sidebar .nav-link.active {
  color: #0baab9 !important;
  background-color: #e6f7f9 !important;
  font-weight: 600;
}
.sidebar .nav-link .nav-icon {
  color: #6b8fa8;
}
.sidebar .nav-link:hover .nav-icon,
.sidebar .nav-link.active .nav-icon {
  color: #0baab9 !important;
}

/* Info do usuário no rodapé da sidebar */
.sidebar .sidebar-user-info {
  border-top-color: #e4e8ec !important;
}

/* ── Navbar (header) ─────────────────────────────────────── */
.header {
  background-color: #ffffff !important;
  box-shadow: 0 1px 4px rgba(47, 70, 86, 0.08) !important;
}
.header .border-bottom {
  border-bottom-color: #e4e8ec !important;
}
.header-toggler {
  color: #2f4656 !important;
}
.header-toggler svg { fill: #2f4656 !important; }
.header .nav-link {
  color: #2f4656 !important;
}
.header .nav-link:hover { color: #0baab9 !important; }

/* ── Botões primary ──────────────────────────────────────── */
.btn-primary {
  --cui-btn-bg:                  #0baab9;
  --cui-btn-border-color:        #0baab9;
  --cui-btn-hover-bg:            #0990a0;
  --cui-btn-hover-border-color:  #0990a0;
  --cui-btn-active-bg:           #077e8c;
  --cui-btn-active-border-color: #077e8c;
  --cui-btn-disabled-bg:         #0baab9;
  --cui-btn-disabled-border-color: #0baab9;
}
.btn-outline-primary {
  --cui-btn-color:               #0baab9;
  --cui-btn-border-color:        #0baab9;
  --cui-btn-hover-bg:            #0baab9;
  --cui-btn-hover-border-color:  #0baab9;
  --cui-btn-active-bg:           #0baab9;
}

/* ── Badges primary ──────────────────────────────────────── */
.badge.bg-primary { background-color: #0baab9 !important; }

/* ── Focus em inputs ─────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
  border-color: #0baab9;
  box-shadow: 0 0 0 0.2rem rgba(11, 170, 185, 0.2);
}

/* ── Spinner ─────────────────────────────────────────────── */
.text-primary { color: #0baab9 !important; }

/* ── Links ───────────────────────────────────────────────── */
a:not(.btn):not(.nav-link):not(.dropdown-item) {
  color: #0baab9;
}
a:not(.btn):not(.nav-link):not(.dropdown-item):hover {
  color: #0990a0;
}

/* Tom-select dentro de modal: permite overflow para o dropdown aparecer */
.modal-content,
.modal-body { overflow: visible !important; }
.ts-dropdown {
  z-index: 1100 !important;
  background-color: #fff !important;
}

/* TomSelect — alinhar altura com inputs Bootstrap sm.
   O .ts-wrapper herda form-select-sm e tem 1px de borda cima+baixo (2px total).
   O .ts-control precisa de 29px para que wrapper total = 31px = altura do form-control-sm. */
/* TomSelect com form-select (tamanho normal) — remove borda dupla */
.ts-wrapper.form-select {
  padding: 0 !important;
  min-height: 0 !important;
}
.ts-wrapper.form-select .ts-control {
  border: none !important;
  box-shadow: none !important;
  min-height: calc(1.5em + 0.75rem) !important;
  padding: 0.375rem 2rem 0.375rem 0.75rem !important;
  box-sizing: border-box;
}

/* TomSelect com form-select-sm — alinhar altura com inputs Bootstrap sm */
.ts-wrapper.form-select-sm {
  padding: 0 !important;
  min-height: 0 !important;
}
.ts-wrapper.form-select-sm .ts-control {
  border: none !important;
  box-shadow: none !important;
  min-height: calc(1.5em + 0.5rem) !important;
  padding: 0.25rem 2rem 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  box-sizing: border-box;
}

body {
  background-color: #f3f5f7;
  color: #1f2933;
}

/* Info do usuário logado no rodapé do sidebar */
.sidebar-user-info {
  line-height: 1.35;
}

.app-shell__lead {
  max-width: 36rem;
}

.body-content {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.sidebar-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1034; /* just below sidebar z-index 1035 */
}

.card-body-wrapper .actions {
  border-bottom: 1px solid var(--cui-border-color, #d8dbe0);
  padding-bottom: 0.75rem;
  margin-bottom: 0;
}

/* Turbo progress bar */
.turbo-progress-bar {
  height: 3px;
  background: var(--cui-primary, #321fdb);
}

/* Dim turbo frames while loading */
turbo-frame[busy] {
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

/* Clickable table rows */
.table-row-link {
  cursor: pointer;
}
.table-row-link:hover td {
  background-color: var(--cui-table-hover-bg, rgba(0,0,21,.075));
}

/* FullCalendar — responsive fixes */
@media (max-width: 575px) {
  .fc-toolbar-title {
    font-size: 0.85rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  .fc-header-toolbar {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }
  .fc-toolbar-chunk {
    display: flex;
    align-items: center;
  }
}

/* Multiroom grid — horizontal scroll on small screens */
.multiroom-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Chat Widget Flutuante
   ============================================================ */

/* Root — posicionado no canto inferior direito, acima de tudo */
#chat-widget-root {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 1040;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 8px;
  pointer-events: none; /* permite clicar no conteúdo abaixo */
}
#chat-widget-root > * { pointer-events: auto; }

/* Caixas de conversa abertas */
.cw-boxes {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* ---- Caixa individual de conversa ---- */
.cw-box {
  width: 296px;
  height: 370px;
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height .18s ease;
}
.cw-box.cw-box-minimized {
  height: auto;
}
.cw-box.cw-box-minimized .cw-box-body { display: none; }

.cw-box-header {
  background: #1877f2;
  color: #fff;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  border-radius: 8px 8px 0 0;
  gap: 6px;
}
.cw-box-name {
  font-weight: 600;
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.cw-box-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  padding: 0 3px;
  font-size: .78rem;
  line-height: 1;
}
.cw-box-btn:hover { color: #fff; }

.cw-box-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.cw-box-messages {
  flex: 1;
  overflow-y: auto;
  padding: .65rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  scroll-behavior: smooth;
}

/* Balões de mensagem — estilo WhatsApp */
.cw-msg { display: flex; margin-bottom: .15rem; }
.cw-msg-own   { justify-content: flex-end; }
.cw-msg-other { justify-content: flex-start; }

.cw-bubble {
  position: relative;
  max-width: 80%;
  padding: .35rem .55rem .28rem .55rem;
  border-radius: .75rem;
  font-size: .84rem;
  word-break: break-word;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,.1);
}

/* Própria mensagem — verde claro */
.cw-msg-own .cw-bubble {
  background: #d9fdd3;
  color: #111b21;
  border-bottom-right-radius: .2rem;
}

/* Mensagem recebida — branca */
.cw-msg-other .cw-bubble {
  background: #fff;
  color: #111b21;
  border-bottom-left-radius: .2rem;
}

/* Meta (hora + ticks) — flutua à direita, dentro da bolha */
.cw-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .18rem;
  float: right;
  margin-left: .4rem;
  margin-top: .1rem;
  /* Empurra para baixo na mesma linha que o texto */
  position: relative;
  bottom: -.1rem;
}
.cw-msg-meta small {
  font-size: .65rem;
  color: #667781;
  white-space: nowrap;
}

/* Ticks de status */
.cw-status        { font-size: .7rem; color: #667781; line-height: 1; }
.cw-status-read   { color: #53bdeb; }  /* azul = lida, igual ao WhatsApp */

/* Clearfix após o float */
.cw-bubble::after { content: ""; display: table; clear: both; }

.cw-msg-img {
  max-width: 100%;
  max-height: 180px;
  border-radius: .5rem;
  display: block;
  margin-bottom: .25rem;
}
.cw-msg-file {
  color: #1d7bd4;
  text-decoration: none;
  font-size: .8rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

/* Rodapé da caixa */
.cw-box-footer {
  display: flex;
  align-items: flex-end;
  gap: .35rem;
  padding: .4rem .5rem;
  border-top: 1px solid #e4e6ea;
  flex-shrink: 0;
  background: #fff;
}
.cw-input {
  flex: 1;
  border: 1px solid #ccd0d5;
  border-radius: 1.2rem;
  padding: .35rem .7rem;
  font-size: .82rem;
  resize: none;
  outline: none;
  max-height: 72px;
  overflow-y: auto;
  line-height: 1.4;
  background: #f0f2f5;
  transition: border-color .15s;
}
.cw-input:focus { border-color: #1877f2; background: #fff; }

/* Botões de ícone (emoji, anexo) */
.cw-icon-btn {
  background: none;
  border: none;
  color: #606770;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  padding: 0;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.cw-icon-btn:hover { background: #f0f2f5; color: #1877f2; }

/* Botão enviar */
.cw-send-btn {
  background: #1877f2;
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
  transition: background .15s;
}
.cw-send-btn:hover { background: #1558c0; }

/* Emoji picker — portal fixo no body, fora de qualquer overflow:hidden */
.cw-emoji-portal {
  position: fixed;
  z-index: 9999;
}
.cw-emoji-portal emoji-picker {
  --num-columns: 7;
  --emoji-size: 1.05rem;
  height: 260px;
  width: 296px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  border-radius: .5rem;
}

/* Preview de anexo */
.cw-attach-preview { font-size: .75rem; }

/* ---- Painel de contatos (roster) ---- */
.cw-roster {
  width: 256px;
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  overflow: hidden;
  flex-shrink: 0;
}
.cw-roster-header {
  background: #1877f2;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: .875rem;
  gap: 6px;
}
.cw-roster-title { display: flex; align-items: center; flex: 1; }
.cw-roster-body {
  max-height: 380px;
  overflow-y: auto;
}
.cw-contact {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  cursor: pointer;
  font-size: .85rem;
  transition: background .1s;
}
.cw-contact:hover { background: #f0f2f5; }
.cw-contact-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Indicadores de presença */
.cw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cw-dot.online  { background: #31a24c; }
.cw-dot.offline { background: #ccd0d5; }

/* Presença global (usada em outros contextos) */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background-color: #31a24c; }
.status-dot.offline { background-color: #ccd0d5; }

/* Mobile: ocultar caixas extras, apenas o roster */
@media (max-width: 575.98px) {
  .cw-boxes { display: none; }
  .cw-roster { width: calc(100vw - 16px); }
}
