/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
  font-family: system-ui, sans-serif;
  background-color: #0E1017;
  color: #fff;
}

body {
  display: flex;
  flex-direction: column;
}

:root {
  --bg-primary: #0E1017;
  --bg-secondary: #1B1F2E;
  --bg-tertiary: #252a3a;
  --border-color: #2A2F40;
  --text-primary: #fff;
  --text-secondary: #cfd6e0;
  --text-muted: #888;
  --accent-primary: #7ec4ff;
  --accent-success: #00dfc4;
  --accent-warning: #ff9800;
  --accent-danger: #f44336;
  --accent-info: #7ec4ff;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout containers */
/* Only apply normal container styles when NOT on trade builder */
.main-container:not(.trade-builder-active) {
  flex: 1;
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1em 1em 2em 1em;
}


.main-container.trade-builder-active {
  padding: 0;
  max-width: none;
  flex: 1;
  display: flex;
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Header */
header {
  background-color: var(--bg-secondary);
  padding: 0.75em 2em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: none; /* Hidden by default */
}

header.show {
  display: block;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 1em;
}

/* League Dropdown Styles */
.league-dropdown-container {
  position: relative;
  display: flex;
  justify-content: center;
}

.league-dropdown-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5em 1em;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75em;
  font-size: 1.4em;
  font-weight: 600;
  transition: all 0.2s;
}

.league-dropdown-btn:hover {
  border-color: var(--accent-primary);
  background-color: rgba(126, 196, 255, 0.1);
}

.league-dropdown-btn img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

.dropdown-arrow {
  font-size: 0.8em;
  transition: transform 0.2s;
  margin-left: auto;
}

.league-dropdown-btn.open .dropdown-arrow {
  transform: rotate(180deg);
}

.league-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  margin-top: 0.5em;
}

.league-dropdown-menu.open {
  display: block;
}

.league-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.75em 1em;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.league-dropdown-item:hover {
  background-color: var(--bg-tertiary);
}

.league-dropdown-item:last-child {
  border-bottom: none;
}

.league-dropdown-item.active {
  background-color: rgba(0, 223, 196, 0.1);
  border-left: 3px solid var(--accent-success);
}

.league-dropdown-item.has-new-messages::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent-danger);
  border-radius: 50%;
  margin-left: auto;
}

.league-dropdown-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}

.league-dropdown-name {
  font-weight: 500;
  color: var(--text-primary);
}

/* User Menu */
.user-menu-container {
  position: absolute;
  right: 0;
}

.user-menu-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4em 0.75em;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s;
}

.user-menu-btn:hover {
  border-color: var(--accent-primary);
  background-color: rgba(126, 196, 255, 0.1);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-display-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-btn .dropdown-arrow {
  font-size: 0.7em;
  margin-left: 0.25em;
}

.user-menu-btn.open .dropdown-arrow {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5em);
  right: 0;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1001;
}

.user-menu-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-item {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 0.75em 1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75em;
  font-size: 0.9em;
  transition: background-color 0.2s;
  text-align: left;
}

.user-menu-item:hover {
  background-color: rgba(126, 196, 255, 0.1);
}

.user-menu-item.logout-item {
  color: var(--accent-danger);
}

.user-menu-item.logout-item:hover {
  background-color: rgba(244, 67, 54, 0.1);
}

.menu-item-icon {
  font-size: 1.1em;
}

.logout-btn {
  position: absolute;
  right: 0;
  color: var(--accent-danger);
  background: none;
  border: 1px solid var(--accent-danger);
  padding: 0.5em 1em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.logout-btn:hover {
  background-color: rgba(244, 67, 54, 0.1);
}

.back-link {
  position: absolute;
  right: 0;
  color: var(--accent-primary);
  text-decoration: none;
  padding: 0.5em 1em;
  border: 1px solid var(--accent-primary);
  border-radius: 6px;
  transition: background-color 0.2s;
}

.back-link:hover {
  background-color: rgba(126, 196, 255, 0.1);
  text-decoration: none;
}

/* Footer */
footer {
  margin-top: auto;
  padding: 2em;
  text-align: center;
  background-color: var(--bg-secondary);
}

footer p {
  font-size: 0.85em;
  color: var(--text-muted);
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.4em;
}

/* Tab Navigation */
.tab-navigation {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1em 2em 0 2em;
  display: flex;
  gap: 1em;
  border-bottom: 2px solid var(--border-color);
}

.tab-button {
  padding: 0.75em 1.5em;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1em;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--accent-primary);
}

.tab-button.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* Ensure tab content is properly hidden by default */
.tab-content {
  display: none !important;
}

.tab-content.active {
  display: block !important;
}



/* Loading & Error States */
.loading {
  text-align: center;
  padding: 3em;
  color: var(--text-muted);
}

.error-message {
  background-color: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
  color: var(--accent-danger);
  padding: 1em;
  border-radius: 8px;
  margin-bottom: 1.5em;
  text-align: center;
}

/* Responsive */
@media (max-width: 1200px) {
  .main-container {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .main-container {
    padding: 0.25em;
  }
}