/**
 * Components
 * Kingshot Alliance Tools Design System
 *
 * Buttons, cards, form controls, badges/chips, and stats grid.
 */

/* ========================================
   BUTTONS
   ======================================== */

/* Base button */
.btn {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-3) var(--space-5);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--r12);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  background: var(--surface);
  color: var(--text);
  /* Safari button fixes */
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

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

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary button */
.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

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

/* Secondary / outline button */
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--stroke-strong);
}

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

/* Ghost button */
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--surface);
  color: var(--text);
}

/* Danger button */
.btn.danger {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.btn.danger:hover {
  background: #f85a73;
  border-color: #f85a73;
}

/* Success button */
.btn.success {
  background: var(--success);
  color: #0e1220;
  border-color: var(--success);
}

.btn.success:hover {
  background: #4ade9a;
  border-color: #4ade9a;
}

/* Button sizes */
.btn.sm {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.8125rem;
  border-radius: var(--r8);
}

.btn.lg {
  min-height: 52px;
  padding: var(--space-4) var(--space-6);
  font-size: 1rem;
}

/* Full-width button */
.btn.block {
  width: 100%;
}

/* Icon button */
.iconbtn {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  font-size: 1.25rem;
  border: none;
  border-radius: var(--r12);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
  background: transparent;
  color: var(--muted);
  /* Safari button fixes */
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.iconbtn:hover {
  background: var(--surface);
  color: var(--text);
}

/* Ensure SVG inside buttons doesn't capture clicks */
.iconbtn svg,
.iconbtn .icon {
  pointer-events: none;
}

.iconbtn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.iconbtn:active {
  transform: scale(0.95);
}

.iconbtn.sm {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  border-radius: var(--r8);
}

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

.iconbtn.primary:hover {
  background: var(--accent-hover);
}

/* ========================================
   CARDS
   ======================================== */

/* Base card */
.card {
  background: var(--panel);
  border-radius: var(--r16);
  border: 1px solid var(--stroke);
  overflow: hidden;
}

/* Card header */
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--stroke);
}

.card-h-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-h-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* Card body */
.card-b {
  padding: var(--space-5);
}

/* Alternate card class names for compatibility */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--stroke);
}

.card-content {
  padding: var(--space-5);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* Card variants */
.card.interactive {
  cursor: pointer;
  transition:
    border-color var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.card.interactive:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card.surface {
  background: var(--surface);
}

.card.flat {
  background: transparent;
  border-color: transparent;
}

/* Danger zone card variant */
.card.danger-zone {
  border-color: var(--error);
}

.card.danger-zone .card-header,
.card.danger-zone .card-h {
  background: rgba(var(--error-rgb), 0.1);
}

.card.danger-zone .card-title,
.card.danger-zone .card-h-title {
  color: var(--error);
}

.card.danger-zone .card-title::before,
.card.danger-zone .card-h-title::before {
  background: var(--error);
}

/* Character card variant */
.card.character-card {
  padding: var(--space-3);
}

.card.character-card.primary {
  border-color: var(--accent);
}

.card.character-card.pending {
  border-color: var(--warning);
}

.card.character-card.rejected {
  border-color: var(--error);
  opacity: 0.7;
}

/* Character avatar */
.character-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: var(--surface);
  flex-shrink: 0;
}

.character-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--r-full);
  object-fit: cover;
}

.character-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

/* ========================================
   FORM CONTROLS
   ======================================== */

/* Field container */
.field {
  margin-bottom: var(--space-4);
}

.field:last-child {
  margin-bottom: 0;
}

/* Alternate form class names for compatibility */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Label */
.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.label.required::after {
  content: ' *';
  color: var(--error);
}

/* Input, select, textarea control */
.control,
.form-input,
.form-select,
input[type="text"].form-input,
input[type="email"].form-input,
input[type="password"].form-input,
select.form-select,
textarea.form-input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-3) var(--space-4);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r12);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  appearance: none;
}

.control::placeholder,
.form-input::placeholder,
.form-select::placeholder {
  color: var(--faint);
}

.control:hover,
.form-input:hover,
.form-select:hover {
  border-color: var(--stroke-strong);
}

.control:focus,
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.control:disabled,
.form-input:disabled,
.form-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Control with error */
.control.error,
.form-input.error,
.form-select.error {
  border-color: var(--error);
}

