/*
 * Standalone Chat Application Styles (chat-styles.css)
 */

:root {
  --bg: #0b0f19;
  --panel: #101625;
  --panel-2: #182033;
  --line: rgba(255, 255, 255, 0.1);
  --ink: #f3f4f6;
  --muted: #9ca3af;
  --accent: #4f9cf9;
  --accent-2: #5ee0c0;
  --danger: #ef4b5e;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef2f9;
  --line: #cbd5e1;
  --ink: #111827;
  --muted: #4b5563;
  --accent: #2563eb;
  --accent-2: #059669;
  --danger: #dc2626;
}

.theme-toggle-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-toggle-btn:hover {
  border-color: var(--accent);
}

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

body, html {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  overflow: hidden;
}

.chat-app-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- AUTHENTICATION SCREEN ---------- */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(79, 156, 249, 0.15), transparent 50%),
              radial-gradient(circle at bottom left, rgba(94, 224, 192, 0.1), transparent 50%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 12px var(--accent-2);
}
.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.auth-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.auth-card p.muted {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 20px;
}
.auth-tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth-tab-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.field input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
}

.btn-primary {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4a75f5);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-primary:hover {
  filter: brightness(1.1);
}

.auth-notice {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  font-size: 12.5px;
  background: rgba(79, 156, 249, 0.15);
  border: 1px solid var(--accent);
  color: var(--ink);
  word-break: break-all;
}
.status-msg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* ---------- WORKSPACE SCREEN ---------- */
.workspace-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-navbar {
  height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.online-status-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(94, 224, 192, 0.12);
  padding: 3px 10px;
  border-radius: 999px;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
  transition: all 0.2s ease;
}
.header-status-dot.online {
  background: #10b981;
  color: #10b981;
}
.header-status-dot.offline {
  background: #9ca3af;
  color: #9ca3af;
}

.user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.btn-logout {
  background: rgba(239, 75, 94, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 75, 94, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover {
  background: var(--danger);
  color: #fff;
}

/* Workspace Layout */
.chat-workspace-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.contacts-sidebar {
  width: 320px;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.contacts-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.contacts-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.contacts-count {
  font-size: 12px;
  color: var(--muted);
}

.contact-search-box {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contact-search-box input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
}

.btn-global-search {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(79, 156, 249, 0.15);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}
.btn-global-search:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Pending Requests Section */
.pending-requests-box {
  padding: 12px;
  background: rgba(94, 224, 192, 0.08);
  border-bottom: 1px solid var(--line);
}
.pending-requests-title {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-2);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.pending-requests-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pending-card {
  padding: 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pending-card-info {
  display: flex;
  flex-direction: column;
}
.pending-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.pending-card-phone {
  font-size: 11.5px;
  color: var(--muted);
}
.pending-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.btn-accept {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: #10b981;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-decline {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-invite-action {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-invite-action:hover {
  filter: brightness(1.1);
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.contact-card:hover {
  background: rgba(255, 255, 255, 0.05);
}
.contact-card.active {
  background: rgba(79, 156, 249, 0.15);
  border: 1px solid rgba(79, 156, 249, 0.3);
}

.contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6f7cf9);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--panel-2);
}
.status-indicator.online { background: #10b981; }
.status-indicator.offline { background: #6b7280; }

.contact-info {
  flex: 1;
  min-width: 0;
}
.contact-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Conversation Area */
.conversation-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  min-width: 0;
}

.placeholder-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}
.placeholder-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.placeholder-view h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.placeholder-view p {
  max-width: 400px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.placeholder-view .muted-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--accent-2);
}

.active-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.contact-chat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.btn-back-mobile {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.active-contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.active-contact-meta {
  display: flex;
  flex-direction: column;
}
.active-contact-name {
  font-size: 15px;
  font-weight: 700;
}
.active-contact-status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online { background: #10b981; }
.status-dot.offline { background: #6b7280; }

.chat-log-box {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.direct-msg-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.direct-msg-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #4a75f5);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.direct-msg-bubble.peer {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.direct-msg-meta {
  font-size: 10.5px;
  margin-top: 6px;
  opacity: 0.8;
  text-align: right;
}

.chat-input-form {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.chat-input-form input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.chat-input-form input:focus {
  border-color: var(--accent);
}

.btn-send {
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-send:hover {
  filter: brightness(1.1);
}

@media (max-width: 640px) {
  .contacts-sidebar { width: 100%; }
  .conversation-main { display: none; }
  .chat-workspace-layout.chat-active .contacts-sidebar { display: none; }
  .chat-workspace-layout.chat-active .conversation-main { display: flex; }
  .btn-back-mobile { display: block; }
}
