/* Color tokens. Every color below is keyed off these variables so the whole
   page can be re-themed by flipping a single set of values — matching how the
   landing page (index.html) and the <power-strip> component theme themselves.
   The light palette is the default; the dark overrides are driven by the
   user's OS color-scheme preference, with a [data-theme] escape hatch so a
   page (or the power strip) can force a theme at runtime. */
:root {
  --bg: #f9f9f9;
  --surface: #fff;
  --surface-muted: #f8f9fa;
  --surface-alt: #f1f3f4;
  --hover-bg: #f0f0f0;
  --text: #333;
  --text-secondary: #555;
  --text-faint: #666;
  --text-muted: #717171;
  --border: #ddd;
  --border-light: #eee;
  --accent: #ffcc00;
  --accent-hover: #e6b800;
  --accent-text: #826700;
  --accent-soft-bg: #fff7d6;
  --on-accent: #202124;
  --muted-badge-text: #5f6368;
  --danger: #d93025;
  --danger-hover: #ea4335;
  --danger-soft-bg: #fce8e6;
  --disabled-bg: #ccc;
  --avatar-remove-bg: #727579;
  --avatar-remove-icon: #fff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1a1a;
    --surface: #2d2d2d;
    --surface-muted: #333;
    --surface-alt: #3c4043;
    --hover-bg: #3c4043;
    --text: #e0e0e0;
    --text-secondary: #c0c0c0;
    --text-faint: #bdc1c6;
    --text-muted: #9aa0a6;
    --border: #5f6368;
    --border-light: #444;
    --accent: #ffcc00;
    --accent-hover: #e6b800;
    --accent-text: #ffcc00;
    --accent-soft-bg: #3a3320;
    --on-accent: #202124;
    --muted-badge-text: #a8adb2;
    --danger: #f28b82;
    --danger-hover: #ee675c;
    --danger-soft-bg: #3c2a28;
    --disabled-bg: #5f6368;
    --avatar-remove-bg: #5f6368;
    --avatar-remove-icon: #e0e0e0;
  }
}

[data-theme='dark'] {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --surface-muted: #333;
  --surface-alt: #3c4043;
  --hover-bg: #3c4043;
  --text: #e0e0e0;
  --text-secondary: #c0c0c0;
  --text-faint: #bdc1c6;
  --text-muted: #9aa0a6;
  --border: #5f6368;
  --border-light: #444;
  --accent: #ffcc00;
  --accent-hover: #e6b800;
  --accent-text: #ffcc00;
  --accent-soft-bg: #3a3320;
  --on-accent: #202124;
  --muted-badge-text: #a8adb2;
  --danger: #f28b82;
  --danger-hover: #ee675c;
  --danger-soft-bg: #3c2a28;
  --disabled-bg: #5f6368;
  --avatar-remove-bg: #5f6368;
  --avatar-remove-icon: #e0e0e0;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  padding: 2rem;
  margin: 0 auto;
  background: var(--bg);
  color: var(--text);
}

.main-layout,
.header-area {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}

.main-layout {
  display: flex;
  gap: 3rem;
  margin-top: 2rem;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
}

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

.header-area {
  margin-bottom: 2rem;
  padding-left: calc(240px + 3rem);
}

@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
    gap: 2rem;
  }
  .sidebar {
    width: 100%;
  }
  .header-area {
    padding-left: 0;
  }
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
}

.nav-link:hover {
  background: var(--hover-bg);
  color: var(--accent-text);
}

.nav-link.active {
  color: var(--accent-text);
  font-weight: 600;
  border-left: 3px solid var(--accent-text);
  border-radius: 0;
  padding-left: calc(1rem - 3px);
}

h1.page-subtitle {
  color: var(--text-faint);
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  margin-top: 0;
}

.page-title {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
}

section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

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

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.form-group input:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
}

button {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
}

button:hover {
  background: var(--accent-hover);
}

button.secondary-btn {
  background: var(--surface);
  color: var(--accent-text);
  border: 1px solid var(--accent-text);
}

button.secondary-btn:hover {
  background: var(--surface-muted);
}

button:disabled {
  background: var(--disabled-bg);
  cursor: not-allowed;
}

#toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 1rem;
  background: #333;
  color: white;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10000;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent-text);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.remove-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.remove-btn:hover {
  background: var(--danger-soft-bg);
}

.remove-btn:disabled {
  background: var(--surface-muted);
  border-color: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-link {
  display: inline-block;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--accent-text);
  border: 1px solid var(--accent-text);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.btn-link:hover {
  background: var(--surface-muted);
}

.remove-image-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--avatar-remove-bg);
  color: var(--avatar-remove-icon);
  border: 2px solid var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-weight: bold;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s;
  z-index: 10;
}

.remove-image-btn:hover {
  background: #ea4335;
}

/* Profile specific */
.avatar-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.account-avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.credential-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.credential-item.active {
  border-color: var(--accent-text);
  background-color: var(--accent-soft-bg);
}

.current-badge {
  font-size: 0.75rem;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.125rem 0.375rem;
  border-radius: 0.75rem;
  margin-left: 0.5rem;
  font-weight: normal;
}

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

.provider-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.twitch-icon {
  color: #9146ff;
}

.link-account-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.2s;
}

.link-account-btn.google:hover {
  background: var(--surface-muted);
}

.link-account-btn.twitch {
  background: #9146ff;
  color: white;
  border-color: #9146ff;
}

.link-account-btn.twitch .twitch-icon {
  color: white;
}

.link-account-btn.twitch:hover {
  background: #7d2ee6;
}

/* Accounts specific */
.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.member-item:last-child {
  border-bottom: none;
}

.member-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-badge-text);
}

.member-avatar svg {
  width: 20px;
  height: 20px;
}

.member-details {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.member-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.member-role {
  width: 80px;
  display: flex;
  justify-content: center;
}

.role-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  background: var(--surface-alt);
  color: var(--muted-badge-text);
  font-weight: 500;
}

.role-badge.admin {
  background: var(--accent-soft-bg);
  color: var(--accent-text);
}

.role-select {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
}

.role-select:disabled {
  background: var(--surface-alt);
  color: var(--muted-badge-text);
  border-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: default;
}

.id-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 25ch;
}

.copy-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: var(--hover-bg);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}
