/* layout.css — shell de 2 colunas no desktop / drawer no mobile */

html, body {
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--wa-teal);
  color: #fff;
  z-index: 30;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand strong {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.brand span {
  font-size: 14.4px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: inherit;
  flex: 0 0 auto;
}

.icon-btn:hover { background: rgba(0, 0, 0, 0.08); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- Shell ---------- */
.app {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 25;
}

.sidebar-head {
  padding: 8px 10px;
  background: var(--panel);
  border-bottom: 1px solid #E9EDEF;
}

/* busca em pílula cinza com lupa, como no WhatsApp Web */
.sidebar-head input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px 8px 40px;
  font-size: 16.2px;
  background: var(--panel-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2354656F' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center / 17px 17px;
  color: var(--ink);
}

.sidebar-head input::placeholder { color: var(--ink-muted); }

.sidebar-head input:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--wa-green);
}

.chatlist {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-foot {
  padding: 8px 12px;
  font-size: 13.2px;
  color: var(--ink-3);
  border-top: 1px solid #E9EDEF;
  background: var(--panel);
}

.view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--wa-chat-bg);
}

.view > * { min-height: 0; }

.scrim {
  display: none;
}

/* ---------- Mobile: drawer ---------- */
@media (max-width: 767px) {
  .only-mobile { display: inline-flex; }
  .only-desktop { display: none !important; }

  /* topbar: marca truncável */
  .brand {
    overflow: hidden;
    flex: 0 1 auto;
  }

  .brand strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(86vw, 360px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
  }

  .scrim {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(11, 20, 26, 0.45);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .scrim.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 768px) {
  .only-mobile { display: none !important; }
  .only-desktop { display: inline-flex; }
}
