/* ═══════════════════════════════════════════════════
   Terminal Profile Studio — Styles
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --bg-inset: #010409;
  --border: #30363d;
  --border-muted: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-subtle: #6e7681;
  --accent: #8534F3;
  --accent-muted: #43179E;
  --green: #0FBF3E;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  background: var(--bg-raised);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

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

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
  font-style: italic;
}

/* ── Main Layout ── */

main {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  gap: 0;
}

/* ── Controls Panel (Left) ── */

.controls-panel {
  width: 340px;
  min-width: 340px;
  border-right: none;
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Resizable divider */

.resize-handle {
  width: 5px;
  cursor: col-resize;
  background: var(--border-muted);
  transition: background 0.15s;
  flex-shrink: 0;
}

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

.control-group {
  background: var(--bg-raised);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 1rem;
}

.control-group h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.control-group h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin: 0.75rem 0 0.5rem;
  font-weight: 500;
}

/* ── Presets ── */

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

.preset-btn {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preset-btn:hover {
  border-color: var(--accent);
  background: var(--bg-raised);
}

.preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.preset-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── Color Controls ── */

.color-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  cursor: pointer;
}

.color-field span {
  font-size: 0.85rem;
  color: var(--text);
}

.color-field input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* ── ANSI Swatches ── */

.ansi-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.3rem;
}

.ansi-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
}

.ansi-swatch input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 0;
}

.ansi-swatch input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.ansi-swatch input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.ansi-swatch span {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-subtle);
}

/* ── Form Fields ── */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field select,
.field input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.field select:focus,
.field input[type="number"]:focus {
  border-color: var(--accent);
}

.field-row {
  display: flex;
  gap: 0.6rem;
}

.field.half {
  flex: 1;
}

/* Range slider */

.range-with-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-with-value input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.range-with-value input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.range-with-value output {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 3em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Toggle */

.toggle-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle:checked {
  background: var(--accent);
}

.toggle:checked::after {
  transform: translateX(16px);
}

/* Cursor style buttons */

.cursor-options {
  display: flex;
  gap: 0.3rem;
}

.cursor-btn {
  width: 36px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.cursor-btn:hover {
  border-color: var(--text-muted);
}

.cursor-btn.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

/* ── Preview Panel (Right) ── */

.preview-panel {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  max-height: calc(100vh - 70px);
}

/* ── Terminal Chrome ── */

.preview-wrapper {
  position: sticky;
  top: 0;
}

.terminal-chrome {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-titlebar {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  position: relative;
}

.traffic-lights {
  display: flex;
  gap: 6px;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.traffic-light.red { background: #ff5f57; }
.traffic-light.yellow { background: #febc2e; }
.traffic-light.green { background: #28c840; }

.terminal-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.6;
}

.terminal-body {
  padding: 0.75rem 1rem;
  min-height: 360px;
  position: relative;
  overflow: hidden;
}

.terminal-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.terminal-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
}

.terminal-cursor.no-blink {
  animation: none;
}

.terminal-cursor.block {
  width: 0.6em;
  height: 1.1em;
  vertical-align: text-bottom;
}

.terminal-cursor.underline {
  width: 0.6em;
  height: 2px;
  vertical-align: baseline;
}

.terminal-cursor.bar {
  width: 2px;
  height: 1.1em;
  vertical-align: text-bottom;
}

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

/* ── Contrast Panel ── */

.contrast-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 1rem;
}

.contrast-panel h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.contrast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.35rem;
}

.contrast-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.contrast-item .label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.contrast-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.1);
}

.contrast-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.contrast-badge.pass-aaa {
  background: #0FBF3E22;
  color: #0FBF3E;
}

.contrast-badge.pass-aa {
  background: #F08A3A22;
  color: #F08A3A;
}

.contrast-badge.fail {
  background: #C5321122;
  color: #FE4C25;
}

/* ── Export Panel ── */

.export-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 1rem;
}

.export-panel h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.export-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.export-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.export-btn:hover {
  border-color: var(--accent);
  background: var(--bg-raised);
  transform: translateY(-1px);
}

.export-btn:active {
  transform: translateY(0);
}

.export-btn .export-icon {
  font-size: 1.3rem;
}

.export-btn small {
  font-size: 0.65rem;
  color: var(--text-subtle);
  font-weight: 400;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s;
}

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

.share-btn svg {
  width: 14px;
  height: 14px;
}

.share-status {
  font-size: 0.8rem;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s;
}

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

/* ── Footer ── */

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.8rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}

/* ── Responsive ── */

@media (max-width: 900px) {
  main {
    flex-direction: column;
  }
  .controls-panel {
    width: 100%;
    min-width: unset;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .preview-panel {
    max-height: none;
  }
  .preview-wrapper {
    position: static;
  }
}
