/* Enhanced Dark Theme Variables */
:root {
  /* Core color palette - refined dark theme */
  --bg-primary: #0a0a0b;
  --bg-secondary: #111113;
  --bg-tertiary: #1a1a1c;
  --bg-card: #1c1c1e;
  --bg-hover: #242427;
  --bg-active: #2c2c30;

  /* Border system */
  --border-subtle: #2a2a2d;
  --border-primary: #36363a;
  --border-hover: #4a4a50;
  --border-focus: #6366f1;

  /* Text hierarchy */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --text-muted: #52525b;

  /* Purple accent colors */
  --accent-primary: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-secondary: #a855f7;
  --accent-tertiary: #c084fc;

  /* Status colors */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* Shadow system */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-purple: 0 0 20px rgba(139, 92, 246, 0.3);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
}

/* Modal (user name) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  width: min(92vw, 420px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  overflow: hidden;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
}

.modal-body {
  padding: 1rem;
}

.modal-body p {
  margin: 0 0 0.5rem 0;
  color: var(--text-secondary);
}

.input-group {
  margin-top: 0.5rem;
}

#display-name-input {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
  outline: none;
}

#display-name-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

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

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: 16px;
  overflow-y: auto;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scrolling */
  -webkit-text-size-adjust: 100%; /* Prevent iOS text size adjustment */
}

/* App container */
.app-container {
  height: 100dvh;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 100;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg) var(--spacing-xl);
  gap: var(--spacing-lg);
}

.luna-brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.luna-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  position: relative;
}

.luna-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.3));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-2px); }
}

.luna-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.025em;
}

.luna-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
  animation: pulse-success 2s ease-in-out infinite;
}

@keyframes pulse-success {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }
  50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.4); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  text-decoration: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-icon {
  padding: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

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

.btn-close {
  padding: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

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

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  min-width: 0; /* Prevents flex overflow */
  height: 100dvh;
  position: relative;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 11, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-normal);
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

/* Server Status - Icon Button Style */
.server-status-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem; /* 40px */
  height: 2.5rem; /* 40px */
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: default;
  transition: var(--transition-normal);
}

.server-status-wrapper:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

/* Server Status - Text Pill Variant (match WIP pill) */
.server-status-wrapper.with-text {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: auto;
  height: auto;
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(168, 85, 247, 0.1));
  border: none;
  border-radius: var(--radius-full);
}

.server-status-wrapper.with-text:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.15));
}

.server-status-wrapper.with-text #status-text {
  font-size: 0.75rem;       /* match header small text */
  line-height: 1.2;         /* slight breathing room */
  color: var(--text-secondary);
  white-space: nowrap;      /* keep as one line */
}


.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px 2px rgba(34, 197, 94, 0.3);
}

.status-dot.offline {
  background-color: var(--error);
  box-shadow: 0 0 8px 2px rgba(239, 68, 68, 0.3);
}

.status-dot.checking {
  background-color: var(--accent-primary);
  animation: pulse-status 1.5s ease-in-out infinite;
}

@keyframes pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pulse-success {
  0%, 100% { box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3); }
  50% { box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5); }
}

/* Work in Progress Notice */
.work-in-progress-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(168, 85, 247, 0.1));
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  margin: 0 auto;
  max-width: fit-content;
}

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

@keyframes pulse-success {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }
  50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.4); }
}

/* Responsive design */
@media (max-width: 768px) {
  .header-content {
    padding: var(--spacing-md);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .luna-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }

  .work-in-progress-header {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    gap: 0.25rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .work-in-progress-header i {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .luna-logo h1 {
    font-size: 1.25rem;
  }

  .luna-icon {
    font-size: 1.5rem;
  }

  .server-status {
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    min-height: 18px;
  }

  .status-dot {
    width: 5px;
    height: 5px;
  }

  .status-text {
    font-size: 0.625rem;
  }

  .work-in-progress-header {
    display: none;
  }

  /* Improved touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
  }
}

/* Focus styles for accessibility */
*:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
