/* Pinfluence Pipeline — styled to match the Pinfluence (Discover/Keywords)
   design system: warm neutrals + brand red, Geist type, white cards, pill
   buttons. Token values mirror frontend/src/app/globals.css (--ml-*) in the
   Pinfluenced-Keywords sister repo. */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --surface-3: #f0efec;
  --ink: #15171a;
  --ink-1: #2b2d32;
  --ink-2: #5a5e68;
  --ink-3: #8a8f99;
  --line: #e7e6e2;
  --line-2: #d9d8d3;
  --brand: #e33d2f;
  --brand-d: #b8302a;
  --brand-l: #fbe6e3;
  --brand-ll: #fdf4f2;
  --good: #0d7d3c;
  --good-s: #e3f3e9;
  --warn: #d9a514;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---- app shell: Discover-style sidebar + content ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 288px; z-index: 5;
  display: flex; flex-direction: column; gap: 20px;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 12px 24px 16px; overflow-y: auto;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 10px 0; text-decoration: none; }
.brand-penguin { height: 42px; width: auto; }
.brand-word { display: flex; align-items: baseline; gap: 7px; }
.brand-red { color: var(--brand); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { color: var(--ink); font-size: 13px; font-weight: 800; letter-spacing: 0.22em; }

.side-nav { display: flex; flex-direction: column; flex: 1; }
.side-label { padding: 0 12px; margin: 0 0 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.side-section { display: flex; flex-direction: column; gap: 8px; }
.side-tools { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.side-item {
  display: flex; align-items: center; gap: 12px;
  border-radius: 8px; padding: 8px 12px;
  font-size: 14px; font-weight: 600; color: var(--ink-1);
  text-decoration: none; cursor: pointer; transition: background .15s, color .15s;
}
.side-item:hover { background: var(--surface-2); color: var(--ink); }
.side-item.current, .side-item.nav.active,
.side-item.current:hover, .side-item.nav.active:hover { background: var(--surface-3); color: var(--brand); }
.side-item svg { width: 20px; height: 20px; flex: none; }
.side-item .ext { width: 16px; height: 16px; margin-left: auto; color: var(--ink-3); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 12px 0; font-size: 11px; color: var(--ink-3); }

.content { margin-left: 288px; flex: 1; min-width: 0; }
.topbar {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.batchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .sidebar { width: 76px; padding: 12px 10px; }
  .sidebar .brand-word, .side-item span, .side-label, .side-foot, .side-item .ext { display: none; }
  .side-item { justify-content: center; }
  .side-logo { justify-content: center; }
  .content { margin-left: 76px; }
}

/* ---- controls ---- */
button, select, input[type="date"], input[type="time"], input[type="number"] {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-1);
  cursor: pointer;
}
select, input[type="date"], input[type="time"], input[type="number"] {
  border-radius: var(--radius); font-weight: 500; cursor: auto;
}
button:hover { background: var(--surface-3); }

/* primary red pill — the Pinfluence CTA */
#addPin, #savePrompt, #schedApply, #defSave, #libAddRows {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700;
}
#addPin:hover, #savePrompt:hover, #schedApply:hover, #defSave:hover, #libAddRows:hover {
  background: var(--brand-d); border-color: var(--brand-d);
}
/* soft brand chips — secondary emphasis */
#exportCsv, #importCsv {
  background: var(--brand-ll); border-color: var(--brand-l); color: var(--brand-d);
}
#exportCsv:hover, #importCsv:hover { background: var(--brand-l); border-color: var(--brand); }

#status { color: var(--ink-3); font-size: 12px; font-weight: 500; }

