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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --bg-light: #1e293b;
  --bg-lighter: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow: rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: var(--bg-darker);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

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

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-icon {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.25rem;
}

.btn-icon:hover {
  background: var(--bg-lighter);
  color: var(--text-primary);
}

/* Landing Page */
.landing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-darker) 0%, #1e293b 100%);
}

.landing-container {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
  animation: fadeInUp 0.5s ease;
}

.landing-container h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

#username-input {
  padding: 0.875rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

#username-input:focus {
  outline: none;
  border-color: var(--primary);
}

.info-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Main App */
.main-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header h1 {
  font-size: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.username {
  font-weight: 600;
  color: var(--text-primary);
}

.status-indicator {
  font-size: 1.25rem;
  line-height: 1;
}

.status-indicator.active {
  color: var(--success);
}

.status-indicator.afk {
  color: var(--warning);
}

/* App Container */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

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

.sidebar-header h2 {
  font-size: 1.125rem;
}

.games-list {
  flex: 1;
  overflow-y: auto;
}

.game-item {
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}

.game-item:hover {
  background: var(--bg-light);
}

.game-item.active {
  background: var(--bg-light);
  border-left-color: var(--primary);
}

.game-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.game-item-icon {
  font-size: 1.25rem;
}

.game-item-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.game-item-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 2rem;
}

.sidebar-section {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.activity-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--primary);
}

/* Main Panel */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-darker);
}

.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.welcome-content {
  text-align: center;
  max-width: 600px;
  padding: 2rem;
}

.welcome-content h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.welcome-content > p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin-bottom: 3rem;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.feature {
  padding: 1.5rem;
  background: var(--bg-dark);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.feature-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.feature h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.feature p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Game View */
.game-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}

.game-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.game-icon {
  font-size: 2rem;
}

.game-title h2 {
  font-size: 1.5rem;
}

.users-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.trades-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.trades-filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.trades-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.trade-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.15s ease;
  cursor: pointer;
  animation: fadeIn 0.3s ease;
}

.trade-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.trade-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.75rem;
}

.trade-type {
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.trade-type.WTS {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.trade-type.WTB {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.trade-type.WTT {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.trade-author {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.author-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.author-status.afk {
  background: var(--warning);
}

.trade-item {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.trade-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.trade-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.trade-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.offers-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-light);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 1rem;
  font-size: 0.875rem;
}

/* Right Panel */
.right-panel {
  width: 320px;
  background: var(--bg-dark);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.875rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s ease;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  display: none;
}

.tab-content.active {
  display: block;
}

.my-trades-list,
.threads-list {
  padding: 0.5rem;
}

.my-trade-item,
.thread-item {
  padding: 1rem;
  background: var(--bg-light);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.my-trade-item:hover,
.thread-item:hover {
  background: var(--bg-lighter);
  border-color: var(--primary);
}

.my-trade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.my-trade-item-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.my-trade-game {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.my-trade-offers {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.offers-badge {
  background: var(--primary);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
}

.thread-partner {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.thread-trade-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.thread-last-message {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s ease-in-out infinite;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-dark);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px var(--shadow);
  animation: slideUp 0.3s ease;
}

.modal-large .modal-content {
  max-width: 600px;
}

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

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-lighter);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

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

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

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

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.trade-type-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.trade-type-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

.trade-type-btn:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

.trade-type-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.trade-info-preview {
  padding: 1rem;
  background: var(--bg-darker);
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

/* Chat */
.chat-trade-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.chat-body {
  display: flex;
  flex-direction: column;
  max-height: 500px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-darker);
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: fadeIn 0.2s ease;
}

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

.chat-message.theirs {
  align-self: flex-start;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

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

.chat-message.theirs .message-bubble {
  background: var(--bg-light);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

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

#chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 0.9375rem;
}

#chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Notifications */
.notifications {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.notification {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
  animation: slideInRight 0.3s ease;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.notification:hover {
  transform: translateX(-4px);
}

.notification.success {
  border-left: 4px solid var(--success);
}

.notification.error {
  border-left: 4px solid var(--danger);
}

.notification.info {
  border-left: 4px solid var(--primary);
}

.notification.warning {
  border-left: 4px solid var(--warning);
}

.notification-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.notification-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

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

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

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

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-lighter);
  border-radius: 4px;
}

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

/* Mobile Responsive */
@media (max-width: 1024px) {
  .right-panel {
    display: none;
  }

  .trades-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main-panel {
    flex: 1;
  }

  .trades-list {
    grid-template-columns: 1fr;
  }

  .game-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .game-title {
    flex-wrap: wrap;
  }

  #create-trade-btn {
    width: 100%;
  }

  .notifications {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0.5rem 1rem;
  }

  .app-header h1 {
    font-size: 1.125rem;
  }

  .landing-container h1 {
    font-size: 2rem;
  }

  .trades-filter {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}
