/* ============================================================
   Combination Sum Finder — Stylesheet
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #232733;
  --border:    #2e3347;
  --text:      #e1e4ed;
  --text-dim:  #8b90a5;
  --accent:    #6c8cff;
  --accent-bg: rgba(108,140,255,.12);
  --green:     #4ade80;
  --green-bg:  rgba(74,222,128,.10);
  --red:       #f87171;
  --red-bg:    rgba(248,113,113,.10);
  --yellow:    #facc15;
  --yellow-bg: rgba(250,204,21,.10);
  --orange:    #fb923c;
  --radius:    10px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:      'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- Skip Link (Accessibility) ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 6px 6px;
  z-index: 9999;
  font-weight: 600;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus {
  top: 0;
}

/* ---------- Layout ---------- */
.app {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.header { text-align: center; margin-bottom: 24px; }
.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.header .icon { color: var(--accent); margin-right: 4px; }
.subtitle { color: var(--text-dim); margin-top: 4px; font-size: .9rem; }

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 820px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.panel h2 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-header h2 { margin-bottom: 0; }
.panel-actions { display: flex; gap: 6px; }

/* ---------- Input Panel ---------- */
.hint { color: var(--text-dim); font-size: .8rem; margin-bottom: 6px; }
.hint-inline { color: var(--text-dim); font-weight: 400; font-size: .82rem; }

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: .86rem;
  padding: 9px 11px;
  transition: border-color .15s;
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
textarea { resize: vertical; }

.input-row { margin-top: 12px; }
.input-row label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- Drop Zone ---------- */
.input-panel.drop-active {
  border: 2px dashed var(--accent) !important;
  background: var(--accent-bg) !important;
}

/* ---------- Line List ---------- */
.line-list {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
  border-radius: 6px;
}
.line-list::-webkit-scrollbar { width: 5px; }
.line-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.le-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
  transition: background .1s;
}
.le-row:last-child { border-bottom: none; }
.le-row:hover { background: rgba(255,255,255,.03); }

.le-num {
  color: var(--text-dim);
  font-size: .75rem;
  font-family: var(--mono);
  min-width: 32px;
}
.le-val {
  flex: 1;
  font-family: var(--mono);
  color: var(--text);
}
.le-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .82rem;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: .4;
  transition: opacity .15s, background .15s;
}
.le-btn:hover { opacity: 1; background: rgba(255,255,255,.06); }

/* Excluded */
.le-excluded { opacity: .35; }
.le-excluded .le-val { text-decoration: line-through; }
.le-excluded .le-exc-btn { opacity: .8; color: var(--yellow); }

/* Pinned */
.le-pinned { background: var(--accent-bg); border-left: 3px solid var(--accent); }
.le-pinned .le-pin-btn { opacity: 1; }
.le-pinned .le-val { color: var(--accent); font-weight: 600; }

/* Highlight (hover cross-reference) */
.le-highlight {
  background: var(--green-bg) !important;
  border-left: 3px solid var(--green);
}
.le-highlight .le-val { color: var(--green); }

.le-empty {
  padding: 12px;
  color: var(--text-dim);
  font-size: .82rem;
  text-align: center;
}

