/* =========================================================
   niDar Tools — JSON Formatter & Validator
   Original Professional Tool UI
   ========================================================= */

:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --accent: #43a047;

  --bg: #f6f8f7;
  --card: #ffffff;
  --text: #17211b;
  --muted: #66736b;
  --border: #dfe7e1;

  --success: #2e7d32;
  --danger: #d32f2f;
  --warning: #ed6c02;

  --shadow: 0 12px 35px rgba(30, 60, 40, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(46, 125, 50, 0.08), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #f4f7f5 100%);
  color: var(--text);
  line-height: 1.6;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(46, 125, 50, 0.22);
  outline-offset: 2px;
}


/* =========================================================
   MAIN PAGE
   ========================================================= */

.json-tool-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 80px;
}


/* =========================================================
   HERO
   ========================================================= */

.tool-hero {
  max-width: 820px;
  margin: 0 auto 42px;
  text-align: center;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(46, 125, 50, 0.18);
  border-radius: 999px;
  background: rgba(232, 245, 233, 0.8);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.tool-hero h1 {
  margin: 16px 0 12px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: -1.8px;
}

.tool-hero p {
  max-width: 700px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 17px;
}


/* =========================================================
   WORKSPACE
   ========================================================= */

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.input-panel {
  border-top: 4px solid var(--primary);
}

.result-panel {
  border-top: 4px solid #5f6f65;
}


/* =========================================================
   PANEL HEADER
   ========================================================= */

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.panel-header > div:first-child {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-number {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 900;
}

.panel-title-group h2 {
  margin: 0 0 3px;
  font-size: 20px;
  line-height: 1.2;
}

.panel-title-group p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}


/* =========================================================
   EDITOR
   ========================================================= */

.editor-wrapper {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #101512;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #18201b;
}

.status-text,
.size-text {
  color: #cbd5ce;
  font-size: 12px;
  font-weight: 700;
}

#jsonInput,
#jsonOutput {
  display: block;
  width: 100%;
  min-height: 360px;
  padding: 18px;
  border: 0;
  border-radius: 0;
  outline: none;
  resize: vertical;

  background: #101512;
  color: #e6eee8;

  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace;

  font-size: 14px;
  line-height: 1.65;
  tab-size: 2;
}

#jsonInput::placeholder,
#jsonOutput::placeholder {
  color: #758279;
}

#jsonOutput {
  cursor: text;
}


/* =========================================================
   ACTION BUTTONS
   ========================================================= */

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
  min-height: 44px;
  border-radius: 12px;
  padding: 9px 16px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 18px rgba(46, 125, 50, 0.2);
}

.primary-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(46, 125, 50, 0.25);
}

.secondary-btn,
.icon-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.secondary-btn:hover,
.icon-btn:hover {
  border-color: rgba(46, 125, 50, 0.4);
  background: var(--primary-light);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.danger-btn {
  background: #fff4f4;
  color: var(--danger);
  border-color: #f1cccc;
}

.danger-btn:hover {
  background: #ffe8e8;
  transform: translateY(-1px);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}


/* =========================================================
   VALIDATION RESULT
   ========================================================= */

.validation-result {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-top: 16px;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid #c9e4cc;
  background: #f0f9f1;
}

.validation-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-weight: 900;
}

.validation-content strong {
  display: block;
  margin-bottom: 2px;
  color: var(--success);
  font-size: 15px;
}

.validation-content p {
  margin: 0;
  color: #4e6253;
  font-size: 13px;
}


/* Invalid state */
.validation-result.invalid {
  border-color: #efcaca;
  background: #fff4f4;
}

.validation-result.invalid .validation-icon {
  background: var(--danger);
}

.validation-result.invalid .validation-content strong {
  color: var(--danger);
}


/* =========================================================
   SECTION HEADINGS
   ========================================================= */

.section-heading {
  max-width: 720px;
  margin: 0 auto 24px;
  text-align: center;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.4px;
}

.section-heading h2 {
  margin: 0 0 7px;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}


/* =========================================================
   FORMATTING OPTIONS
   ========================================================= */

.options-section {
  margin-top: 55px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.option-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #fff;
}

.option-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.option-card select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}


