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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #0d0f1a;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #ffffff;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}


/* =========================================================
   APP
========================================================= */

.app-container {
  width: 100%;
  height: 100dvh;
  background: linear-gradient(
    180deg,
    #1d1838 0%,
    #121324 50%,
    #0d1e36 100%
  );
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

@media (min-width: 768px) {

  body {
    padding: 20px;
  }

  .app-container {
    max-width: 1100px;
    height: 88vh;
    max-height: 850px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  }

}


/* =========================================================
   LOGIN
========================================================= */

#login-screen {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  overflow-y: auto;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.brand-logo {
  width: 60px;
  height: 60px;
  background: #7c3aed;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.brand-subtitle {
  font-size: 12px;
  color: #a1a1aa;
  margin-bottom: 18px;
}

.form-group {
  width: 100%;
  text-align: left;
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #e4e4e7;
}

.form-input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #ffffff !important;
  font-size: 14px;
  outline: none;
}

.form-input:focus {
  border-color: #00d2ff;
}

#captcha-container {
  margin: 10px 0;
  display: none;
  justify-content: center;
  width: 100%;
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(
    90deg,
    #7c3aed 0%,
    #00d2ff 100%
  );
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-submit:hover {
  opacity: 0.9;
}

.toggle-auth {
  font-size: 13px;
  color: #a1a1aa;
  margin-top: 14px;
  cursor: pointer;
}

.toggle-auth span {
  color: #00d2ff;
  font-weight: 600;
}

#auth-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 10px;
  font-weight: 600;
}


/* =========================================================
   CHAT
========================================================= */

#chat-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}


/* HEADER */

.chat-header {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title {
  font-weight: 700;
  font-size: 15px;
}

.header-sub {
  font-size: 11px;
  color: #a1a1aa;
}

.header-status-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.status-select {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.status-select option {
  background: #121324;
}


/* MOBILE USER BUTTON */

.mobile-toggle-btn {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}


/* PROFILE BAR */

.profile-bar {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.profile-avatar-preview {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #7c3aed;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.upload-btn-label {
  background: linear-gradient(
    90deg,
    #7c3aed 0%,
    #00d2ff 100%
  );
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-block;
}

.upload-status {
  font-size: 11px;
  color: #a1a1aa;
}


/* =========================================================
   CHAT BODY
========================================================= */

.chat-body-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}


/* SIDEBAR */

.sidebar {
  width: 260px;
  background: rgba(0, 0, 0, 0.25);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.sidebar-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.user-item:hover {
  background: rgba(255, 255, 255, 0.08);
}


/* MAIN CHAT */

.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}


/* =========================================================
   MESSAGES
========================================================= */

.msg-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 12px 14px;
  position: relative;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  object-fit: cover;
  overflow: hidden;
}

.header-avatar {
  background: #8b5cf6;
  cursor: pointer;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name {
  font-weight: 700;
  font-size: 13px;
  color: #38bdf8;
}

.role-badge {
  background: #8b5cf6;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}

.msg-body {
  font-size: 14px;
  color: #f4f4f5;
  line-height: 1.4;
  word-break: break-word;
}


/* ADMIN */

.admin-controls {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.admin-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.admin-btn:hover {
  background: rgba(239, 68, 68, 0.4);
}


/* =========================================================
   FOOTER
========================================================= */

.chat-footer {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.msn-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.msn-toolbar select {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
}

.msn-toolbar input[type="color"] {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 24px;
  color: #ffffff !important;
  font-size: 14px;
  outline: none;
}

.chat-input::placeholder {
  color: #a1a1aa;
}

.chat-input:focus {
  border-color: #00d2ff;
  background: rgba(255, 255, 255, 0.18);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(
    135deg,
    #8b5cf6,
    #3b82f6
  );
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}


/* =========================================================
   PROFILE MODAL
========================================================= */

.profile-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.profile-modal-box {
  background: #1d1838;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 300px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.close-profile-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #a1a1aa;
  font-size: 18px;
  cursor: pointer;
}

.modal-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #7c3aed;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  overflow: hidden;
}

.modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-username {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.modal-role {
  display: inline-block;
  margin-bottom: 12px;
}

.modal-status-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 12px;
  font-size: 12px;
  color: #a1a1aa;
  margin-top: 8px;
}

#modal-status {
  color: #4ade80;
  font-weight: 600;
}

.role-assign-box {
  display: none;
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.role-assign-box label {
  font-size: 11px;
  color: #a1a1aa;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.role-assign-box select {
  background: #121324;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  width: 100%;
  font-weight: 600;
  outline: none;
}

#role-save-status {
  font-size: 10px;
  color: #4ade80;
  margin-top: 4px;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 767px) {

  .mobile-toggle-btn {
    display: block;
  }

  .sidebar {
    position: absolute;
    inset: 0;
    z-index: 50;
    width: 100%;
    background: #121324;
    display: none;
  }

  .sidebar.active {
    display: flex;
  }

  .chat-header {
    padding: 10px 12px;
  }

  .profile-bar {
    padding: 6px 12px;
  }

  #messages-list {
    padding: 12px;
  }

  .chat-footer {
    padding: 8px 10px;
  }

  .header-sub {
    display: none;
  }

}