/* CSS Variables - Rust Dark Theme */
:root {
  /* Rust branding colors */
  --rust-primary: #CD412B;
  --rust-primary-hover: #E04D35;
  --rust-primary-dark: #A53624;
  --rust-accent: #FF6B4A;

  /* Dark mode colors */
  --bg-dark: #0D0D0D;
  --bg-darker: #080808;
  --bg-card: #141414;
  --bg-card-hover: #1A1A1A;
  --bg-input: #1E1E1E;
  --bg-console: #0A0A0A;

  /* Text colors */
  --text-primary: #E8E8E8;
  --text-secondary: #A0A0A0;
  --text-muted: #666666;

  /* Border colors */
  --border-color: #2A2A2A;
  --border-focus: #CD412B;

  /* Status colors */
  --status-online: #4ADE80;
  --status-offline: #EF4444;
  --status-warning: #F59E0B;

  /* Syntax highlighting */
  --syntax-string: #98C379;
  --syntax-number: #E5C07B;
  --syntax-boolean: #56B6C2;
  --syntax-null: #C678DD;
  --syntax-key: #61AFEF;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

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

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-indicator.connected {
  background: var(--status-online);
  box-shadow: 0 0 8px var(--status-online);
}

.status-indicator.disconnected {
  background: var(--status-offline);
  animation: none;
}

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

.status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebars */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-darker);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.players-sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--bg-darker);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

/* Panels */
.panel {
  display: flex;
  flex-direction: column;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.panel-title svg {
  color: var(--rust-primary);
}

.panel-content {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input, .form-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--rust-primary);
  box-shadow: 0 0 0 3px rgba(205, 65, 43, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  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='%23666666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 32px;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
}

.select-with-action {
  display: flex;
  gap: var(--space-sm);
  min-width: 0;
}

.select-with-action .form-select {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
}

.input-with-button {
  display: flex;
  gap: var(--space-sm);
}

.input-with-button .form-input {
  flex: 1;
}

.save-server-group {
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
  margin-top: var(--space-sm);
  flex-shrink: 0;
}

.connection-panel .panel-content {
  overflow: visible;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--rust-primary-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: #DC2626;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #EF4444;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-sm);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-icon {
  padding: var(--space-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.btn-block {
  width: 100%;
}

/* Sessions List */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 200px;
  overflow-y: auto;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.session-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--rust-primary);
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.session-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.session-delete {
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.session-delete:hover {
  background: #DC2626;
  color: white;
}

/* Console Area */
.console-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-dark);
}

.console-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

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

.console-header .panel-title {
  border-bottom: none;
}

.console-actions {
  display: flex;
  gap: var(--space-xs);
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  background: var(--bg-console);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.console-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-sm);
  color: var(--text-secondary);
  text-align: center;
}

.console-welcome .rust-text {
  color: var(--rust-primary);
  font-weight: 600;
}

.console-welcome .muted {
  font-size: 12px;
  color: var(--text-muted);
}

.console-line {
  display: flex;
  gap: var(--space-md);
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.console-line:hover {
  background: rgba(255, 255, 255, 0.02);
}

.line-number {
  min-width: 40px;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  flex-shrink: 0;
}

.line-timestamp {
  min-width: 80px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.line-content {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

.line-content.input {
  color: var(--rust-accent);
}

.line-content.input::before {
  content: '> ';
  color: var(--rust-primary);
}

.line-content.output {
  color: var(--text-primary);
}

.line-content.error {
  color: var(--status-offline);
}

.line-content.warning {
  color: var(--status-warning);
}

/* JSON Syntax Highlighting */
.json-key {
  color: var(--syntax-key);
}

.json-string {
  color: var(--syntax-string);
}

.json-number {
  color: var(--syntax-number);
}

.json-boolean {
  color: var(--syntax-boolean);
}

.json-null {
  color: var(--syntax-null);
}

.json-bracket {
  color: var(--text-muted);
}

/* Console Input */
.console-input-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-darker);
  border-top: 1px solid var(--border-color);
}

.input-prefix {
  color: var(--rust-primary);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
}

.console-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.console-input:focus {
  outline: none;
  border-color: var(--rust-primary);
  box-shadow: 0 0 0 3px rgba(205, 65, 43, 0.15);
}

.console-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Players Panel */
.players-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-count {
  color: var(--rust-primary);
  font-weight: 700;
}

.players-panel .panel-content {
  flex: 1;
  overflow: hidden;
  padding: 0;
}

.players-list {
  height: 100%;
  overflow-y: auto;
  padding: var(--space-md);
}

.empty-message {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: var(--space-lg);
}

.player-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: var(--space-sm);
  transition: all var(--transition-fast);
}

