/* ========= Base / Variables ========= */
:root {
  /* layout */
  --sidebar-w: 200px;
  --bg: #f7f9fc;
  --panel-bg: #f1f1f1;
  --text: #1a1a1a;
  --shadow-lg: 0 8px 20px rgba(0,0,0,.08);
  --shadow-md: 0 4px 10px rgba(0,0,0,.07);
  --radius: 6px;

  /* fluid spacing & typography (final, denser) */
  --space: clamp(10px, 1vw, 18px);
  --font-size-base: clamp(15px, 1.1vw + 10px, 18px);
  --font-size-h1: clamp(28px, 2.6vw + 12px, 42px);
  --font-size-h2: clamp(20px, 1.4vw + 10px, 24px);

  /* colors */
  --link: #1976d2;
  --link-hover: #0d47a1;
  --primary: #05bff8;
  --primary-hover: #244af3;
  --primary-active: #120c70;

  /* fonts */
  --font-display: "Orbitron", Arial, sans-serif; /* headers/sidebar/buttons */
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

html, body { height: 100%; }

/* ========= Body / Global ========= */
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  letter-spacing: 0;            /* readability */
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;

  /* left rail offset */
  margin-left: var(--sidebar-w);
  padding-left: 10px;
}

/* ========= Main Wrapper ========= */
#content-wrapper {
  margin-left: 0;
  padding: var(--space);
  max-width: 1280px;            /* widened */
  margin-right: auto;
  margin-left: auto;
}

/* ========= Headings / Titles (display font) ========= */
header h1,
header h2,
.section-title,
.card h3,
.accordion summary {
  font-family: var(--font-display);
  letter-spacing: 0.3px;
  line-height: 1.2;
}
header h1 { font-size: var(--font-size-h1); margin: 0 0 6px; }
header h2 { font-size: var(--font-size-h1); margin: 0 0 6px; }
.section-title { font-size: var(--font-size-h2); }
.card h3 { font-size: var(--font-size-h2); margin: 0 0 10px; }

/* ========= Forms / Inputs ========= */
/* Inherit body font by default for any control type */
input, select, textarea { font: inherit; }

/* Explicit sizing/appearance for common types */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;           /* larger */
  margin: 6px 0;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  background: #fff;
  transition: box-shadow .15s ease, border-color .15s ease;
  font-family: var(--font-body);
  font-size: 1rem;              /* larger */
  letter-spacing: 0;
  line-height: 1.45;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #90caf9;
  box-shadow: 0 0 0 2px #bbdefb;
}

/* Placeholders match body font */
input::placeholder,
textarea::placeholder {
  font: inherit;
  color: #9aa3af;
  opacity: 1;
}

/* ========= Buttons (display font) ========= */
button,
.button {
  display: inline-block;
  width: auto;
  min-width: 10.5em;            /* wider */
  color: rgba(255,255,255,.95);
  background-color: var(--primary);
  padding: 12px 16px;           /* larger */
  margin: 8px 6px 8px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 5px 5px 7px rgba(0,0,0,.2);
  transition: transform .05s ease, box-shadow .15s ease, background-color .15s ease;
  font-family: var(--font-display);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 600;
}
button:hover { background-color: var(--primary-hover); }
button:active {
  background-color: var(--primary-active);
  transform: translateY(2px);
  box-shadow: 1px 1px 3px rgba(0,0,0,.25);
}
button:disabled,
button[aria-disabled="true"] {
  opacity: .6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Specific spacing for Export JSON button */
#exportButton { margin-left: 10px; }

/* ========= Panels / Layout ========= */
#content-wrapper > div,
.left-column,
.right-column,
.left,
.right,
.card {
  border-radius: var(--radius);
  background-color: var(--panel-bg);
  padding: clamp(12px, 1.2vw, 18px);  /* tighter but responsive */
  box-shadow: var(--shadow-md);
}
.card { margin-bottom: 16px; }
.card .body { margin-top: 6px; }

/* Two-column layout */
.columns,
main {
  display: flex;
  gap: 16px;                    /* tighter gap */
  flex-wrap: wrap;
}

.left,
.left-column {
  flex: 1 1 640px;
  min-width: 420px;
  max-width: 60%;               /* editor wider */
}
.right,
.right-column {
  flex: 1 1 480px;
  min-width: 360px;
  max-width: 40%;
}

/* ========= Grid rows inside cards ========= */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0;
}
.row > div { min-width: 0; } /* prevents overflow with long UA strings */

