@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0b0e;
  --bg-secondary: #12131a;
  --bg-tertiary: #1a1b24;
  --glass-bg: rgba(18, 19, 26, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-hover: #4f46e5;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Glassmorphism App Wrapper */
#app-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Auth Screens styling */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.1), transparent 40%),
              var(--bg-primary);
  z-index: 10;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  border-radius: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 15px var(--accent-glow));
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: var(--transition-smooth);
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

.auth-toggle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 24px;
}

.auth-toggle span {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.auth-toggle span:hover {
  text-decoration: underline;
}

/* Chat Main Layout */
#chat-workspace {
  display: flex;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  min-height: 0;
}

/* Sidebar styling */
#sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  position: relative;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.avatar.status-online::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background-color: var(--success);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

.avatar.status-away::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background-color: var(--warning);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

.avatar-info {
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-weight: 600;
  font-size: 14px;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-status {
  font-size: 11px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.sidebar-nav {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-item:hover, .nav-item.active {
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 16px 16px 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-bottom: 4px;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.list-item.active {
  background: rgba(99, 102, 241, 0.12);
}

.list-item-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.list-item.active .list-item-title {
  color: var(--accent);
  font-weight: 600;
}

.list-item-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-badge {
  background-color: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Chat Main Viewport */
#chat-viewport {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  min-height: 0;
}

#active-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  min-height: 0;
}

.chat-header {
  height: 70px;
  padding: 0 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

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

.chat-title {
  font-weight: 600;
  font-size: 16px;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* Message Bubbles */
.message-row {
  display: flex;
  gap: 12px;
  max-width: 75%;
}

.message-row.incoming {
  align-self: flex-start;
}

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}

.incoming .message-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.outgoing .message-bubble {
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: white;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.outgoing .message-meta {
  color: rgba(255, 255, 255, 0.7);
  justify-content: flex-end;
}

.sender-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* Chat Input Bar */
.chat-footer {
  padding: 16px 24px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--glass-border);
}

.composer-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 16px;
  transition: var(--transition-smooth);
}

.composer-container:focus-within {
  border-color: var(--accent);
}

.composer-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 0;
  resize: none;
  max-height: 100px;
}

/* Modal styling */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Selector list inside modals */
.user-select-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--bg-tertiary);
  padding: 8px;
}

.user-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.user-select-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Custom layout logic for narrow viewports */
@media (max-width: 600px) {
  #sidebar {
    width: 100%;
  }
  
  #chat-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #chat-workspace.chat-active #chat-viewport {
    transform: translateX(0);
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Drag and Drop File Sharing Overlay */
#drag-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 11, 14, 0.92);
  backdrop-filter: blur(8px);
  z-index: 90;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  pointer-events: none; /* Let drag/drop bubble up */
  transition: opacity 0.2s ease;
}

#drag-drop-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.drag-drop-box {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(99, 102, 241, 0.03);
  text-align: center;
}

.drag-drop-box h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.drag-drop-box p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Upload Progress Bar */
#upload-progress-container {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

#upload-progress-text {
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

#upload-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width 0.1s linear;
}

/* File Attachment Cards in Messages */
.file-attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 10px 14px;
  border-radius: 12px;
  margin-top: 8px;
  max-width: 280px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-smooth);
}

.file-attachment-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

.incoming .file-attachment-card {
  background: var(--bg-primary);
}

.file-attachment-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-grow: 1;
}

.file-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.file-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.image-attachment {
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  margin-top: 8px;
  display: block;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: opacity 0.2s;
}

.image-attachment:hover {
  opacity: 0.9;
}

/* Links in Messages */
.message-link {
  color: #a5b4fc; /* Light indigo */
  text-decoration: underline;
  word-break: break-all;
}

.outgoing .message-link {
  color: #ffffff; /* White link on outgoing */
  text-decoration: underline;
}

/* Link Preview Cards */
.link-preview-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 10px 12px;
  border-radius: 12px;
  margin-top: 8px;
  max-width: 320px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-smooth);
}

.link-preview-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

.incoming .link-preview-card {
  background: var(--bg-primary);
}

.outgoing .link-preview-card {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.1);
}

.link-preview-favicon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
}

.link-preview-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-grow: 1;
}

.link-preview-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-preview-url {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.outgoing .link-preview-url {
  color: rgba(255, 255, 255, 0.7);
}

/* Unread Messages Indicator Dot */
.unread-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent);
  margin-left: 8px;
}

