/* ============================================
   SSH Config Generator - Styles
   ============================================ */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-alt: #1f2233;
  --border: #2e3345;
  --text: #e8eaed;
  --text-dim: #9aa0b0;
  --accent: #6c63ff;
  --accent-hover: #7d75ff;
  --accent-dim: rgba(108, 99, 255, 0.15);
  --danger: #ff5555;
  --success: #50fa7b;
  --warning: #f1fa8c;
  --code-bg: #151821;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

code, pre {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0 0;
  text-align: center;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.accent {
  color: var(--accent);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.subtitle code {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0;
  justify-content: center;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

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

.tab-content {
  display: none;
  padding: 1.5rem 0;
}

.tab-content.active {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  background: var(--surface);
  color: var(--text);
}

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

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

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

.btn-secondary {
  background: transparent;
}

.btn-small {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 85, 85, 0.1);
}

/* Generator Layout */
.generator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.form-panel,
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-header.sticky {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
}

/* Quick Patterns */
.quick-patterns {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
}

.quick-patterns .label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

.pattern-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.pattern-btn:hover {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.25);
}

/* Form */
#host-form {
  padding: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.required {
  color: var(--danger);
}

.form-group input,
.form-group select {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.hint code {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.05em 0.3em;
  border-radius: 2px;
  font-size: 0.85em;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* Host List */
.host-list {
  padding: 0 1.25rem 1.25rem;
}

.host-list:empty {
  display: none;
}

.host-list h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.host-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.host-item-name {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--accent);
}

.host-item-target {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: 0.5rem;
}

.host-item-actions {
  display: flex;
  gap: 0.35rem;
}

.host-item-actions button {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.host-item-actions button:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.host-item-actions .btn-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Config Preview */
.config-preview {
  margin: 0;
  padding: 1.25rem;
  background: var(--code-bg);
  font-size: 0.85rem;
  line-height: 1.7;
  min-height: 300px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* Troubleshooter */
.section-intro {
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.error-selector {
  margin-bottom: 1.5rem;
}

.error-selector label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.error-selector select {
  width: 100%;
  max-width: 500px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}

.error-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

.troubleshoot-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.troubleshoot-result:empty {
  display: none;
}

.troubleshoot-result h3 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  color: var(--danger);
}

.troubleshoot-result .error-desc {
  color: var(--text-dim);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.checklist {
  list-style: none;
  counter-reset: step;
}

.checklist li {
  counter-increment: step;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.checklist li:last-child {
  border-bottom: none;
}

.checklist li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.checklist li code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--warning);
}

/* SEO Content / Guide */
.seo-content {
  max-width: 800px;
}

.seo-content h2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.seo-content h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.seo-content p {
  margin-bottom: 1rem;
  color: var(--text);
}

.seo-content ul {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.seo-content li {
  margin-bottom: 0.4rem;
}

.seo-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
}

.seo-content code {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
}

.seo-content pre code {
  background: none;
  color: var(--text);
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.seo-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.seo-content th,
.seo-content td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.seo-content th {
  background: var(--surface-alt);
  font-weight: 600;
}

.seo-content td {
  background: var(--surface);
}

.affiliate-list {
  list-style: none;
  padding-left: 0;
}

.affiliate-list li {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.affiliate-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.affiliate-list a:hover {
  text-decoration: underline;
}

/* Ad container */
.ad-container {
  margin: 1.5rem auto;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-note {
  font-size: 0.75rem;
  margin-top: 0.35rem;
  opacity: 0.7;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 900px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    order: -1;
  }

  .config-preview {
    min-height: 150px;
  }
}

@media (max-width: 600px) {
  .site-header h1 {
    font-size: 1.35rem;
  }

  .tab-btn {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .quick-patterns {
    flex-wrap: wrap;
  }
}