/* =========================================================
   QUICK ACTIONS
   ========================================================= */

.quick-section {
  margin-top: 58px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.quick-card {
  min-height: 145px;
  padding: 22px 16px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 7px 24px rgba(30, 60, 40, 0.05);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.quick-card:hover {
  transform: translateY(-4px);
  border-color: rgba(46, 125, 50, 0.35);
  box-shadow: 0 14px 30px rgba(30, 60, 40, 0.09);
}

.quick-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  margin-bottom: 13px;
  border-radius: 13px;
  background: var(--primary-light);
  font-size: 20px;
}

.quick-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.quick-card small {
  color: var(--muted);
  font-size: 12px;
}


/* =========================================================
   HOW TO USE
   ========================================================= */

.info-section {
  margin-top: 60px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.info-card {
  position: relative;
  overflow: hidden;
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.info-number {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
}

.info-card h3 {
  margin: 0 0 7px;
  font-size: 18px;
}

.info-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}


/* =========================================================
   FEATURES
   ========================================================= */

.features-section {
  margin-top: 60px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.feature-card {
  padding: 23px 18px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: #fff;
  text-align: center;
}

.feature-card > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  border-radius: 14px;
  background: var(--primary-light);
  font-size: 21px;
}

.feature-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}


/* =========================================================
   PRIVACY NOTE
   ========================================================= */

.privacy-note {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 48px;
  padding: 20px 22px;
  border: 1px solid rgba(46, 125, 50, 0.2);
  border-radius: 17px;
  background:
    linear-gradient(
      135deg,
      rgba(232, 245, 233, 0.9),
      rgba(255, 255, 255, 0.95)
    );
}

.privacy-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #fff;
  font-size: 22px;
}

.privacy-note h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.privacy-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}


/* =========================================================
   DARK MODE
   ========================================================= */