.control.error:focus,
.form-input.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.25);
}

/* Select with custom arrow */
select.control,
select.form-select {
  padding-right: var(--space-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.7)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

html[data-theme="light"] select.control,
html[data-theme="light"] select.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.6)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Textarea */
textarea.control,
textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

/* Helper text */
.helper {
  font-size: 0.75rem;
  color: var(--faint);
  margin-top: var(--space-1);
}

.helper.error {
  color: var(--error);
}

/* Checkbox & Radio */
.checkbox,
.radio {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  cursor: pointer;
}

.checkbox input,
.radio input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ========================================
   BADGES / CHIPS
   ======================================== */

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--muted);
}

.badge.accent {
  background: rgba(124, 92, 255, 0.15);
  color: var(--accent);
}

.badge.success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge.warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.badge.error,
.badge.danger {
  background: rgba(251, 113, 133, 0.15);
  color: var(--error);
}

.badge.info {
  background: rgba(96, 165, 250, 0.15);
  color: var(--info);
}

/* Badge sizes */
.badge.sm {
  font-size: 0.65rem;
  padding: 1px var(--space-2);
}

/* Chip (larger, often removable) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--r8);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--stroke);
}

.chip.interactive {
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.chip.interactive:hover {
  background: var(--surface2);
  border-color: var(--stroke-strong);
}

.chip.selected {
  background: rgba(124, 92, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 1rem;
  color: var(--faint);
  cursor: pointer;
  border-radius: var(--r-full);
  transition: color var(--duration-fast) var(--ease-out);
}

.chip-remove:hover {
  color: var(--error);
}

/* ========================================
   STATS GRID
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 860px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--surface);
  border-radius: var(--r12);
  padding: var(--space-4);
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text);
  line-height: 1.2;
}

.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.error { color: var(--error); }
.stat-value.info { color: var(--info); }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-1);
}

/* ========================================
   AVATAR
   ======================================== */

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}

.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
}

/* ========================================
   LOADING SPINNER
   ======================================== */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--stroke);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner.lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   SKELETON LOADER
   ======================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface2) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r8);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 70%;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ========================================
   MODAL / DIALOG
   ======================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    visibility var(--duration-normal);
  /* Mobile touch support */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--panel);
  border-radius: var(--r20);
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - var(--space-8));
  max-height: calc(100dvh - var(--space-8)); /* Mobile viewport support */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-bounce);
}

.modal-backdrop.active .modal,
.modal-backdrop.show .modal {
  transform: scale(1) translateY(0);
}

/* Mobile specific adjustments */
@media (max-width: 640px) {
  .modal {
    max-width: calc(100vw - var(--space-4));
    max-height: calc(100vh - var(--space-4));
    max-height: calc(100dvh - var(--space-4));
    border-radius: var(--r16);
  }
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  /* Smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .modal-body {
    padding: var(--space-4);
  }
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--stroke);
}

.modal-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: var(--surface);
  border: none;
  border-radius: var(--r8);
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Mobile touch support */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
  flex-shrink: 0;
}

/* Ensure child elements don't capture clicks */
.modal-close svg,
.modal-close * {
  pointer-events: none;
}

.modal-close:hover {
  background: var(--accent);
  color: white;
}

.modal-close:active {
  transform: scale(0.92);
}

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

/* ========================================
   ALERT / MESSAGE BOXES
   ======================================== */

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r12);
  font-size: 0.875rem;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--text);
  margin-bottom: var(--space-3);
}

