/* ---------- THEME TOKENS (Light as base) ---------- */
:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --th-bg: #f9fafb;
  --ok: #15803d;
  --no: #b91c1c;
  --bar: #065f46;
  --bar-bg: #e5e7eb;

  --badge-fg: #111827;
  --badge-bg: #fafafa;
  --badge-br: #e5e7eb;

  --badge-modrinth-fg: #065f46;
  --badge-modrinth-bg: #ecfdf5;
  --badge-modrinth-br: #d1fae5;

  --badge-gh-fg: #92400e;
  --badge-gh-bg: #fffbeb;
  --badge-gh-br: #fde68a;
}

/* Explicit Dark */
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --border: #253042;
  --th-bg: #0f1620;
  --ok: #4ade80;
  --no: #f87171;
  --bar: #34d399;
  --bar-bg: #1f2937;

  --badge-fg: #e5e7eb;
  --badge-bg: #0f1620;
  --badge-br: #273244;

  --badge-modrinth-fg: #34d399;
  --badge-modrinth-bg: #10241d;
  --badge-modrinth-br: #134e4a;

  --badge-gh-fg: #f59e0b;
  --badge-gh-bg: #241a0a;
  --badge-gh-br: #4b3713;
}

/* System Dark (applies only when data-theme=system AND OS is dark) */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0b0f14;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #253042;
    --th-bg: #0f1620;
    --ok: #4ade80;
    --no: #f87171;
    --bar: #34d399;
    --bar-bg: #1f2937;

    --badge-fg: #e5e7eb;
    --badge-bg: #0f1620;
    --badge-br: #273244;

    --badge-modrinth-fg: #34d399;
    --badge-modrinth-bg: #10241d;
    --badge-modrinth-br: #134e4a;

    --badge-gh-fg: #f59e0b;
    --badge-gh-bg: #241a0a;
    --badge-gh-br: #4b3713;
  }
}

/* ---------- Base UI ---------- */
html, body { height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg) url('bg.svg') no-repeat top left;
  color: var(--fg);
  padding: 1rem;
}
label, input, button, select { font-size: 1rem; color: var(--fg); }
input, select, button { background: var(--bg); border: 1px solid var(--border); border-radius: .4rem; padding: .35rem .5rem; }
button { cursor: pointer; }
button:hover { filter: brightness(1.03); }

/* Primary action buttons (Check and Build) */
#run, #build {
  background: var(--badge-modrinth-bg);
  border-color: var(--badge-modrinth-br);
  color: var(--badge-modrinth-fg);
  font-weight: 500;
}

#run:hover, #build:hover {
  filter: brightness(1.1);
}

#run:disabled, #build:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

/* Custom file input styling */
.file-input-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#file {
  position: absolute;
  opacity: 0;
  width: 0.1px;
  height: 0.1px;
  overflow: hidden;
}