/* ---- grid ---- */
main { padding: 20px; }
table {
  border-collapse: separate; border-spacing: 0; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
th, td { padding: 10px 12px; vertical-align: top; text-align: left; border-bottom: 1px solid var(--surface-3); }
td { border-right: 1px solid var(--surface-3); }
td:last-child { border-right: none; }
tr:last-child td { border-bottom: none; }
th {
  background: var(--surface-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
td [contenteditable] { min-width: 120px; min-height: 20px; outline: none; border-radius: 6px; }
td [contenteditable]:focus { background: var(--brand-ll); box-shadow: 0 0 0 2px var(--brand-l); }
.imgcell { width: 120px; }
.imgcell img { max-width: 110px; max-height: 110px; border-radius: 8px; display: block; }
.imgcell.drop { outline: 2px dashed var(--brand); background: var(--brand-ll); }
.handle { cursor: grab; color: var(--ink-3); user-select: none; }
tr.dragging { opacity: .4; }
.hint { color: var(--ink-3); font-size: 12px; margin-top: 10px; }

/* row actions */
.del { color: var(--brand-d); border-color: var(--brand-l); background: var(--surface); padding: 5px 10px; }
.del:hover { background: var(--brand-ll); }
button.dup { color: var(--ink-2); border-color: var(--line-2); margin-right: 4px; padding: 5px 10px; }

/* schedule inputs inside the grid */
td input[type="datetime-local"] { font: inherit; font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink-1); }

/* ---- panels (prompts / images / schedule / defaults) ---- */
#promptsPanel, #libraryPanel, #schedPanel, #defaultsPanel {
  margin: 20px 20px 0; padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
#promptsPanel { max-width: 780px; }
#promptsPanel h2, #libraryPanel h2, #schedPanel h2, #defaultsPanel h2 {
  margin: 0 0 6px; font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
}
#promptsPanel .hint, #libraryPanel .hint, #schedPanel .hint, #defaultsPanel .hint { margin: 0 0 12px; }
#promptsPanel code, #libraryPanel code {
  background: var(--surface-3); padding: 1px 6px; border-radius: 5px;
  font: 12px "Geist Mono", ui-monospace, Consolas, monospace;
}
.promptbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
#schedPanel label, #defaultsPanel label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-1); font-weight: 500; }
#schedPanel input, #defaultsPanel input, #promptName {
  font: inherit; font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
#schedPanel input[type="checkbox"], #defaultsPanel input[type="checkbox"] { width: auto; accent-color: var(--brand); }
#promptName { width: 100%; margin-bottom: 10px; }
#promptText {
  width: 100%; padding: 12px;
  font: 13px/1.55 "Geist Mono", ui-monospace, Consolas, monospace;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  margin-bottom: 10px; resize: vertical; color: var(--ink-1); background: var(--surface-2);
}
button.danger { color: var(--brand-d); border-color: var(--brand-l); }
button.danger:hover { background: var(--brand-ll); }

/* status flash */
.flash { padding: 8px 12px; border-radius: var(--radius); margin: 14px 20px 0; font-size: 12.5px; font-weight: 500; line-height: 1.4; }
.flash.ok { background: var(--good-s); color: var(--good); border: 1px solid #cbe7d6; }
.flash.err { background: var(--brand-ll); color: var(--brand-d); border: 1px solid var(--brand-l); }

/* ---- images tray ---- */
#libDrop {
  border: 2px dashed var(--line-2); border-radius: var(--radius);
  padding: 20px; text-align: center; color: var(--ink-3); font-weight: 500;
  cursor: pointer; margin-bottom: 14px; background: var(--surface-2);
}
#libDrop:hover, #libDrop.drop { border-color: var(--brand); background: var(--brand-ll); color: var(--brand-d); }
#libGrid { display: flex; flex-wrap: wrap; gap: 12px; }
.libitem { width: 108px; position: relative; }
.libitem img { width: 108px; height: 162px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: grab; display: block; }
.libitem img:active { cursor: grabbing; }
.libitem.libused img { opacity: .5; }
.libcheck { position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; accent-color: var(--brand); }
.libbar { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.libbadge { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.libitem:not(.libused) .libbadge { color: #fff; background: var(--brand); padding: 1px 6px; border-radius: 4px; }
.libbar button { font-size: 11px; padding: 3px 9px; }

/* ---- copy health ---- */
td { position: relative; }
.cc { position: absolute; right: 5px; bottom: 3px; font-size: 10px; color: var(--ink-3); visibility: hidden; font-variant-numeric: tabular-nums; pointer-events: none; }
td:focus-within .cc { visibility: visible; }
.cc.over { visibility: visible; color: var(--brand-d); font-weight: 700; }
td.kwmiss { box-shadow: inset 3px 0 0 var(--warn); }
