/* Base Styles Using Variables */
/* Root Variables for Light Theme (default) */
:root {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #fafafa;
  --text-primary: #333;
  --text-secondary: #666;
  --text-tertiary: #999;
  --border-color: #ddd;
  --border-light: #eee;
  --shadow: rgba(0, 0, 0, 0.1);

  /* Code - LIGHT BACKGROUND for light theme */
  --code-bg: #f5f5f5;
  --code-text: #333;

  --accent-green: #4caf50;
  --accent-green-hover: #45a049;
  --accent-blue: #2196f3;
  --accent-blue-hover: #0b7dda;
  --accent-red: #e74c3c;
  --accent-red-hover: #c0392b;

  /* Footer */
  --footer-bg: #ffedeb;
  --footer-text: #ffb6ad;
  --footer-link: #ff9100;
  --footer-link-hover: #ff9100;
}

/* Dark Theme Variables */
.theme-dark {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #242424;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #404040;
  --border-light: #333333;
  --shadow: rgba(0, 0, 0, 0.3);

  /* Code - DARK BACKGROUND for dark theme */
  --code-bg: #1e1e1e;
  --code-text: #d4d4d4;

  --accent-green: #5cb85c;
  --accent-green-hover: #4ca64c;
  --accent-blue: #3ba3f3;
  --accent-blue-hover: #2b93e3;
  --accent-red: #f56c5c;
  --accent-red-hover: #e55c4c;

  /* Footer - Inverted */
  --footer-bg: #1a0500;
  --footer-text: #ff6b5a;
  --footer-link: #ffb380;
  --footer-link-hover: #ffc299;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: 80vw;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 20px 0;
  background: var(--bg-secondary);
  margin-bottom: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--shadow);
}

h1 {
  font-size: 2em;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9em;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 500px;
  gap: 30px;
  height: 80vh;
  overflow: scroll;
}

.panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--shadow);
  max-height: calc(98vh - 255px);
  overflow: scroll;
}

.panel h2 {
  margin-bottom: 20px;
  font-size: 1.3em;
  color: var(--text-primary);
}

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

.inner-padding {
  padding: 30px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9em;
  color: var(--text-primary);
}

.required::after {
  content: " *";
  color: var(--accent-red);
}

input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9em;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-green);
}

textarea {
  resize: vertical;
  min-height: 60px;
  font-family: monospace;
  font-size: 0.85em;
}

.hint {
  font-size: 0.8em;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.output {
  position: sticky;
  max-height: calc(98vh - 255px);
  display: flex;
  flex-direction: column;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 20px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.5;
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
  transition: background 0.3s, color 0.3s;
}

/* Inline code in text */
p code,
li code,
td code {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Code blocks */
pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

button {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.9em;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--accent-green);
  color: white;
}

.btn-primary:hover {
  background: #45a049;
}

.btn-secondary {
  background: var(--accent-blue);
  color: white;
}

.btn-secondary:hover {
  background: #0b7dda;
}

.section-title {
  font-size: 1.1em;
  font-weight: 600;
  margin: 30px 0 15px 0;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0px;
  height: 50px;
  background: var(--bg-secondary);
  z-index: 10;
}

.section-title:first-child {
  margin-top: 0;
}

.subsection-title {
  font-size: 0.95em;
  font-weight: 600;
  margin: 20px 0 12px 0;
  color: var(--text-secondary);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 35px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: var(--bg-primary);
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.checkbox-item {
  display: flex;
  align-items: center;
}

.checkbox-item input {
  margin-right: 8px;
}

.checkbox-item label {
  margin: 0;
  font-weight: 400;
  font-size: 0.85em;
}

.icon-inputs {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: center;
}

.icon-inputs label {
  text-align: right;
  font-size: 0.85em;
}

.array-input {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  margin-top: 10px;
}

.array-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.array-item input,
.array-item select {
  flex: 1;
}

.btn-remove {
  background: var(--accent-red);
  color: white;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}

.btn-add {
  background: #3498db;
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  margin-top: 5px;
}

.btn-remove:hover {
  background: #c0392b;
}

.btn-add:hover {
  background: #2980b9;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #323232;
  color: white;
  padding: 16px 24px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collapsible::after {
  content: "▼";
  font-size: 0.8em;
}

.collapsible.collapsed::after {
  content: "▶";
}

.collapsible-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
  max-height: 0;
}

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

  .output {
    position: static;
    max-height: 600px;
  }
}

footer {
  color: var(--footer-text);
  text-align: center;
  background: var(--footer-bg);
  padding: 15px;
  width: 100%;
  margin-top: auto;
  position: absolute;
  bottom: 0;
  transition: background 0.3s, color 0.3s;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--footer-link);
  text-decoration: none;
  transition: color 0.3s;
}

footer a:hover {
  text-decoration: underline;
  color: var(--footer-link-hover);
}

/* ===== LIGHT THEME TOKENS (Default) - VIBRANT COLORS ===== */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6a737d;
  font-style: italic;
}

.token.punctuation {
  color: #24292e;
}

.token.property {
  color: #005cc5;
}

.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #d73a49;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #22863a;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #d73a49;
  background: transparent;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #d73a49;
}

.token.function,
.token.class-name {
  color: #6f42c1;
}

.token.regex,
.token.important,
.token.variable {
  color: #e36209;
}

/* ===== DARK THEME TOKENS ===== */
.theme-dark .token.comment,
.theme-dark .token.prolog,
.theme-dark .token.doctype,
.theme-dark .token.cdata {
  color: #6a9955;
  font-style: italic;
}

.theme-dark .token.punctuation {
  color: #d4d4d4;
}

.theme-dark .token.property {
  color: #9cdcfe;
}

.theme-dark .token.tag,
.theme-dark .token.boolean,
.theme-dark .token.number,
.theme-dark .token.constant,
.theme-dark .token.symbol,
.theme-dark .token.deleted {
  color: #b5cea8;
}

.theme-dark .token.selector,
.theme-dark .token.attr-name,
.theme-dark .token.string,
.theme-dark .token.char,
.theme-dark .token.builtin,
.theme-dark .token.inserted {
  color: #ce9178;
}

.theme-dark .token.operator,
.theme-dark .token.entity,
.theme-dark .token.url,
.theme-dark .language-css .token.string,
.theme-dark .style .token.string {
  color: #d4d4d4;
  background: transparent;
}

.theme-dark .token.atrule,
.theme-dark .token.attr-value,
.theme-dark .token.keyword {
  color: #c586c0;
}

.theme-dark .token.function,
.theme-dark .token.class-name {
  color: #dcdcaa;
}

.theme-dark .token.regex,
.theme-dark .token.important,
.theme-dark .token.variable {
  color: #d16969;
}

/* Bold and italic */
.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

.token.entity {
  cursor: help;
}

.token.namespace {
  opacity: 0.7;
}
