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

:root {
  --bg: #090b0f;
  --card-bg: rgba(17, 22, 34, 0.65);
  --sidebar-bg: rgba(10, 13, 20, 0.85);
  --primary: hsl(250, 84%, 58%);
  --primary-hover: hsl(250, 84%, 64%);
  --accent: hsl(290, 80%, 56%);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --bubble-self: linear-gradient(135deg, hsl(250, 70%, 54%) 0%, hsl(265, 75%, 52%) 100%);
  --bubble-other: rgba(30, 41, 59, 0.8);
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-interface: 'Inter', sans-serif;
  --font-title: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

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

/* Background Animated Glows */
body::before, body::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  opacity: 0.15;
}

body::before {
  top: 10%;
  left: 10%;
  background: var(--primary);
}

body::after {
  bottom: 10%;
  right: 10%;
  background: var(--accent);
}

/* App Containers */
.app-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}

/* Auth View Styles */
.auth-view {
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: 2.5rem;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-glow);
  animation: fadeIn 0.4s ease-out;
}

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

.auth-header h1 {
  font-family: var(--font-title);
  font-size: 2.25rem;
  font-weight: 700;
  background: linear-gradient(to right, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-control {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(10, 15, 30, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: var(--transition);
}

.input-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn {
  width: 100%;
  padding: 0.875rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-toggle a {
  color: #818cf8;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.auth-toggle a:hover {
  color: #a5b4fc;
  text-decoration: underline;
}

/* Chat Layout Styles */
.chat-view {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: 320px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 10;
}

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

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.9375rem;
  color: #fff;
}

.username-display {
  font-weight: 500;
  font-size: 0.9375rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.section-title {
  padding: 1.25rem 1.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  margin: 0.125rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

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

.list-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-left: 3px solid #6366f1;
}

.list-item-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  overflow: hidden;
}

.list-item-name {
  font-size: 0.9375rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat Pane */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(13, 17, 26, 0.4);
}

.chat-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 13, 20, 0.3);
}

.room-info h2 {
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 600;
}

.room-info p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-wrapper.self {
  align-self: flex-end;
}

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

.message-sender {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  margin-left: 0.5rem;
}

.message-wrapper.self .message-sender {
  display: none; /* Sender is self, hiding */
}

.message-bubble {
  padding: 0.875rem 1.125rem;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
}

.message-wrapper.self .message-bubble {
  background: var(--bubble-self);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-wrapper.other .message-bubble {
  background: var(--bubble-other);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  align-self: flex-end;
  margin-top: 0.25rem;
  margin-right: 0.5rem;
}

.message-wrapper.self .message-time {
  margin-right: 0.25rem;
}

/* Chat Input Area */
.chat-input-area {
  padding: 1.25rem;
  background: rgba(10, 13, 20, 0.4);
  border-top: 1px solid var(--border);
}

.input-console {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(10, 15, 30, 0.7);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  position: relative;
}

.input-console:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 0.5rem;
}

/* Typography Drawer Styles */
.font-selector-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 280px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-glow);
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 20;
  backdrop-filter: blur(20px);
  animation: popoverFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.font-selector-popover.show {
  display: flex;
}

.popover-header {
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.font-list-items {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.font-option {
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.font-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.font-option.selected {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  font-weight: 500;
}

.btn-upload-font {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  border-radius: 6px;
  color: #818cf8;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-upload-font:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
}

.hidden-file-input {
  display: none;
}

.selected-font-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #818cf8;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes popoverFade {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* Utility Helpers */
.hidden {
  display: none !important;
}

/* Modal Component */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: var(--transition);
}

.modal-content {
  background: #0d111a;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  padding: 2rem;
  box-shadow: var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-title);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: var(--shadow-glow);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), fadeOut 0.5s ease-in forwards;
  animation-delay: 0s, 4.5s;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

.toast-message {
  flex: 1;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .app-container {
    border: none;
  }
  
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .message-wrapper {
    max-width: 85%;
  }
}

/* Admin Typography Manager Styles */
.admin-modal-content {
  max-width: 680px !important;
}

.admin-upload-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-upload-section h4, .admin-list-section h4 {
  font-family: var(--font-title);
  font-size: 1rem;
  margin-bottom: 1rem;
  color: #818cf8;
}

.admin-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.admin-upload-form .input-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.admin-upload-form button {
  height: 42px;
  padding: 0 1.25rem;
  width: auto;
}

.admin-fonts-table-wrapper {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(10, 15, 30, 0.4);
}

.admin-fonts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.admin-fonts-table th, .admin-fonts-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-fonts-table th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  color: var(--text-muted);
}

.admin-fonts-table tr:last-child td {
  border-bottom: none;
}

.admin-font-row-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  border: none;
  font-family: var(--font-title);
  transition: var(--transition);
}

.btn-small-edit {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

.btn-small-edit:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: #6366f1;
}

.btn-small-delete {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.btn-small-delete:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

.inline-edit-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.inline-edit-input {
  flex: 1;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  background: rgba(10, 15, 30, 0.8);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}

/* Discover/Join items listing inside modals */
.available-items-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(10, 15, 30, 0.4);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.discover-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: var(--transition);
}

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

.discover-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-discover-action {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-title);
  transition: var(--transition);
}

.btn-discover-action:hover {
  background: var(--primary-hover);
}

/* Alpha / Development Warning Elements */
.badge-alpha {
  font-family: var(--font-title);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
  display: inline-block;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

.alpha-disclaimer-card {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #fca5a5;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.alpha-disclaimer-card svg {
  flex-shrink: 0;
  color: #fca5a5;
  margin-top: 0.1rem;
}

.sidebar-alpha-warning {
  background: rgba(249, 115, 22, 0.06);
  border-bottom: 1px solid rgba(249, 115, 22, 0.15);
  padding: 0.625rem 1rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #ffedd5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-alpha-warning svg {
  flex-shrink: 0;
  color: #fb923c;
}