.file-input-label {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  cursor: pointer;
  color: var(--fg);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.file-input-label:hover {
  background: var(--th-bg);
  border-color: var(--badge-modrinth-br);
}

.file-name {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
.controls { display:flex; gap:.75rem; align-items:center; flex-wrap: wrap; }
.control-row { flex-basis: 100%; display: flex; align-items: center; gap: .75rem; }
.muted { color: var(--muted); }
h2 { margin: 1.5rem 0 .5rem; font-size: 1.2rem; }
table { border-collapse: collapse; margin-top: .5rem; width: 100%; }
th, td { border: 1px solid var(--border); padding: .5rem; text-align: left; vertical-align: top; }
th { background: var(--th-bg); }
.ok { color: var(--ok); }
.no { color: var(--no); }
pre { white-space: pre-wrap; }
.bar { height: 10px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; margin-top:.25rem; }
.bar > span { display:block; height:100%; width:0%; background: var(--bar); transition: width .15s linear; }
.status { display:flex; align-items:center; gap:.5rem; margin-top:.5rem; }
.status small { color: var(--muted); }
.counts { font-size:.95rem; color: var(--fg); }
.badge {
  display:inline-block; padding:.125rem .4rem; border-radius:.45rem; font-size:.8rem; line-height:1;
  border:1px solid var(--badge-br); background: var(--badge-bg); color: var(--badge-fg); text-decoration: none;
}
.badge.modrinth { border-color: var(--badge-modrinth-br); background: var(--badge-modrinth-bg); color: var(--badge-modrinth-fg); }
.badge.github-fallback { border-color: var(--badge-gh-br); background: var(--badge-gh-bg); color: var(--badge-gh-fg); }
.small { font-size:.9rem; }

/* ---------- Floating theme controls ---------- */
.theme-switch {
  position: fixed;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 1000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.theme-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 999px;
  line-height: 1;
  font-size: 18px;
  color: var(--fg);
}
.theme-btn.active {
  border-color: var(--border);
  background: var(--th-bg);
}
.theme-btn:hover {
  background: var(--th-bg);
}

/* ---------- Help Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  color: var(--fg);
  font-size: 1.25rem;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
}

.modal-close:hover {
  background: var(--th-bg);
  color: var(--fg);
}

.modal-body {
  padding: 1.25rem;
}

.modal-body h3 {
  color: var(--fg);
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p, .modal-body li {
  color: var(--fg);
  line-height: 1.5;
}

.modal-body ol, .modal-body ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.modal-body ol li, .modal-body ul li {
  margin-bottom: 0.25rem;
}

.modal-body strong {
  color: var(--fg);
}

/* ---------- Missing Items UI ---------- */
.missing-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Missing Items Button */
#missing-items-btn {
  color: #dc2626; /* Red color */
}

#missing-items-btn svg {
  color: #dc2626; /* Red color for the X */
}

#missing-items-btn.checking svg {
  animation: rotate 1s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.missing-items-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.missing-check-btn, .missing-clear-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
}

.missing-check-btn:hover, .missing-clear-btn:hover {
  background: var(--th-bg);
}

.missing-check-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.missing-clear-btn {
  background: var(--no);
  color: white;
  border-color: var(--no);
}

.missing-clear-btn:hover {
  filter: brightness(1.1);
  background: var(--no);
}

.missing-status {
  font-size: 0.875rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

.missing-items-list {
  max-height: 400px;
  overflow-y: auto;
}

.missing-item {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
}

.missing-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.25rem;
}

.missing-item-name {
  font-weight: 600;
  color: var(--fg);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.missing-item-mc {
  font-weight: normal;
  color: var(--muted);
  font-size: 0.875rem;
}

.missing-item-status {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 1px solid;
}

.missing-item-status.found {
  background: var(--badge-modrinth-bg);
  border-color: var(--badge-modrinth-br);
  color: var(--badge-modrinth-fg);
}

.missing-item-status.not-found {
  background: var(--badge-gh-bg);
  border-color: var(--badge-gh-br);
  color: var(--badge-gh-fg);
}

.missing-item-details {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.25rem 0;
  line-height: 1.4;
}

.missing-item-details strong {
  color: var(--fg);
}

.missing-item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  justify-content: space-between;
  flex-wrap: wrap;
}

.missing-item-actions > div {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.missing-item-lastcheck {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}

.missing-item-lastcheck strong {
  color: var(--fg);
}

.missing-item-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.missing-item-remove:hover {
  background: var(--th-bg);
  color: var(--fg);
}

.missing-item-view {
  background: var(--badge-modrinth-bg);
  border: 1px solid var(--badge-modrinth-br);
  color: var(--badge-modrinth-fg);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
  text-decoration: none;
}

.missing-item-view:hover {
  filter: brightness(1.1);
}

/* ---------- Notification Toast ---------- */
.notification-toast {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 3000;
  max-width: 400px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification-content {
  background: var(--badge-modrinth-bg);
  border: 1px solid var(--badge-modrinth-br);
  color: var(--badge-modrinth-fg);
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.notification-close {
  background: transparent;
  border: none;
  color: var(--badge-modrinth-fg);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}

.notification-close:hover {
  opacity: 1;
}