:root {
  --bg-sidebar: #111b21;
  --bg-main: #0b141a;
  --bg-header: #202c33;
  --bg-hover: #2a3942;
  --bg-input: #2a3942;
  --green: #00a884;
  --green-wa: #25d366;
  --text: #e9edef;
  --text2: #8696a0;
  --bubble: #005c4b;
  --border: #222d34;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  background: #0b141a;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 420px;
  min-width: 340px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  height: 60px;
  background: var(--bg-header);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.profile h1 {
  font-size: 16px;
  font-weight: 500;
}

.profile span {
  font-size: 12px;
  color: var(--text2);
}

.actions { display: flex; gap: 4px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.search-box {
  padding: 8px 12px;
  position: relative;
}
.search-box i {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text2);
  font-size: 14px;
}
.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 10px 12px 10px 40px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: var(--bg-input);
  border: none;
  color: var(--text2);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
}
.tab.active {
  background: var(--green);
  color: #fff;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.chat-item:hover,
.chat-item.active {
  background: var(--bg-hover);
}

.chat-item .avatar {
  font-size: 13px;
  width: 48px;
  height: 48px;
}

.chat-meta {
  flex: 1;
  min-width: 0;
}
.chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.chat-name {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-time {
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
}
.chat-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-preview {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.badge.pending {
  background: #4a3d2d;
  color: #f4b400;
}
.badge.sent {
  background: #1e3a2f;
  color: #25d366;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.4'%3E%3Cpath d='M50 50v-6h-4v6h-6v4h6v6h4v-6h6v-4h-6zm0-40V4h-4v6h-6v4h6v6h4V14h6V10h-6zM10 50v-6H6v6H0v4h6v6h4v-6h6v-4H10zM10 10V4H6v6H0v4h6v6h4V14h6V10H10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.empty-icon {
  width: 90px;
  height: 90px;
  background: var(--bg-header);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--green-wa);
  margin-bottom: 24px;
}
.empty h2 {
  font-size: 28px;
  font-weight: 300;
  margin-bottom: 10px;
}
.empty p {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 28px;
}
.stats {
  display: flex;
  gap: 24px;
  font-size: 14px;
  color: var(--text2);
}
.stats strong {
  color: var(--text);
  font-size: 20px;
  display: block;
}

/* Chat view */
.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  height: 60px;
  background: var(--bg-header);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-info h2 {
  font-size: 16px;
  font-weight: 500;
}
.user-info span {
  font-size: 13px;
  color: var(--text2);
}

.message-area {
  flex: 1;
  overflow-y: auto;
  padding: 30px 60px;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.35'%3E%3Cpath d='M50 50v-6h-4v6h-6v4h6v6h4v-6h6v-4h-6zm0-40V4h-4v6h-6v4h6v6h4V14h6V10h-6zM10 50v-6H6v6H0v4h6v6h4v-6h6v-4H10zM10 10V4H6v6H0v4h6v6h4V14h6V10H10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.date-sep {
  align-self: center;
  background: var(--bg-header);
  color: var(--text2);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.bubble {
  max-width: 70%;
  padding: 10px 14px 8px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  position: relative;
}
.bubble.out {
  background: var(--bubble);
  border-top-right-radius: 0;
  align-self: flex-end;
}

.bottom-bar {
  background: var(--bg-header);
  padding: 14px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--border);
}

.btn-wa {
  flex: 1;
  background: var(--green-wa);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .2s, transform .15s;
}
.btn-wa:hover {
  background: #1da851;
  transform: scale(1.02);
}
.btn-wa i { font-size: 22px; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: none;
  border-radius: 24px;
  padding: 14px 20px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover {
  background: var(--bg-hover);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #374045; border-radius: 3px; }

@media (max-width: 768px) {
  .sidebar { width: 100%; }
  .main { display: none; }
  .main.active { display: flex; position: absolute; inset: 0; }
  .message-area { padding: 20px; }
  .bubble { max-width: 90%; }
}
