/* ==========================================
   RESET & GLOBAL STYLES (SLATE / BLUE THEME)
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: #0f172a;
  color: #f8fafc;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* Container Utama untuk Setiap Section */
.container {
  background: #1e293b;
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
}

/* ==========================================
   AUTH & FORM (LOGIN / REGISTER)
   ========================================== */
.logo-container {
  text-align: center;
  margin-bottom: 20px;
}

.logo {
  max-width: 260px;
  height: auto;
}

.logo-small {
  max-width: 90px;
  height: auto;
  display: block;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  background: #0f172a;
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #06b6d4;
  color: #ffffff;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  color: #f8fafc;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: #06b6d4;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

.btn-primary {
  width: 100%;
  background: #06b6d4;
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background: #0891b2;
}

.btn-secondary {
  width: 100%;
  background: #334155;
  color: #f8fafc;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: #475569;
}

/* ==========================================
   SEARCH SECTION & USER LIST
   ========================================== */
.header-user {
  display: flex;
  align-items: flex-start; /* Mengunci nama pengguna di posisi atas */
  justify-content: space-between;
  position: relative;      /* Sebagai acuan posisi logo di tengah */
  width: 100%;
  margin-bottom: 20px;
  min-height: 65px;
}

/* Nama User di Pojok Kiri Atas */
#displayMyUsername {
  font-weight: 600;
  font-size: 0.9rem;
  color: #94a3b8;
  z-index: 2;             /* Agar berada di atas layer lain */
}

/* Logo Presisi di Tengah Halaman Pencarian */
.header-user .logo-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user .logo {
  height: 80px;           /* Sesuaikan tinggi logo */
  object-fit: contain;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #ef4444;
  color: #ffffff;
}

.search-box h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #f8fafc;
}

.user-card {
  background: #0f172a;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 1px solid #334155;
  margin-top: 8px;
  transition: background-color 0.2s;
  color: #f8fafc;
  font-weight: 500;
}

.user-card:hover {
  background: #334155;
}

/* ==========================================
   MODAL KONFIRMASI (USER MODAL)
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #1e293b;
  padding: 20px;
  border-radius: 12px;
  width: 85%;
  max-width: 320px;
  text-align: center;
  border: 1px solid #334155;
}

.modal-content h3 {
  font-size: 1.2rem;
  color: #f8fafc;
  margin-bottom: 4px;
}

.status-text {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ==========================================
   CHAT SECTION LAYOUT
   ========================================== */
.chat-container-layout,
#chatSection {
  width: 100%;
  max-width: 450px;
  height: 90vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding: 0;
  background-color: #0f172a;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  border: 1px solid #334155;
}

@media (min-width: 768px) {
  .chat-container-layout,
  #chatSection {
    max-width: 650px;
  }
}

/* HEADER RUANG OBROLAN */
.chat-header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  height: 42px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.btn-back {
  background: transparent;
  border: none;
  color: #38bdf8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.chat-header-info {
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Pembungkus Dot & Nama Sejajar */
.user-name-wrapper {
  display: flex;
  align-items: center;
  gap: 8px; /* Jarak antara titik hijau/abu dan nama */
  overflow: hidden;
}

.target-username {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
  margin: 0 !important;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px; /* Batas maksimal panjang nama */
}

/* Hanya Indikator Lingkaran (Online / Offline) */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-dot.online {
  background-color: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.status-dot.offline {
  background-color: #64748b;
}

.target-username {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* Menambahkan titik-titik (...) jika nama terlalu panjang */
  max-width: 160px;        /* Batas maksimal lebar nama user */
}

.status-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #94a3b8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.status-dot.offline {
  background-color: #64748b;
}

.btn-back,
.btn-dots {
  background: transparent;
  border: none;
  color: #06b6d4;
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.1s;
}

.btn-back:hover,
.btn-dots:hover {
  color: #38bdf8;
  transform: scale(1.15);
}

/* DROPDOWN MENU */
.chat-menu-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 40px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 100;
  width: 120px;
  overflow: hidden;
}

.dropdown-item-danger {
  width: 100%;
  background: transparent;
  color: #ef4444;
  border: none;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.dropdown-item-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* MESSAGES BOX */
.messages-box {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* CHAT INPUT BOX */
.chat-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #1e293b;
  border-top: 1px solid #334155;
}

.chat-input-box textarea {
  flex: 1;
  margin-bottom: 0;
  resize: none;
  height: 42px;
  padding: 10px 12px;
  border-radius: 20px;
}

.btn-plus,
.btn-emoji,
.btn-send {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #06b6d4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: transform 0.1s;
}

.btn-plus:hover,
.btn-emoji:hover,
.btn-send:hover {
  transform: scale(1.15);
  color: #38bdf8;
}

/* ==========================================
   POPUP PREVIEW GAMBAR (IMAGE MODAL)
   ========================================== */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 25px;
  font-size: 35px;
  color: #ffffff;
  cursor: pointer;
  z-index: 2100;
  user-select: none;
}

.modal-content-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: transform 0.1s ease-out;
   padding: 1px;
}
