/* styles.css — Text Compare web app */

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

:root {
  --color-bg:               #0f1117;
  --color-surface:          #1a1d27;
  --color-surface-2:        #21253a;
  --color-border:           #2e3245;
  --color-text:             #e2e8f0;
  --color-muted:            #8892a4;
  --color-accent:           #6c7fe8;

  /* Diff colours */
  --color-added-bg:         #0d3321;
  --color-added-gutter:     #22543d;
  --color-added-bar:        #38a169;
  --color-removed-bg:       #3d1515;
  --color-removed-gutter:   #742a2a;
  --color-removed-bar:      #e53e3e;
  --color-changed-bg:       #2d2510;
  --color-changed-gutter:   #6b4c12;
  --color-changed-bar:      #d69e2e;
  --color-empty-bg:         #13151e;
  --color-inline-add:       #276749;
  --color-inline-del:       #9b2c2c;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius:   8px;
}

/* ─── Base ─────────────────────────────────────────────── */

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ────────────────────────────────────────────── */

header {
  padding: 1.25rem 2rem 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.83rem;
  color: var(--color-muted);
}

/* ─── Main layout ───────────────────────────────────────── */

main {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Input section ─────────────────────────────────────── */

.input-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input-pane label {
  display: block;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  margin-bottom: 0.4rem;
}

.input-pane textarea {
  width: 100%;
  height: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  padding: 0.7rem 1rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  tab-size: 2;
}

.input-pane textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(108, 127, 232, 0.2);
}

/* ─── Toolbar ───────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.btn-primary:hover  { filter: brightness(1.15); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
  border-color: var(--color-muted);
  color: var(--color-text);
}

.divider {
  width: 1px;
  height: 1.4rem;
  background: var(--color-border);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}
.toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* ─── Stats bar ─────────────────────────────────────────── */

.stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  padding: 0.5rem 0 0.75rem;
  flex-wrap: wrap;
}
.stat-added   { color: #68d391; }
.stat-removed { color: #fc8181; }
.stat-changed { color: #f6ad55; }
.stat-equal   { color: var(--color-muted); font-style: italic; }

.hidden { display: none !important; }

/* ─── Diff output ───────────────────────────────────────── */

.diff-output {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.diff-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.diff-header span {
  padding: 0.45rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}
.diff-header span:first-child {
  border-right: 1px solid var(--color-border);
}

/* ─── Diff rows ─────────────────────────────────────────── */

.diff-rows { overflow-x: auto; }

.diff-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.diff-row:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}
.diff-row:hover .diff-cell {
  filter: brightness(1.06);
}

.diff-cell {
  display: flex;
  align-items: stretch;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  min-height: 1.65em;
}
.diff-cell:first-child {
  border-right: 1px solid var(--color-border);
}

/* Cell type backgrounds */
.diff-cell.equal   { background: transparent; }
.diff-cell.added   { background: var(--color-added-bg);   border-left: 3px solid var(--color-added-bar);   }
.diff-cell.removed { background: var(--color-removed-bg); border-left: 3px solid var(--color-removed-bar); }
.diff-cell.changed { background: var(--color-changed-bg); border-left: 3px solid var(--color-changed-bar); }
.diff-cell.empty   { background: var(--color-empty-bg);   }

/* Line number gutter */
.line-num {
  min-width: 3.2rem;
  padding: 0.18rem 0.5rem 0.18rem 0.25rem;
  text-align: right;
  color: var(--color-muted);
  font-size: 0.7rem;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: rgba(0, 0, 0, 0.18);
  opacity: 0.85;
}
.empty-num { opacity: 0; }

/* Line content */
.line-content {
  padding: 0.18rem 0.85rem;
  word-break: break-all;
  white-space: pre-wrap;
  flex: 1;
  min-width: 0;
}

/* ─── Inline highlights ──────────────────────────────────── */

.inline-add {
  background: var(--color-inline-add);
  border-radius: 2px;
  padding: 0 1px;
}
.inline-del {
  background: var(--color-inline-del);
  border-radius: 2px;
  padding: 0 1px;
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.4);
}

/* ─── Footer ────────────────────────────────────────────── */

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

/* ─── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  main { padding: 1rem 1rem 2rem; }

  .input-section { grid-template-columns: 1fr; }

  .diff-header,
  .diff-row { grid-template-columns: 1fr; }

  .diff-header span:first-child {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .diff-cell:first-child {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .divider { display: none; }
}

@media (max-width: 480px) {
  header { padding: 1rem; }
  header h1 { font-size: 1.2rem; }
}
