:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(20, 25, 40, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f0f4f8;
  --text-muted: #94a3b8;
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #ec4899;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --glass-blur: blur(16px);
  --font-main: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Animated Background --- */
.background-orbs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(99,102,241,0.4) 0%, rgba(11,15,25,0) 70%);
}

.orb-2 {
  bottom: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(236,72,153,0.3) 0%, rgba(11,15,25,0) 70%);
  animation-delay: -5s;
}

.orb-3 {
  top: 40%;
  left: 40%;
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, rgba(11,15,25,0) 70%);
  animation-duration: 25s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 50px) scale(1.1); }
}

/* --- UI Components --- */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
  border-radius: 8px;
}

input[type="text"], input[type="file"] {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
  font-family: var(--font-main);
  font-size: 1rem;
  transition: all 0.2s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* --- Home Page --- */
.home-body {
  justify-content: center;
  align-items: center;
}

.home-container {
  width: 100%;
  max-width: 500px;
  padding: 3rem;
  text-align: center;
}

.home-header {
  margin-bottom: 2.5rem;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--primary-color);
}

.home-header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.input-group {
  text-align: left;
  margin-bottom: 2rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.action-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 16px;
  text-align: left;
}

.action-card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.action-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.join-input-group {
  display: flex;
  gap: 0.5rem;
}

.divider {
  position: relative;
  text-align: center;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.divider span {
  position: relative;
  background: var(--panel-bg);
  padding: 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

/* --- Room Page --- */
.room-body {
  height: 100vh;
  padding: 1.5rem;
}

.room-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.room-id-badge {
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: bold;
  border: 1px dashed rgba(99, 102, 241, 0.5);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.room-id-badge:hover {
  background: rgba(99, 102, 241, 0.2);
}

.room-controls {
  display: flex;
  gap: 1rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 1.5rem;
  flex: 1;
  height: calc(100vh - 120px);
}

/* Chat Section */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: slideIn 0.3s ease;
}

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

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

.message-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  gap: 0.5rem;
}

.message.self .message-meta {
  justify-content: flex-end;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}

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

.message.other .message-bubble {
  background: rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
}

.system-message {
  align-self: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  margin: 0.5rem 0;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--panel-border);
}

.chat-form {
  display: flex;
  gap: 0.75rem;
}

.chat-form input {
  flex: 1;
}

/* Files Section */
.files-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.files-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
}

.upload-zone {
  margin: 1.5rem;
  padding: 2rem 1rem;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary-color);
  background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

#fileInput {
  display: none;
}

.files-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  gap: 1rem;
  animation: fadeIn 0.3s ease;
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon.img-preview {
  background-size: cover;
  background-position: center;
}

.file-icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-action {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.file-action:hover {
  background: var(--primary-color);
}

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

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1.5rem;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: auto;
  }
  
  .room-body {
    height: auto;
    min-height: 100vh;
  }
  
  .chat-container, .files-container {
    height: 500px;
  }
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
  font-family: var(--font-main);
}

.footer-name {
  color: var(--primary-color);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.footer-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
