/* ===== Custom Properties ===== */
:root {
  --bg-terminal: #1e1e1e;
  --bg-header: #2d2d2d;
  --bg-header-text: #e0e0e0;
  --bg-preview: #ffffff;
  --bg-admin: #f5f6f8;
  --bg-admin-card: #ffffff;

  --border-color: #3a3a3a;
  --border-light: #ddd;
  --accent: #6c63ff;
  --accent-hover: #5a52d5;
  --accent-text: #ffffff;

  --status-green: #22c55e;
  --status-green-bg: #dcfce7;
  --status-red: #ef4444;
  --status-red-bg: #fee2e2;
  --status-yellow: #eab308;
  --status-yellow-bg: #fef9c3;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;

  --handle-width: 5px;
  --header-height: 42px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  overflow: hidden;
}

/* ===== Seat Page Layout ===== */
.seat-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-terminal);
}

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

.seat-header .seat-info {
  color: var(--bg-header-text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-header .seat-info .seat-label {
  color: #999;
  margin-right: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* --- Tab Buttons --- */
.tab-btn {
  padding: 4px 14px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: transparent;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-ui);
}

.tab-btn:hover {
  color: #ddd;
  border-color: #666;
}

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

/* --- Refresh Button --- */
.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.refresh-btn:hover {
  color: #ddd;
  border-color: #666;
  background: rgba(255, 255, 255, 0.05);
}

/* --- Split Panes --- */
.split-container {
  display: flex;
  flex: 1;
  min-height: 0;
}

.pane-terminal {
  flex: 0 0 55%;
  min-width: 200px;
  position: relative;
  overflow: hidden;
  background: var(--bg-terminal);
}

.pane-terminal #terminal-container {
  position: absolute;
  inset: 0;
  padding: 4px 0 0 4px;
}

/* xterm.js fills its container */
.pane-terminal .xterm {
  height: 100%;
}

.resize-handle {
  width: var(--handle-width);
  cursor: col-resize;
  background: var(--border-color);
  flex-shrink: 0;
  transition: background 0.15s ease;
  position: relative;
  z-index: 10;
}

.resize-handle:hover,
.resize-handle.active {
  background: var(--accent);
}

.pane-preview {
  flex: 1;
  min-width: 200px;
  position: relative;
  background: var(--bg-preview);
  overflow: hidden;
}

.pane-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- Connection Status Overlay --- */
.connection-status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.connection-status.visible {
  opacity: 1;
}

.connection-status.connecting {
  background: rgba(234, 179, 8, 0.9);
  color: #1a1a1a;
}

.connection-status.connected {
  background: rgba(34, 197, 94, 0.85);
  color: #fff;
}

.connection-status.disconnected {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

/* =========================================================
   Admin Page
   ========================================================= */
.admin-layout {
  min-height: 100vh;
  background: var(--bg-admin);
  padding: 24px 32px;
  overflow: auto;
}

.admin-layout h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a1a;
}

/* --- Auth Bar --- */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--bg-admin-card);
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

.auth-bar label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
  white-space: nowrap;
}

.auth-bar input {
  flex: 1;
  max-width: 340px;
  padding: 7px 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.auth-bar button {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: background 0.15s ease;
}

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

/* --- Cards --- */
.admin-card {
  background: var(--bg-admin-card);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  padding: 18px 22px;
  margin-bottom: 18px;
}

.admin-card h2 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 14px;
}

/* --- Stats Row --- */
.stats-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
}

.stat .label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* --- Table --- */
.seats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.seats-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-light);
}

.seats-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}

.seats-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.seats-table tbody tr:hover {
  background: #f0f2f5;
}

.seats-table td {
  padding: 10px 12px;
  color: #333;
  vertical-align: middle;
}

.seats-table td.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #666;
}

/* --- Status Badges --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.running {
  background: var(--status-green-bg);
  color: #16a34a;
}

.badge.exited,
.badge.removed {
  background: var(--status-red-bg);
  color: #dc2626;
}

.badge.other {
  background: var(--status-yellow-bg);
  color: #a16207;
}

/* --- Action Buttons --- */
.action-btns {
  display: flex;
  gap: 6px;
}

.btn-sm {
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: #fff;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: all 0.12s ease;
}

.btn-sm:hover {
  border-color: #bbb;
  background: #f5f5f5;
}

.btn-sm.danger {
  color: var(--status-red);
  border-color: #fca5a5;
}

.btn-sm.danger:hover {
  background: var(--status-red-bg);
}

.btn-sm.open {
  color: var(--accent);
  border-color: #c4b5fd;
}

.btn-sm.open:hover {
  background: #ede9fe;
}

/* --- Bulk Create Form --- */
.bulk-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bulk-form .form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bulk-form label {
  font-size: 13px;
  color: #555;
  font-weight: 500;
  min-width: 60px;
}

.bulk-form input[type="number"] {
  width: 80px;
  padding: 7px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 13px;
}

.bulk-form textarea {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
  resize: vertical;
  min-height: 60px;
}

.bulk-form .form-hint {
  font-size: 11px;
  color: #999;
}

.btn-primary {
  padding: 8px 22px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s ease;
  align-self: flex-start;
}

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

.btn-danger {
  padding: 8px 22px;
  border: none;
  border-radius: 6px;
  background: var(--status-red);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s ease;
}

.btn-danger:hover {
  background: #dc2626;
}

/* --- Footer actions row --- */
.footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* --- Toast / Messages --- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: #16a34a;
}

.toast.error {
  background: #dc2626;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #999;
  font-size: 14px;
}

/* --- Login page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  color: #1a1a2e;
}

.login-card h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  color: #1a1a2e;
}

.login-subtitle {
  margin: 0 0 28px 0;
  color: #888;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
  background: #fafafa;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  margin-top: 8px;
}

.btn-primary {
  background: #6366f1;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #4f46e5;
}

.btn-primary:disabled {
  background: #a5a6f6;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: #888;
  font-weight: 500;
}

.btn-secondary:hover {
  color: #444;
}

.error-msg {
  color: #ef4444;
  font-size: 13px;
  margin: 8px 0;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* --- Seat header user/logout --- */
.header-separator {
  width: 1px;
  height: 16px;
  background: #555;
  margin: 0 8px;
}

.user-display {
  color: #aaa;
  font-size: 13px;
  margin-right: 8px;
}

.logout-btn {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.logout-btn:hover {
  color: #fff;
  border-color: #888;
}

/* --- Responsive --- */
@media (max-width: 1280px) {
  .admin-layout {
    padding: 16px 18px;
  }
}
