html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.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;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===================== AUTH PAGES ===================== */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.8rem;
}

.auth-header .chat-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  font-style: normal;
}

.auth-header h2 {
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.auth-header p {
  color: #64748b;
  margin: 0;
}

.auth-card .form-group {
  margin-bottom: 1.2rem;
}

.auth-card label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.4rem;
  display: block;
}

.auth-card .form-control {
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  transition: border-color .2s;
}

.auth-card .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.btn-block {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: #6b7280;
}

.auth-footer a {
  color: #3b82f6;
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* ===================== HOME PAGE ===================== */
.home-hero {
  padding: 4rem 1rem;
}

.hero-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.features {
  margin-top: 3rem;
}

.feature-item {
  padding: 1.5rem;
  border-radius: 12px;
  background: #f8fafc;
  margin: 0.5rem;
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ===================== CHAT PAGE ===================== */
.chat-body {
  margin: 0;
  padding: 0;
  background: #f1f5f9;
  height: 100vh;
  overflow: hidden;
}

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

/* Sidebar */
.chat-sidebar {
  width: 280px;
  min-width: 240px;
  background: #1e293b;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.current-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.current-user-info .username {
  font-weight: 700;
  font-size: 0.95rem;
}

.current-user-info .status {
  font-size: 0.75rem;
  color: #22c55e;
}

.btn-logout {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}

.btn-logout:hover {
  color: #f87171;
  background: rgba(248,113,113,0.1);
}

.sidebar-search {
  padding: 0.75rem 1rem;
  background: #1e293b;
}

.search-input {
  width: 100%;
  background: #334155;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: #f1f5f9;
  font-size: 0.875rem;
  outline: none;
}

.search-input::placeholder { color: #94a3b8; }

.users-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
}

.users-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.users-list::-webkit-scrollbar { width: 4px; }
.users-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.user-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: background .15s;
  border-radius: 0;
}

.user-item:hover { background: #334155; }
.user-item.active { background: #3b82f6; }

.user-item-info { flex: 1; min-width: 0; }

.user-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-item-status {
  font-size: 0.72rem;
  color: #9ca3af;
}

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.avatar-xs {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

/* Main chat */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  gap: 0.5rem;
}

.empty-icon { font-size: 4rem; }

.chat-header {
  display: flex;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.chat-partner-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.partner-name {
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
}

.partner-status {
  font-size: 0.78rem;
  color: #9ca3af;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.message-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 75%;
}

.message-wrapper.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-wrapper.theirs {
  align-self: flex-start;
}

.message-bubble {
  border-radius: 18px;
  padding: 0.6rem 1rem;
  max-width: 100%;
  word-break: break-word;
}

.bubble-mine {
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble-theirs {
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.message-text { font-size: 0.92rem; line-height: 1.4; }

.message-time {
  font-size: 0.68rem;
  margin-top: 0.2rem;
  opacity: 0.7;
  text-align: right;
}

/* Input area */
.chat-input-area {
  padding: 0.9rem 1.25rem;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

.input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #f1f5f9;
  border-radius: 24px;
  padding: 0.35rem 0.5rem 0.35rem 1rem;
}

.message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: #1e293b;
}

.message-input::placeholder { color: #9ca3af; }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background .2s;
  flex-shrink: 0;
}

.send-btn:hover { background: #2563eb; }
.send-btn:disabled { background: #94a3b8; cursor: not-allowed; }