.alert.success {
  background: rgba(52, 211, 153, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.alert.error {
  background: rgba(251, 113, 133, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.alert.warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: var(--warning);
  color: var(--warning);
}

.alert.info {
  background: rgba(96, 165, 250, 0.1);
  border-color: var(--info);
  color: var(--info);
}

/* ========================================
   COLUMN LAYOUT (Vertical Stack)
   ======================================== */

.col {
  display: flex;
  flex-direction: column;
}

.col.gap-1 { gap: var(--space-1); }
.col.gap-2 { gap: var(--space-2); }
.col.gap-3 { gap: var(--space-3); }
.col.gap-4 { gap: var(--space-4); }
.col.gap-6 { gap: var(--space-6); }

/* ========================================
   TABLES
   ======================================== */

/* Base table container */
.table-container {
  overflow-x: auto;
  border-radius: var(--r12);
  border: 1px solid var(--stroke);
  background: var(--panel);
}

/* Base table */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.table thead {
  background: var(--surface);
  border-bottom: 2px solid var(--stroke);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--stroke);
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background: var(--surface);
}

.table tbody tr:last-child {
  border-bottom: none;
}

.table td {
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  color: var(--text);
}

/* Sortable columns */
.table th[data-sortable] {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.table th[data-sortable]:hover {
  background: var(--surface2);
}

/* Row states */
.table tbody tr.selected {
  background: rgba(124, 92, 255, 0.1);
}

.table tbody tr.selected:hover {
  background: rgba(124, 92, 255, 0.15);
}

/* Responsive table - hide on mobile */
@media (max-width: 859px) {
  .table-responsive {
    display: none;
  }
}

/* Compact table variant */
.table.compact th,
.table.compact td {
  padding: var(--space-2) var(--space-3);
}

/* Striped rows variant */
.table.striped tbody tr:nth-child(even) {
  background: var(--surface);
}

.table.striped tbody tr:nth-child(even):hover {
  background: var(--surface2);
}

/* ========================================
   CHARACTER SWITCHER
   ======================================== */

.character-switcher {
  position: relative;
  display: flex;
  align-items: center;
}

.character-switcher-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r8);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
  /* Safari button fixes */
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.character-switcher-toggle:hover {
  background: var(--surface2);
  border-color: var(--stroke-strong);
}

.character-switcher-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.character-switcher-toggle[aria-expanded="true"] {
  background: var(--surface2);
  border-color: var(--accent);
}

.character-switcher-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.character-switcher-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.character-switcher-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--muted);
}

.character-switcher-server {
  white-space: nowrap;
}

.character-switcher-alliance {
  white-space: nowrap;
  color: var(--accent);
}

.character-switcher-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform var(--duration-fast) var(--ease-out);
}

.character-switcher-toggle[aria-expanded="true"] .character-switcher-chevron {
  transform: rotate(180deg);
}

/* Dropdown menu */
.character-switcher-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  min-width: 280px;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--r12);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition:
    opacity var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    visibility var(--duration-fast);
  overflow: hidden;
  max-height: 400px;
  overflow-y: auto;
}

.character-switcher-dropdown[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Character list items */
.character-switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--stroke);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out);
  text-align: left;
  /* Safari button fixes */
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

.character-switcher-item:hover:not(.disabled) {
  background: var(--surface);
}

.character-switcher-item:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.character-switcher-item.active {
  background: rgba(124, 92, 255, 0.1);
}

.character-switcher-item.active:hover {
  background: rgba(124, 92, 255, 0.15);
}

.character-switcher-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.character-switcher-item-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.character-switcher-item-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-switcher-item.active .character-switcher-item-name {
  color: var(--accent);
}

.character-switcher-item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--muted);
}

.character-switcher-item-server {
  white-space: nowrap;
}

.character-switcher-item-alliance {
  white-space: nowrap;
  color: var(--accent);
}

.character-switcher-check {
  flex-shrink: 0;
  color: var(--accent);
}

/* Mobile responsive adjustments */
@media (max-width: 860px) {
  .character-switcher-toggle {
    padding: var(--space-2);
  }

  .character-switcher-name {
    max-width: 100px;
  }

  .character-switcher-meta {
    font-size: 0.7rem;
  }

  .character-switcher-dropdown {
    right: 0;
    left: auto;
    min-width: 260px;
  }
}

/* Extra small screens - further reduce character switcher width */
@media (max-width: 640px) {
  .character-switcher {
    max-width: 140px;
  }

  .character-switcher-toggle {
    padding: 6px 8px;
    gap: 4px;
  }

  .character-switcher-name {
    max-width: 80px;
    font-size: 0.8125rem;
  }

  .character-switcher-meta {
    display: none; /* Hide server/alliance info on very small screens */
  }

  .character-switcher-chevron {
    width: 14px;
    height: 14px;
  }
}

/* Portrait mode on mobile - hide character switcher entirely to save space */
@media (max-width: 480px) {
  .character-switcher {
    display: none !important;
  }
}