/* ========= JSON / Code Areas ========= */
#referralJson,
.mono {
  min-height: 110px;
  font-family: var(--font-code);
  font-size: 1rem;              /* match body */
  line-height: 1.5;
  letter-spacing: 0;            /* alignment */
}
#referralJson { min-height: 400px; } /* taller editor */

/* ========= Control Rows ========= */
.controls,
.inline-controls,
.section-header,
.btns {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.btns button { white-space: nowrap; }

/* ========= Accordion (right column) using <details> ========= */
.accordion details {
  background: #f8fafc;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 12px;
  overflow: hidden; /* keeps rounded corners when pane opens */
}
.accordion summary {
  list-style: none;  /* hide default triangle in some browsers */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: #eef2ff;
  border-bottom: 1px solid #dbeafe;
  position: relative;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: "▸";
  font-family: var(--font-display);
  transform: rotate(0deg);
  transition: transform .2s ease;
}
.accordion details[open] summary::after { transform: rotate(90deg); }
.accordion .pane { padding: 12px 14px; background: #fff; }
.accordion .pane label { display: block; font-weight: 600; margin: 8px 0 4px; }

/* Helper text */
.small { font-size: 0.92rem; color: #4b5563; line-height: 1.5; }

/* PayPal Buttons container */
#paypal-button-container { width: 100%; margin: 8px 0 10px; }

/* ========= Sidebar (display font) ========= */
#sidebar {
  background: linear-gradient(180deg, #e3f2fd 0%, #b3e5fc 100%);
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 20px 10px 20px 20px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.07);
  z-index: 100;
  overflow-y: auto;
  font-family: var(--font-display);
  letter-spacing: 0.2px;
}
#sidebar h2 {
  font-size: 1.1rem;
  margin: 16px 0 8px;
  font-weight: 700;
  color: #1565c0;
  letter-spacing: 0.4px;
}
#sidebar ul { list-style: none; padding-left: 0; margin: 0 0 10px; }
#sidebar ul li { margin-bottom: 6px; }
#sidebar a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  transition: color .15s ease, text-decoration-color .15s ease;
  letter-spacing: 0.2px;
}
#sidebar a:hover { color: var(--link-hover); text-decoration: underline; }
.sidebar-section { margin-bottom: 12px; }
.dropdown-toggle {
  width: 100%;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 4px;
  text-align: left;
  transition: background .15s ease, box-shadow .15s ease;
  font-family: var(--font-display);
  letter-spacing: 0.3px;
  text-transform: none;
}
.dropdown-toggle:hover { background: #1565c0; }
.dropdown-toggle:focus, .dropdown-toggle:active {
  outline: 2px solid #1565c0; box-shadow: 0 0 0 2px #90caf9;
}
.dropdown-menu {
  max-height: 0;
  overflow: hidden;
  background: #e3f2fd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 6px;
  transition: max-height .25s cubic-bezier(.4,0,.2,1), padding .25s cubic-bezier(.4,0,.2,1);
  padding: 0 0 0 12px;
}
.dropdown-menu.open { max-height: 500px; padding: 8px 0 8px 12px; }
.dropdown-menu li { margin-bottom: 4px; }
.dropdown-menu a { color: var(--link); font-size: .98em; }

/* ========= Responsive ========= */
@media (max-width: 1100px) {
  .left, .right, .left-column, .right-column { max-width: 100%; flex-basis: 100%; }
  .row { grid-template-columns: 1fr; }

  /* Ensure min-widths don't force horizontal scrolling on narrow devices */
  .left, .right, .left-column, .right-column { min-width: 0; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  body { margin-left: 0; }
  #sidebar { display: none; }
  .controls button, .inline-controls button { width: 100%; }

  /* Make inputs and primary buttons full width for touch usability */
  input, select, textarea, button, .button {
    width: 100%;
    min-width: 0;
  }

  /* Reduce gaps and padding slightly for small screens */
  .columns, main { gap: 12px; }
  #content-wrapper { padding: calc(var(--space) * 0.75); }
}

/* ========= Optional Dark Mode ========= */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1117;
    --panel-bg: #0f172a;
    --text: #e5e7eb;
    --link: #93c5fd;
    --link-hover: #bfdbfe;
  }
  #content-wrapper > div,
  .left, .right,
  .left-column, .right-column,
  .section, .card { box-shadow: var(--shadow-lg); }
}