html[data-theme="dark"] body,
body.dark-mode {
  --bg: #0d120f;
  --card: #151b17;
  --text: #edf5ef;
  --muted: #a6b3aa;
  --border: #2a352e;

  background:
    radial-gradient(circle at 10% 0%, rgba(46, 125, 50, 0.14), transparent 32%),
    linear-gradient(180deg, #0b100d 0%, #101612 100%);
  color: var(--text);
}

html[data-theme="dark"] .tool-badge,
body.dark-mode .tool-badge {
  background: rgba(46, 125, 50, 0.16);
  color: #a8e6ad;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .options-section,
html[data-theme="dark"] .option-card,
html[data-theme="dark"] .quick-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .feature-card,
body.dark-mode .panel,
body.dark-mode .options-section,
body.dark-mode .option-card,
body.dark-mode .quick-card,
body.dark-mode .info-card,
body.dark-mode .feature-card {
  background: var(--card);
  border-color: var(--border);
}

html[data-theme="dark"] .secondary-btn,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .danger-btn,
html[data-theme="dark"] select,
body.dark-mode .secondary-btn,
body.dark-mode .icon-btn,
body.dark-mode .danger-btn,
body.dark-mode select {
  background: #19211c;
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .secondary-btn:hover,
html[data-theme="dark"] .icon-btn:hover,
body.dark-mode .secondary-btn:hover,
body.dark-mode .icon-btn:hover {
  background: rgba(46, 125, 50, 0.18);
  color: #b7eabb;
}

html[data-theme="dark"] .danger-btn,
body.dark-mode .danger-btn {
  background: rgba(211, 47, 47, 0.1);
  border-color: rgba(211, 47, 47, 0.3);
}

html[data-theme="dark"] .validation-result,
body.dark-mode .validation-result {
  background: rgba(46, 125, 50, 0.1);
  border-color: rgba(76, 175, 80, 0.28);
}

html[data-theme="dark"] .validation-content p,
body.dark-mode .validation-content p {
  color: #b5c3b9;
}

html[data-theme="dark"] .privacy-note,
body.dark-mode .privacy-note {
  background: rgba(46, 125, 50, 0.1);
  border-color: rgba(76, 175, 80, 0.25);
}

html[data-theme="dark"] .privacy-icon,
body.dark-mode .privacy-icon {
  background: #19211c;
}

html[data-theme="dark"] .privacy-note p,
body.dark-mode .privacy-note p {
  color: var(--muted);
}


/* =========================================================
   SENIOR MODE
   ========================================================= */

html[data-theme="senior"] body {
  font-size: 18px;
  background: #000;
  color: #fff;
}

html[data-theme="senior"] .json-tool-page {
  width: min(1200px, calc(100% - 24px));
}

html[data-theme="senior"] .tool-badge,
html[data-theme="senior"] .panel,
html[data-theme="senior"] .options-section,
html[data-theme="senior"] .option-card,
html[data-theme="senior"] .quick-card,
html[data-theme="senior"] .info-card,
html[data-theme="senior"] .feature-card,
html[data-theme="senior"] .privacy-note {
  background: #111;
  color: #fff;
  border-color: #fff;
}

html[data-theme="senior"] .tool-hero h1,
html[data-theme="senior"] .panel-title-group h2,
html[data-theme="senior"] .section-heading h2,
html[data-theme="senior"] .info-card h3,
html[data-theme="senior"] .feature-card h3,
html[data-theme="senior"] .privacy-note h3,
html[data-theme="senior"] .quick-card strong {
  color: #fff;
}

html[data-theme="senior"] .tool-hero p,
html[data-theme="senior"] .panel-title-group p,
html[data-theme="senior"] .section-heading p,
html[data-theme="senior"] .info-card p,
html[data-theme="senior"] .feature-card p,
html[data-theme="senior"] .quick-card small,
html[data-theme="senior"] .privacy-note p {
  color: #fff;
}

html[data-theme="senior"] .tool-badge,
html[data-theme="senior"] .step-number,
html[data-theme="senior"] .quick-icon,
html[data-theme="senior"] .feature-card > span {
  background: #000;
  color: #ffeb3b;
  border: 2px solid #ffeb3b;
}

html[data-theme="senior"] .primary-btn {
  background: #00a000;
  color: #fff;
  border: 2px solid #fff;
}

html[data-theme="senior"] .secondary-btn,
html[data-theme="senior"] .icon-btn,
html[data-theme="senior"] .danger-btn,
html[data-theme="senior"] select {
  background: #000;
  color: #fff;
  border: 2px solid #fff;
}

html[data-theme="senior"] .section-kicker {
  color: #ffeb3b;
}

html[data-theme="senior"] .privacy-icon {
  background: #000;
  border: 2px solid #fff;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1000px) {

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

  .quick-grid,
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 680px) {

  .json-tool-page {
    width: min(100% - 20px, 560px);
    padding: 30px 0 55px;
  }

  .tool-hero {
    margin-bottom: 30px;
  }

  .tool-hero h1 {
    font-size: 34px;
    letter-spacing: -1px;
  }

  .tool-hero p {
    font-size: 15px;
  }

  .panel {
    padding: 17px;
    border-radius: 17px;
  }

  .panel-header {
    flex-direction: column;
    gap: 12px;
  }

  .panel-header > div:first-child {
    width: 100%;
  }

  .panel-header .secondary-btn {
    width: 100%;
  }

  .result-actions {
    width: 100%;
    justify-content: stretch;
  }

  .result-actions .icon-btn {
    flex: 1;
  }

  #jsonInput,
  #jsonOutput {
    min-height: 300px;
    padding: 14px;
    font-size: 13px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .action-row button {
    width: 100%;
  }

  .action-row .primary-btn {
    grid-column: 1 / -1;
  }

  .options-section {
    padding: 22px 16px;
  }

  .quick-grid,
  .features-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .quick-card {
    min-height: auto;
  }

  .privacy-note {
    align-items: flex-start;
  }
}


/* =========================================================
   SMALL PHONES
   ========================================================= */

@media (max-width: 420px) {

  .json-tool-page {
    width: calc(100% - 14px);
  }

  .tool-hero h1 {
    font-size: 29px;
  }

  .panel {
    padding: 13px;
  }

  .editor-toolbar {
    padding: 8px 10px;
  }

  .status-text,
  .size-text {
    font-size: 10px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .action-row .primary-btn {
    grid-column: auto;
  }

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

  .result-actions .icon-btn {
    width: 100%;
  }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
