/* ── Base ─────────────────────────────────────────────── */
:root {
  --primary: #0b1f3a;
  --primary-light: #16345f;
  --background: #ffffff;
  --surface: #f8f9fa;
  --text: #111111;
  --muted: #6c757d;
  --border: #e5e7eb;
  --shadow: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --background: #081120;
  --surface: #0f1c2e;
  --text: #ffffff;
  --muted: #b0b7c3;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--background);
  margin: 0;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ── Layout ───────────────────────────────────────────── */
.container-xl {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Navbar ───────────────────────────────────────────── */
.navbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.navbar .container-xl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.navbar-brand {
  text-decoration: none;
  display: flex;
  align-items: baseline;
}

.brand-text {
  font-weight: 700;
  font-size: 17px;
  color: var(--primary);
  transition: color 0.25s ease;
}

[data-theme="dark"] .brand-text {
  color: #ffffff;
}

.brand-dot {
  font-weight: 700;
  font-size: 17px;
  color: var(--primary);
  transition: color 0.25s ease;
}

[data-theme="dark"] .brand-dot {
  color: #ffffff;
}

.brand-tools {
  font-weight: 400;
  font-size: 17px;
  color: var(--muted);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-back {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav-back:hover {
  color: var(--primary);
}

[data-theme="dark"] .nav-back:hover {
  color: #ffffff;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: border-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--muted);
}

/* ── Page Header ──────────────────────────────────────── */
.tool-header {
  padding: 40px 0 24px;
}

.tool-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  line-height: 1.2;
  transition: color 0.25s ease;
}

[data-theme="dark"] .tool-title {
  color: #ffffff;
}

.tool-description {
  font-size: 15px;
  color: var(--muted);
  margin: 6px 0 0;
}

/* ── Tool Card ────────────────────────────────────────── */
.tool-main {
  padding: 0 0 80px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 2px 8px var(--shadow);
  max-width: 900px;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.field-block {
  margin-top: 20px;
}

.field-block:first-child {
  margin-top: 0;
}

/* ── Inputs ───────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

textarea,
select {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: background-color 0.25s ease, border-color 0.2s ease, color 0.25s ease;
}

textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
}

textarea:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}

textarea.input-error {
  border-color: #dc3545;
}

textarea.input-error:focus {
  outline-color: #dc3545;
}

select {
  cursor: pointer;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-field .field-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.error-msg {
  font-size: 13px;
  color: #dc3545;
  margin: 6px 0 0;
  display: none;
}

.error-msg.visible {
  display: block;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

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

.btn-secondary:hover {
  background: var(--primary);
  color: #ffffff;
}

[data-theme="dark"] .btn-secondary {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Output ───────────────────────────────────────────── */
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.output-header .field-label {
  margin-bottom: 0;
}

.output-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.output-box {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13.5px;
  color: var(--text);
  min-height: 120px;
  white-space: pre;
  overflow-x: auto;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.output-placeholder {
  color: var(--muted);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-style: italic;
  white-space: normal;
}

.validation-badge {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
}

.badge-valid {
  background: #d1fae5;
  color: #065f46;
}

.badge-invalid {
  background: #fee2e2;
  color: #991b1b;
}

[data-theme="dark"] .badge-valid {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

[data-theme="dark"] .badge-invalid {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ── Footer ───────────────────────────────────────────── */
.site-footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  transition: border-color 0.25s ease;
}

.footer-text {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.footer-text a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

[data-theme="dark"] .footer-text a {
  color: #b0b7c3;
}

.footer-text a:hover {
  text-decoration: underline;
}

/* ── Dark mode overrides ──────────────────────────────── */
[data-theme="dark"] .btn-secondary {
  background: transparent;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 575px) {
  .tool-card {
    padding: 16px;
  }

  .tool-title {
    font-size: 22px;
  }

  .btn {
    width: 100%;
  }

  .btn-group {
    flex-direction: column;
  }

  .inline-field {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .output-controls {
    flex-wrap: wrap;
  }
}
