:root {
  --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.15);
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
  --text-main: #ffffff;
  --text-muted: #a0a0a0;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Full screen layout */
}

/* Utility Classes */
.mobile-only {
  display: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* ================= AUTH SECTION ================= */
#auth-section {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: fadeInDown 0.6s ease-out;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Brand Header */
.brand-header {
  margin-bottom: 28px;
}

.brand-logo {
  font-size: 2.4rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #c3a7e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.brand-tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Creator Credit — auth card */
.creator-credit {
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.creator-credit .heart {
  color: #ff6b9d;
}

.creator-credit strong {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
}

/* Creator Credit — sidebar footer */
.sidebar-creator {
  margin-top: auto;
  padding: 14px 15px 6px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.25);
  text-align: center;
  letter-spacing: 0.3px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-creator strong {
  color: rgba(255, 255, 255, 0.45);
}

#auth-section h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin-bottom: 24px;
  background: linear-gradient(to right, #fff, #b0b0b0);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-body);
  font-size: 1rem;
  transition: all 0.3s ease;
}

input:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 15px rgba(118, 75, 162, 0.3);
  background: rgba(0, 0, 0, 0.5);
}

button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(118, 75, 162, 0.6);
}

button:active {
  transform: scale(0.98);
}

.toggle-form {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toggle-form a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  margin-left: 5px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.5);
}

.toggle-form a:hover {
  border-bottom-style: solid;
}

.error-message {
  color: #ff6b6b;
  margin-top: 10px;
  font-size: 0.9rem;
  min-height: 20px;
}

/* ================= CHAT CONTAINER ================= */
/* ================= CHAT CONTAINER ================= */
#chat-container {
  width: 100%;
  height: 100%;
  max-width: none;
  background: rgba(0, 0, 0, 0.2);
  /* Slightly darker, no borders */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: none;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  overflow: hidden;
  animation: zoomIn 0.3s ease-out;
}

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ================= SIDEBAR ================= */
.online-users-box {
  width: 280px;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.online-users-box h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#online-users-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

#online-users-list li {
  padding: 12px 15px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  position: relative;
  font-weight: 500;
}

#online-users-list li::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #00b894;
  border-radius: 50%;
  margin-right: 12px;
  box-shadow: 0 0 8px #00b894;
}

#online-users-list li:hover {
  background: rgba(255, 255, 255, 0.05);
}

#online-users-list li.selected {
  background: var(--primary-gradient);
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
}

#online-users-list li.selected::before {
  background: #fff;
  box-shadow: none;
}

#online-users-list li.unread::after {
  content: attr(data-unread-count);
  position: absolute;
  right: 15px;
  background: #ff4757;
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(255, 71, 87, 0.4);
}

/* ================= MAIN CHAT AREA ================= */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-header {
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.1);
}

#recipient {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: #fff;
  padding: 0;
  margin: 0;
  width: auto;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
  /* Prevent long names from pushing buttons */
  /* Make it look like a title */
}

/* Mobile Toggle Button */
#sidebar-toggle {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  padding: 5px;
  cursor: pointer;
  display: none;
  /* Hidden on desktop */
  box-shadow: none;
  width: auto;
}

#sidebar-toggle:hover {
  color: #764ba2;
  transform: none;
  background: transparent;
}

#logout-btn {
  width: auto;
  padding: 8px 16px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

#logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: none;
}

.chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border: none;
  background: transparent;
  box-shadow: none;
  margin: 0;
  border-radius: 0;
}

/* Bubbles */
.bubble {
  max-width: 75%;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 4px;
  /* Slight spacing between bubbles */
}

.you {
  align-self: flex-end;
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  /* Tail effect */
  background-attachment: fixed;
  /* Cool gradient effect */
}

.other {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  /* More subtle glass */
  color: white;
  border-bottom-left-radius: 4px;
  /* Tail effect */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bubble strong {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 4px;
  opacity: 0.9;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.8);
}

.time {
  font-size: 0.65rem;
  opacity: 0.6;
  float: right;
  margin-top: 8px;
  margin-left: 12px;
  vertical-align: bottom;
}

/* Read Receipt Ticks */
.tick {
  font-size: 0.7rem;
  margin-left: 4px;
  font-weight: 700;
  letter-spacing: -1px;
  vertical-align: bottom;
}

.tick-sent {
  color: rgba(255, 255, 255, 0.5);
}

.tick-read {
  color: #4fc3f7;
  /* light blue — like WhatsApp */
}

/* Date Separator */
.date-separator {
  align-self: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 20px 0;
}

/* Typing Indicator */
/* Inline Typing Bubble */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  min-width: 60px;
  justify-content: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input Area */
#chat-form {
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 15px;
  align-items: center;
}

#message-input {
  flex: 1;
  margin-bottom: 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#message-input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

#chat-form button {
  width: auto;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}



/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 20px));
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #chat-container {
    flex-direction: column;
    /* Already 100% height/width from main rules */
  }

  /* Sidebar as Overlay/Drawer */
  .online-users-box {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 260px;
    z-index: 100;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding-top: 20px;
  }

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px 15px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
  }

  /* Sidebar Overlay */
  #sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    /* Behind sidebar (100) but above everything else */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  #sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .online-users-box.active {
    transform: translateX(0);
  }



  #online-users-list {
    display: block;
    /* Reset flex from previous mobile style */
  }

  #online-users-list li {
    padding: 15px;
    font-size: 1rem;
    color: #fff;
    /* Ensure text is visible against dark background */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 0;
  }

  .chat-main {
    width: 100%;
    height: 100%;
  }

  .mobile-only {
    display: block;
    margin-right: 15px;
  }

  #sidebar-toggle {
    display: block;
  }

  /* Adjust Chat Header */
  .chat-header {
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(5px);
  }

  #typing-indicator {
    bottom: 85px;
    /* Adjust for mobile input area height */
    left: 15px;
  }
}