/* ---------- Options Panel ---------- */
.opt-group { margin-bottom: 12px; }
.opt-group label:not(.toggle-label) {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.opt-hint { color: var(--text-dim); font-size: .76rem; margin-top: 2px; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  cursor: pointer;
}
.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.opt-row { display: flex; gap: 12px; }
.opt-row .half { flex: 1; }

select { appearance: auto; cursor: pointer; }

/* ---------- Search Estimate ---------- */
.search-estimate {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .82rem;
  background: var(--surface2);
  color: var(--text-dim);
  margin-bottom: 10px;
}
.search-estimate.warn {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(250,204,21,.25);
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #5a7aef; }
.btn-primary:active { transform: scale(.98); }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn-row .btn-primary { flex: 1; }

.btn-cancel {
  padding: 11px 22px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-cancel:hover { background: rgba(248,113,113,.2); }
.btn-narrow { width: auto; padding: 10px 28px; }

.btn-sm {
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--border); }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.btn-test { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.btn-test:hover { background: var(--accent); color: #fff; }

.btn-danger { background: var(--red-bg); border-color: rgba(248,113,113,.3); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,.2); }

/* ---------- Results ---------- */
.results-panel { margin-bottom: 18px; }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.results-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: .76rem;
  padding: 2px 9px;
  border-radius: 20px;
  margin-left: 6px;
  font-weight: 600;
}
.warn-badge { background: var(--yellow-bg); color: var(--yellow); }
.err-badge  { background: var(--red-bg); color: var(--red); }

.results-meta {
  color: var(--text-dim);
  font-size: .82rem;
  margin-bottom: 10px;
}

.results-body {
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}
.results-body::-webkit-scrollbar { width: 5px; }
.results-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Combo card */
.combo-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  transition: border-color .15s, background .15s;
  cursor: default;
}
.combo-card:hover {
  border-color: var(--accent);
  background: rgba(108,140,255,.04);
}

.combo-idx {
  font-size: .73rem;
  color: var(--text-dim);
  margin-bottom: 3px;
  font-weight: 600;
}
.combo-values {
  font-family: var(--mono);
  font-size: .86rem;
  word-break: break-word;
}
.combo-values .val { color: var(--green); }
.combo-values .sep { color: var(--text-dim); margin: 0 3px; }
.combo-values .eq  { color: var(--accent); margin: 0 5px; font-weight: 700; }

.combo-delta {
  color: var(--orange);
  font-size: .78rem;
  margin-left: 4px;
}

.combo-lines {
  margin-top: 3px;
  font-size: .76rem;
  color: var(--text-dim);
}

/* ---------- Batch groups ---------- */
.batch-group {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.batch-group[open] { background: rgba(255,255,255,.01); }

.batch-summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: .9rem;
  background: var(--surface2);
  transition: background .15s;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.batch-summary::-webkit-details-marker { display: none; }
.batch-summary::before {
  content: "▸";
  color: var(--text-dim);
  transition: transform .15s;
  font-size: .8rem;
}
.batch-group[open] > .batch-summary::before { transform: rotate(90deg); }
.batch-summary:hover { background: var(--border); }

.batch-results { padding: 6px 10px; }

/* ---------- History ---------- */
.history-panel {
  margin-bottom: 18px;
  cursor: default;
}
.history-panel > summary {
  cursor: pointer;
  padding: 14px 20px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: .92rem;
}
.history-panel > summary::-webkit-details-marker { display: none; }
.history-panel > summary::before {
  content: "▸";
  color: var(--text-dim);
  transition: transform .15s;
}
.history-panel[open] > summary::before { transform: rotate(90deg); }

.history-body { padding: 4px 0; }

.history-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.history-entry:last-child { border-bottom: none; }

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-date {
  color: var(--text-dim);
  font-size: .76rem;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 30px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.modal-content h3 { margin-bottom: 12px; font-size: 1.08rem; }
.modal-content p { color: var(--text-dim); margin-bottom: 16px; font-size: .9rem; line-height: 1.5; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-close {
  margin-top: 16px;
  display: block;
  margin-left: auto;
}

/* ---------- Shortcuts table ---------- */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}
.shortcuts-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.shortcuts-table td:first-child {
  white-space: nowrap;
  padding-right: 20px;
}

kbd {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
}

/* ---------- Tests ---------- */
.test-panel { margin-bottom: 18px; }
.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.test-results { font-family: var(--mono); font-size: .82rem; }
.test-pass { color: var(--green); }
.test-fail { color: var(--red); }
.test-item { padding: 3px 0; border-bottom: 1px solid var(--border); }
.test-item:last-child { border-bottom: none; }
.test-summary {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
}
.test-summary.pass { background: var(--green-bg); color: var(--green); }
.test-summary.fail { background: var(--red-bg); color: var(--red); }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: .76rem;
  padding-top: 8px;
}
.footer-shortcuts { margin-top: 4px; }
.footer-shortcuts kbd { font-size: .7rem; }

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- No-results ---------- */
.no-results {
  text-align: center;
  padding: 28px 10px;
  color: var(--text-dim);
  font-size: .92rem;
}
.no-results .big { font-size: 2rem; margin-bottom: 4px; }