.player-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--rust-primary);
}

.player-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.player-name::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--status-online);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--status-online);
}

.player-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.player-detail {
  display: flex;
  gap: var(--space-sm);
}

.player-detail-label {
  color: var(--text-muted);
  min-width: 60px;
}

.player-detail-value {
  color: var(--text-secondary);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: var(--space-lg);
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.modal-large {
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  margin-bottom: 0;
}

.modal-body {
  flex: 1;
  overflow: hidden;
}

.session-console {
  height: 400px;
  overflow-y: auto;
  background: var(--bg-console);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
}

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

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

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

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

/* Responsive */
@media (max-width: 1200px) {
  .players-sidebar {
    width: 250px;
    min-width: 250px;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
  }

  .players-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .header {
    padding: var(--space-sm) var(--space-md);
  }
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
}

.quick-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-btn:hover {
  background: var(--rust-primary);
  border-color: var(--rust-primary);
  color: white;
}

.quick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Console Filters & Search */
.console-filters {
  display: flex;
  gap: var(--space-md);
  margin-left: auto;
  margin-right: var(--space-md);
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--rust-primary);
  cursor: pointer;
}

.console-search {
  margin-right: var(--space-sm);
}

.search-input {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 150px;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--rust-primary);
  width: 200px;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* Console line filtering */
.console-line.hidden {
  display: none;
}

/* Command Input Wrapper & Autocomplete */
.command-input-wrapper {
  flex: 1;
  position: relative;
}

.command-input-wrapper .console-input {
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 100;
  margin-bottom: 4px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.autocomplete-dropdown.active {
  display: block;
}

.autocomplete-item {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.autocomplete-item .cmd-name {
  color: var(--rust-accent);
}

.autocomplete-item .cmd-desc {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: var(--space-sm);
}

/* Player Context Menu */
.player-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: none;
  overflow: hidden;
}

.player-menu.active {
  display: block;
}

.player-menu-header {
  padding: var(--space-sm) var(--space-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.player-menu-item:hover {
  background: var(--bg-card-hover);
}

.player-menu-item.danger {
  color: var(--status-offline);
}

.player-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.player-menu-item svg {
  color: var(--text-muted);
}

.player-menu-item:hover svg {
  color: var(--text-primary);
}

.player-menu-item.danger svg {
  color: var(--status-offline);
}

.player-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-xs) 0;
}

/* Player item clickable */
.player-item {
  cursor: pointer;
}

/* Server Info Widget */
.server-info-panel {
  border-bottom: 1px solid var(--border-color);
}

.server-info-content {
  padding: var(--space-sm) var(--space-md);
}

.server-info-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: var(--space-sm);
}

.server-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs);
}

.server-info-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.server-info-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.server-info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.server-info-value.good {
  color: var(--status-online);
}

.server-info-value.warning {
  color: var(--status-warning);
}

.server-info-value.bad {
  color: var(--status-offline);
}

.server-info-value.hostname-value {
  font-size: 12px;
  word-break: break-all;
}

.queued {
  color: var(--status-warning);
  font-size: 11px;
}

/* Player Search */
.player-search-wrapper {
  padding: 0 0 8px 0;
}

.player-search-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

.player-search-input:focus {
  border-color: var(--accent-color);
}

.player-search-input::placeholder {
  color: var(--text-muted);
}

/* Hidden elements */
.player-item.hidden {
  display: none;
}

/* Broadcast button */
.broadcast-btn {
  background: var(--accent-color) !important;
  color: white !important;
}

.broadcast-btn:hover:not(:disabled) {
  background: var(--accent-hover) !important;
}

/* Checkbox group */
.checkbox-group {
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-color);
}

.checkbox-label span {
  line-height: 1;
}
