/* ═══════════════════════════════════════════════════════════
   Elegant Chat - CSS Styles
   Warm, vintage-modern aesthetic
   ═══════════════════════════════════════════════════════════ */

/* CSS Variables */
:root {
  /* Colors - Warm palette */
  --bg-primary: #f8f6f1;
  --bg-secondary: #fffdf8;
  --bg-tertiary: #f0ede5;
  --bg-dark: #2a2a28;
  --bg-dark-secondary: #3a3a38;
  
  --text-primary: #2a2a28;
  --text-secondary: #5a5a58;
  --text-muted: #8a8a88;
  --text-light: #f8f6f1;
  
  --accent: #8b7355;
  --accent-hover: #a08465;
  --accent-dark: #6b5a45;
  
  --border: #e5e2db;
  --border-dark: #d5d2cb;
  
  --success: #5a8a5a;
  --error: #a05050;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(42, 42, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(42, 42, 40, 0.08);
  --shadow-lg: 0 8px 30px rgba(42, 42, 40, 0.12);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
  
  /* Spacing */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Typography */
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.2;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

p { color: var(--text-secondary); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--accent-hover); }

/* ═══════════════════════════════════════════════════════════
   Landing Page
   ═══════════════════════════════════════════════════════════ */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.25rem 2rem;
  background: rgba(248, 246, 241, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: transform var(--transition-normal);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--accent);
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
}

/* Hero Section */
.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8rem 2rem 4rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(139, 115, 85, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 115, 85, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  max-width: 800px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.hero-label-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hero h1 {
  margin-bottom: 1.5rem;
  letter-spacing: -0.03em;
}

.hero h1 span {
  color: var(--accent);
  font-style: italic;
}

.hero-description {
  font-size: 1.125rem;
  max-width: 560px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-light);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--border-dark);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* Features Section */
.features {
  padding: 6rem 2rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.features-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 4rem;
}

.section-header h2 {
  margin-bottom: 1rem;
}

.section-header p {
  max-width: 500px;
  margin: 0 auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  padding: 2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
}

.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  width: 48px;
  height: 48px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.feature-card h3 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.feature-card p {
  font-size: 0.95rem;
}

/* Rooms Preview */
.rooms-preview {
  padding: 6rem 2rem;
  border-top: 1px solid var(--border);
}

.rooms-preview-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}

.room-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.room-card:hover {
  border-color: var(--accent);
  background: var(--bg-primary);
}

.room-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.room-info {
  flex: 1;
  min-width: 0;
}

.room-info h4 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.room-info p {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.room-users {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   Chat Page
   ═══════════════════════════════════════════════════════════ */

.chat-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Join Screen */
.join-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.join-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.join-header {
  text-align: center;
  margin-bottom: 2rem;
}

.join-header .logo-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  color: var(--accent);
}

.join-header h2 {
  margin-bottom: 0.5rem;
}

.join-header p {
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 0.5rem;
}

.room-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.room-option {
  padding: 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.room-option:hover {
  border-color: var(--border-dark);
}

.room-option.selected {
  border-color: var(--accent);
  background: rgba(139, 115, 85, 0.05);
}

.room-option-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.room-option-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.join-card .btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 1rem;
}

/* Chat Layout */
.chat-container {
  display: none;
  height: 100vh;
}

.chat-container.active {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-dark);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--bg-dark-secondary);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-hover);
}

.sidebar-logo .logo-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-light);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-dark-secondary);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}

.sidebar-section {
  padding: 1rem 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-rooms {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-room {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-room:hover {
  background: var(--bg-dark-secondary);
}

.sidebar-room.active {
  background: rgba(139, 115, 85, 0.2);
}

.sidebar-room-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.sidebar-room.active .sidebar-room-icon {
  color: var(--accent-hover);
}

.sidebar-room-name {
  flex: 1;
  font-size: 0.875rem;
}

.sidebar-room-count {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg-dark-secondary);
  border-radius: 100px;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bg-dark-secondary);
}

.btn-leave {
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--bg-dark-secondary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-leave:hover {
  background: var(--bg-dark-secondary);
  color: var(--text-light);
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

.chat-header {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-room-info h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.chat-room-info p {
  font-size: 0.85rem;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-only:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-icon-only svg {
  width: 18px;
  height: 18px;
}

/* Members Panel */
.members-panel {
  display: none;
  width: 240px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  flex-direction: column;
}

.members-panel.open {
  display: flex;
}

.members-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.members-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius-sm);
}

.member-avatar {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.member-name {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.member-item.is-you .member-name {
  font-weight: 500;
}

.member-item.is-you .member-name::after {
  content: ' (you)';
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Messages Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
}

.messages-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.messages-empty p {
  font-size: 0.95rem;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 680px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.message-author {
  font-weight: 500;
  font-size: 0.9rem;
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  word-wrap: break-word;
}

.message.own {
  flex-direction: row-reverse;
}

.message.own .message-header {
  flex-direction: row-reverse;
}

.message.own .message-text {
  color: var(--text-primary);
}

/* System Messages */
.message.system {
  justify-content: center;
  padding: 0.5rem 0;
}

.message.system .message-content {
  text-align: center;
}

.message.system .message-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Private Messages */
.message.private .message-text {
  background: rgba(139, 115, 85, 0.1);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
}

/* Typing Indicator */
.typing-indicator {
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 32px;
}

/* Message Input */
.message-input-container {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.message-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.message-input {
  flex: 1;
  padding: 0.875rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: none;
  min-height: 48px;
  max-height: 150px;
  transition: border-color var(--transition-fast);
}

.message-input:focus {
  outline: none;
  border-color: var(--accent);
}

.message-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--text-light);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send svg {
  width: 20px;
  height: 20px;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .nav {
    display: none;
  }
  
  .hero {
    padding: 7rem 1.5rem 3rem;
  }
  
  .hero-actions {
    flex-direction: column;
  }
  
  .hero-actions .btn {
    width: 100%;
  }
  
  .features, .rooms-preview {
    padding: 4rem 1.5rem;
  }
  
  .room-select {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
  }
  
  .sidebar-overlay.open {
    display: block;
  }
  
  .members-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
  }
  
  .members-panel.open {
    transform: translateX(0);
  }
  
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
  }
  
  .btn-menu {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  
  .btn-menu svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
  }
}

@media (min-width: 769px) {
  .mobile-header {
    display: none;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-up {
  animation: slideUp 0.4s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}