:root {
  --primary: #25D366;       /* verde WhatsApp */
  --primary-dark: #128C7E;
  --accent: #6C5CE7;
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --border: #E4E6EB;
  --text: #111B21;
  --muted: #667781;
  --danger: #E85D75;
  --warning: #F1C40F;
  --sidebar-w: 260px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky; top: 0; align-self: flex-start;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: .75rem;
  position: sticky; top: 0; z-index: 10;
}
.app-content { padding: 1.5rem; flex: 1; }

/* ===== Sidebar ===== */
.brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-weight: 700; font-size: .85rem;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.brand-title { font-weight: 600; font-size: .95rem; line-height: 1; }
.brand-sub { font-size: .75rem; color: var(--muted); }

.app-sidebar .nav { padding: .75rem; }
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .85rem; border-radius: 8px;
  color: #3a444b; font-weight: 500; font-size: .9rem;
  margin-bottom: 2px;
}
.app-sidebar .nav-link:hover { background: #F4F6F8; color: var(--text); }
.app-sidebar .nav-link.active {
  background: rgba(37, 211, 102, .12);
  color: var(--primary-dark);
}

/* ===== Login ===== */
.login-shell {
  min-height: 100vh;
  background: linear-gradient(135deg, #128C7E 0%, #25D366 100%);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

/* ===== Inbox layout (3 columnas) ===== */
.inbox {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - var(--topbar-h));
  background: #fff;
  margin: -1.5rem;
}
.inbox-list {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.inbox-list-header {
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; gap: .5rem; align-items: center;
}
.inbox-list-items { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex; gap: .75rem; padding: .85rem 1rem;
  border-bottom: 1px solid #f1f3f5; cursor: pointer; text-decoration: none; color: inherit;
}
.conv-item:hover { background: #fafbfc; }
.conv-item.active { background: rgba(37, 211, 102, .08); }
.conv-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #e0e3e8; color: #555; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: .5rem; }
.conv-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: .72rem; color: var(--muted); }
.conv-snippet { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-badge {
  background: var(--primary); color: #fff; font-size: .7rem;
  padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.inbox-chat { display: flex; flex-direction: column; min-height: 0; background: #ECE5DD; }
.chat-header {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: .75rem 1rem; display: flex; align-items: center; gap: .75rem;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.msg { max-width: 65%; padding: .55rem .75rem; border-radius: 8px; font-size: .9rem; line-height: 1.35; word-wrap: break-word; }
.msg-in  { background: #fff; align-self: flex-start; border-top-left-radius: 0; }
.msg-out { background: #DCF8C6; align-self: flex-end; border-top-right-radius: 0; }
.msg-meta { font-size: .68rem; color: var(--muted); text-align: right; margin-top: 2px; }
.msg-meta i { font-size: .65rem; }
.msg-sys { align-self: center; background: rgba(0,0,0,.05); color: var(--muted); font-size: .75rem; border-radius: 6px; }

.chat-composer {
  background: #f0f2f5; padding: .75rem 1rem;
  display: flex; gap: .5rem; align-items: flex-end;
  border-top: 1px solid var(--border);
}
.chat-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border);
  border-radius: 20px; padding: .55rem 1rem; font-size: .9rem;
  max-height: 120px; outline: none;
}
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-direction: column; gap: 1rem;
}
.chat-empty i { font-size: 4rem; opacity: .4; }

/* responsive */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; z-index: 100;
    transform: translateX(-100%); transition: transform .25s;
  }
  .app-sidebar.open { transform: translateX(0); }
  .inbox { grid-template-columns: 1fr; }
}
