/* Fockus Chat — Dark Theme */

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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-input: #1e2a45;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b8;
  --text-muted: #6c6c80;
  --accent: #0f3460;
  --accent-hover: #1a4a7a;
  --accent-light: #1e5a9a;
  --bubble-own: #0f3460;
  --bubble-other: #2a2a40;
  --bubble-system: transparent;
  --border: #2a2a40;
  --danger: #c0392b;
  --danger-hover: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: 200ms ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* -- Reconnect Banner -- */

.reconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--warning);
  color: #1a1a2e;
  text-align: center;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.875rem;
  transform: translateY(-100%);
  transition: transform var(--transition);
}

.reconnect-banner.visible {
  transform: translateY(0);
}

/* -- Screens -- */

.screen {
  display: none;
}

.screen.active {
  display: flex;
}

/* -- Login Screen -- */

.screen-login {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  text-align: center;
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: var(--accent-light);
}

.form-error {
  color: var(--danger-hover);
  font-size: 0.8125rem;
  margin-top: 6px;
  min-height: 1.2em;
}

/* -- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  min-height: 44px;
  min-width: 44px;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-danger:hover:not(:disabled) {
  color: var(--danger-hover);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
  font-family: var(--font);
  font-size: 1rem;
}

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

.btn-icon:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* -- Lobby Screen -- */

.screen-lobby {
  flex-direction: column;
  min-height: 100vh;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lobby-header .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
}

.lobby-header .user-nick {
  font-weight: 600;
  color: var(--text-primary);
}

.lobby-body {
  flex: 1;
  padding: 20px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.lobby-body h2 {
  font-size: 1.125rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-light);
}

.room-item:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.room-item .room-name {
  font-weight: 500;
}

.room-item .room-count {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 10px;
  border-radius: 12px;
}

.room-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 0.9375rem;
}

/* -- Create Room -- */

.create-room-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.create-room-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.create-room-form input:focus {
  border-color: var(--accent-light);
}

/* -- Chat Screen -- */

.screen-chat {
  flex-direction: column;
  height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header .room-title {
  flex: 1;
  font-weight: 600;
  font-size: 1.0625rem;
}

.chat-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.chat-messages-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 0.9375rem;
  line-height: 1.45;
  animation: msg-in 200ms ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .msg,
  .reconnect-banner {
    animation: none;
    transition: none;
  }
}

.msg-own {
  align-self: flex-end;
  background: var(--bubble-own);
  border-bottom-right-radius: 4px;
}

.msg-other {
  align-self: flex-start;
  background: var(--bubble-other);
  border-bottom-left-radius: 4px;
}

.msg-system {
  align-self: center;
  background: var(--bubble-system);
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8125rem;
  max-width: 100%;
  padding: 4px 0;
}

.msg .msg-author {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
  font-weight: 500;
}

.msg .msg-text {
  color: var(--text-primary);
}

.msg-system .msg-text {
  color: var(--text-muted);
}

.msg .msg-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: right;
}

/* -- Typing Indicator -- */

.typing-indicator {
  padding: 4px 20px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 24px;
  flex-shrink: 0;
}

/* -- Chat Input -- */

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.chat-input-area input:focus {
  border-color: var(--accent-light);
}

/* -- Sidebar -- */

.chat-sidebar {
  width: 200px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.chat-sidebar h3 {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-list li {
  font-size: 0.875rem;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* -- Sidebar Toggle (Mobile) -- */

.sidebar-toggle {
  display: none;
}

/* -- Responsive -- */

@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 240px;
    z-index: 100;
    transform: translateX(100%);
    transition: transform var(--transition);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.4);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .msg {
    max-width: 85%;
  }

  .login-card {
    padding: 28px 20px;
  }

  .lobby-body {
    padding: 16px;
  }
}

/* -- Scrollbar -- */

::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* -- Utility -- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
