:root {
  --primary-color: #00a884;
  --primary-dark: #008069;
  --bg-app: #111b21;
  --bg-sidebar: #111b21;
  --bg-chat: #0b141a;
  --bg-header: #202c33;
  --bg-bubble-in: #202c33;
  --bg-bubble-out: #005c4b;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --border-color: #222d34;
  --accent-color: #25d366;
  --badge-bg: #00a884;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #0c1317;
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-app);
  position: relative;
}

/* SIDEBAR */
.sidebar {
  width: 380px;
  min-width: 320px;
  max-width: 420px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

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

.user-profile .avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
}

.user-info h2 {
  font-size: 15px;
  font-weight: 600;
}

.status-indicator {
  font-size: 12px;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  background-color: #25d366;
  border-radius: 50%;
  box-shadow: 0 0 8px #25d366;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* SEARCH */
.search-container {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  background-color: var(--bg-header);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 12px;
}

.search-box i {
  color: var(--text-secondary);
  font-size: 14px;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  font-size: 14px;
}

/* CHATS LIST */
.chats-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}

.chat-item:hover {
  background-color: var(--bg-header);
}

.chat-item.active {
  background-color: #2a3942;
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #374248;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.chat-item-content {
  flex: 1;
  overflow: hidden;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-item-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.chat-item-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-item-lastmsg {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.unread-badge {
  background-color: var(--badge-bg);
  color: #111b21;
  font-size: 11px;
  font-weight: bold;
  border-radius: 10px;
  padding: 2px 7px;
}

.empty-chats {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-chats i {
  font-size: 48px;
  margin-bottom: 14px;
  color: #374248;
}

.empty-chats p {
  font-size: 14px;
  line-height: 1.5;
}

/* CHAT AREA */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-chat);
  position: relative;
  height: 100%;
}

.no-chat-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: #111b21;
  border-bottom: 6px solid var(--primary-color);
}

.no-chat-selected .illustration {
  max-width: 480px;
  padding: 20px;
}

.whatsapp-big-icon {
  font-size: 72px;
  color: #25d366;
  margin-bottom: 20px;
}

.no-chat-selected h2 {
  font-size: 26px;
  font-weight: 300;
  margin-bottom: 12px;
  color: #e9edef;
}

.no-chat-selected p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.setup-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 168, 132, 0.1);
  color: var(--primary-color);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* ACTIVE CHAT */
.active-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  height: 60px;
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.active-contact-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #00a884;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
}

.active-contact-info h3 {
  font-size: 16px;
  font-weight: 500;
}

.active-contact-info .sub-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.badge-active {
  color: var(--primary-color);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* MESSAGES CONTAINER */
.messages-container {
  flex: 1;
  padding: 20px 5%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.message-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14.2px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-bubble.inbound {
  align-self: flex-start;
  background-color: var(--bg-bubble-in);
  color: var(--text-primary);
  border-top-left-radius: 0;
}

.message-bubble.outbound {
  align-self: flex-end;
  background-color: var(--bg-bubble-out);
  color: #e9edef;
  border-top-right-radius: 0;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
}

.bubble-meta i.fa-check-double {
  color: #53bdeb;
}

/* FOOTER */
.chat-footer {
  height: 62px;
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
}

.chat-footer input {
  flex: 1;
  height: 42px;
  background-color: #2a3942;
  border: none;
  outline: none;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text-primary);
  font-size: 15px;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--primary-color);
  border: none;
  color: #111b21;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.send-btn:hover {
  background-color: #06cf9c;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: #222e35;
  width: 520px;
  max-width: 92%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 16px 20px;
  background-color: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.alert-box {
  background: rgba(0, 168, 132, 0.15);
  border-left: 4px solid var(--primary-color);
  padding: 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea {
  width: 100%;
  background-color: #111b21;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary-color);
}

.form-group small {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.webhook-guide {
  background: #111b21;
  padding: 14px;
  border-radius: 8px;
  margin-top: 16px;
  border: 1px dashed var(--border-color);
}

.webhook-guide h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--accent-color);
}

.code-box {
  background: #0b141a;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  color: #e9edef;
  line-height: 1.8;
}

.code-box strong {
  color: #25d366;
}

.modal-footer {
  padding: 14px 20px;
  background-color: var(--bg-header);
  text-align: right;
  border-top: 1px solid var(--border-color);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #111b21;
  border: none;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background-color: #06cf9c;
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-width: 100%;
  }

  .chat-area {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 100%;
    transition: left 0.25s ease-in-out;
    z-index: 10;
  }

  .chat-area.active-mobile {
    left: 0;
  }

  .back-btn {
    display: inline-block !important;
    margin-right: 6px;
  }
}
