html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  background: #f0f2f5;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.chat-page-wrap {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.chat-app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

.chat-sidebar {
  width: 360px;
  min-width: 300px;
  border-right: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-sidebar-title {
  font-weight: 600;
  color: #111b21;
}

.chat-sidebar-subtitle {
  font-size: 0.8rem;
  color: #667781;
}

.chat-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid #e9edef;
  background: #fff;
}

.chat-tab {
  flex: 1;
  border: none;
  background: #f0f2f5;
  color: #54656f;
  padding: 10px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.chat-tab.active {
  background: #008069;
  color: #fff;
}

.chat-tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 16px;
}

.chat-tab-panel.active {
  display: block;
}

.chat-panel-label {
  padding: 8px 18px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #667781;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.15s ease;
}

.chat-list-item:hover,
.chat-list-item.active {
  background: #f0f2f5;
}

.chat-list-item.active {
  border-left: 4px solid #008069;
  padding-left: 14px;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a884, #008069);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-avatar-self {
  width: 42px;
  height: 42px;
  font-size: 0.95rem;
}

.chat-avatar-group {
  background: linear-gradient(135deg, #5b8def, #3b6fd8);
}

.chat-avatar-broadcast {
  background: linear-gradient(135deg, #ff8a4c, #e85d04);
  font-size: 1.2rem;
}

.chat-list-body {
  flex: 1;
  min-width: 0;
}

.chat-list-name {
  font-weight: 600;
  color: #111b21;
  margin-bottom: 2px;
}

.chat-list-preview {
  font-size: 0.85rem;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25d366;
  flex-shrink: 0;
}

.offline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
}

.chat-empty {
  padding: 24px 18px;
  color: #667781;
  font-size: 0.9rem;
}

.chat-create-group {
  display: flex;
  gap: 8px;
  padding: 0 14px 12px;
}

.broadcast-entry {
  margin: 0 8px;
  border-radius: 12px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #efeae2;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
}

.chat-header-name {
  font-weight: 700;
  color: #111b21;
}

.chat-header-status {
  font-size: 0.85rem;
  color: #667781;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)), url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d7db' fill-opacity='0.18'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  display: flex;
}

.message-self {
  justify-content: flex-end;
}

.message-other,
.message-broadcast {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 8px 12px 10px;
  border-radius: 12px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.bubble-self {
  background: #d9fdd3;
  border-top-right-radius: 4px;
}

.bubble-other {
  background: #fff;
  border-top-left-radius: 4px;
}

.bubble-group-self {
  background: #cfe2ff;
  border-top-right-radius: 4px;
}

.bubble-group-other {
  background: #fff;
  border-top-left-radius: 4px;
}

.bubble-broadcast {
  background: #fff3cd;
  border-left: 4px solid #e85d04;
}

.bubble-broadcast-self {
  background: #fff3cd;
  border-right: 4px solid #e85d04;
  border-top-right-radius: 4px;
}

.message-author {
  font-size: 0.75rem;
  font-weight: 700;
  color: #008069;
  margin-bottom: 4px;
}

.message-broadcast .message-author {
  color: #e85d04;
}

.message-text {
  color: #111b21;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
  gap: 4px;
}

.message-time {
  font-size: 0.68rem;
  color: #667781;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.bubble-self .message-time {
  color: #54a381;
}

.chat-composer {
  padding: 12px 16px;
  background: #f0f2f5;
  border-top: 1px solid #e9edef;
}

.chat-composer-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-composer-form .form-control {
  border-radius: 24px;
  border: none;
  padding: 12px 18px;
  background: #fff;
}

.chat-send-btn {
  border-radius: 24px;
  padding: 10px 20px;
  font-weight: 600;
}

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: #54656f;
}

.chat-welcome-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.chat-welcome h2 {
  color: #111b21;
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .chat-app {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
  }

  .chat-sidebar {
    width: 100%;
    min-width: 0;
    max-height: none;
  }

  .chat-main {
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
  }

  .chat-page-wrap {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .chat-app-index .chat-main {
    display: none !important;
  }

  .chat-app-index .chat-sidebar {
    max-height: none;
    height: 100vh;
    height: 100dvh;
  }

  .chat-app-chat .chat-sidebar {
    display: none !important;
  }

  .chat-app-chat .chat-main {
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* Group Management Panel */
.group-management-panel {
  width: 320px;
  background: #fff;
  border-left: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  position: absolute;
  right: -320px; /* Hidden by default */
  top: 0;
  bottom: 0;
  transition: right 0.3s ease;
  z-index: 100;
  box-shadow: -4px 0 15px rgba(0,0,0,0.05);
}

.group-management-panel.open {
  right: 0;
}

.group-management-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
}

.group-management-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-main {
  position: relative;
  overflow: hidden; /* Ensure drawer slides within bounds */
}
