/* ============================================================
   shared.css — styles common to all launcher pages
   ============================================================ */

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- Base ---- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #1a1a2e;
}

/* ---- Header ---- */
header {
  min-height: 40px;
  padding: 0.1rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  color: white;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

header::-webkit-scrollbar {
  display: none;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.header-links a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}

.header-links a:hover {
  color: white;
}

/* ---- Header collapse ---- */
header {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

body.header-hidden header {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.header-peek {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border-radius: 0 0 10px 10px;
  padding: 2px 14px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.75rem;
  font-family: inherit;
  border: none;
  transition: transform 0.2s ease;
  white-space: nowrap;
}

body.header-hidden .header-peek {
  transform: translateX(-50%) translateY(0);
}

.header-peek svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.header-peek:hover {
  background: rgba(0, 0, 0, 0.75);
  color: white;
}

.header-collapse {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.header-collapse:hover {
  background: rgba(255, 255, 255, 0.2);
}

.header-collapse svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* ---- Theme toggle button ---- */
.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.theme-toggle:active {
  transform: scale(0.97);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* ---- Layout ---- */
.content {
  max-width: 900px;
  margin: 1.5rem auto;
  padding: 0 2rem;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ---- Form elements ---- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #667eea;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #999;
}

.form-group textarea {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  min-height: 320px;
  resize: vertical;
}

.form-group .hint {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.2rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-section {
  border-top: 1px solid #eee;
  padding-top: 1rem;
  margin-top: 1rem;
}

.form-section h3 {
  font-size: 0.85rem;
  color: #444;
  margin-bottom: 0.75rem;
}

.selector-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #eee;
}

.selector-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* ---- Custom combobox (replaces input+datalist+select) ---- */
/* Behavior: /combobox.js (createCombobox) — shared by index, config, testdata */
.combobox {
  position: relative;
}

.combobox-input {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0.55rem 2.75rem 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1a1a2e;
  background: white;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.combobox-input:focus {
  border-color: #667eea;
}

.combobox-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.combobox-toggle {
  position: absolute;
  right: 0.15rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.combobox-clear {
  position: absolute;
  right: 2.35rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.combobox-clear[hidden] {
  display: none !important;
}

.combobox-clear:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.combobox-clear-icon {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.combobox-clearable .combobox-input {
  padding-right: 4.6rem;
}

.combobox-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.combobox-chevron {
  width: 16px;
  height: 16px;
  pointer-events: none;
  transition: transform 0.15s;
}

.combobox.open .combobox-toggle .combobox-chevron {
  transform: rotate(180deg);
}

.combobox-selection-only .combobox-input:focus {
  border-color: #ddd;
}

.combobox-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

@media (max-width: 640px) {
  .combobox-dropdown {
    max-height: min(50vh, 320px);
  }
}

.combobox.open .combobox-dropdown {
  display: block;
}

.combobox-option {
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: #1a1a2e;
  user-select: none;
}

.combobox-option:hover,
.combobox-option.highlighted {
  background: rgba(102, 126, 234, 0.1);
}

.combobox-option.selected {
  font-weight: 600;
  color: #667eea;
}

.combobox-empty {
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  color: #999;
}

/* Legacy hidden select (kept for config.html compat) */
.searchable-select-hidden {
  display: none;
}

/* Legacy combo input (kept for config.html compat) */
.select-combo-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1a1a2e;
  background: white;
  outline: none;
  transition: border-color 0.15s;
}

.select-combo-input:focus {
  border-color: #667eea;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-warning {
  background: #f39c12;
  color: white;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

.btn-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
  gap: 8px;
}

/* ---- States ---- */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #999;
}

.empty-state p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #999;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 3rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  color: white;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.25s ease;
}

.toast.success {
  background: #27ae60;
}

.toast.error {
  background: #e74c3c;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---- Dark mode ---- */
body.theme-dark {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: #e5e7eb;
}

body.theme-dark header {
  background: rgba(0, 0, 0, 0.45);
  border-bottom-color: rgba(255, 255, 255, 0.16);
}

body.theme-dark .theme-toggle {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
}

body.theme-dark .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

body.theme-dark .panel {
  background: rgba(15, 23, 42, 0.94);
  color: #e5e7eb;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.5);
}

body.theme-dark .form-group label,
body.theme-dark .form-section h3 {
  color: #cbd5e1;
}

body.theme-dark .form-group .hint,
body.theme-dark .empty-state,
body.theme-dark .loading {
  color: #94a3b8;
}

body.theme-dark .form-group input,
body.theme-dark .form-group select,
body.theme-dark .form-group textarea {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f8fafc;
}

body.theme-dark .form-group select option {
  background: #1e293b;
  color: #e2e8f0;
}

body.theme-dark .form-group input::placeholder,
body.theme-dark .form-group textarea::placeholder {
  color: rgba(226, 232, 240, 0.6);
}

body.theme-dark .select-combo-input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

body.theme-dark .select-combo-input:focus {
  border-color: #7c8cff;
}

body.theme-dark .combobox-input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

body.theme-dark .combobox-input:focus {
  border-color: #7c8cff;
}

body.theme-dark .combobox-toggle {
  color: #94a3b8;
}

body.theme-dark .combobox-clear {
  color: #94a3b8;
}

body.theme-dark .combobox-selection-only .combobox-input:focus {
  border-color: rgba(255, 255, 255, 0.15);
}

body.theme-dark .combobox-dropdown {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

body.theme-dark .combobox-option {
  color: #e2e8f0;
}

body.theme-dark .combobox-option:hover,
body.theme-dark .combobox-option.highlighted {
  background: rgba(124, 140, 255, 0.15);
}

body.theme-dark .combobox-option.selected {
  color: #7c8cff;
}

body.theme-dark .combobox-empty {
  color: #64748b;
}

body.theme-dark .selector-row,
body.theme-dark .form-section {
  border-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark .btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  header {
    padding: 0.45rem 0.65rem;
    gap: 0.4rem;
  }

  header h1 {
    font-size: 0.88rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-links {
    gap: 0.5rem;
  }

  .header-links a {
    font-size: 0.72rem;
  }

  .header-collapse {
    width: 24px;
    height: 24px;
  }

  .theme-toggle {
    width: 28px;
    height: 28px;
  }

  .theme-toggle svg {
    width: 15px;
    height: 15px;
  }

  .content {
    margin: 1rem auto;
    padding: 0 1rem;
  }
}
