/* dnial.shk Dashboard — Warp-inspired Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #080807;
  --surface: #111110;
  --surface2: #1a1a19;
  --parchment: #f5f4f1;
  --ash: #a5a4a2;
  --stone: #7a7978;
  --purple-gray: #5c5a5f;
  --earth: #2c2c2b;
  --earth-hover: #3a3a39;
  --charcoal: #353534;
  --border: rgba(200, 200, 198, 0.18);
  --border-subtle: rgba(200, 200, 198, 0.08);
  --border-hover: rgba(200, 200, 198, 0.3);
  --frosted: rgba(255, 255, 255, 0.03);
  --frosted-btn: rgba(255, 255, 255, 0.08);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.1);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 50px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'Courier New', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background: var(--bg);
  color: var(--parchment);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Auth gate ─── */
#expired {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; text-align: center;
}

.expired-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  max-width: 400px;
  animation: fadeIn 0.4s ease-out;
}

.expired-icon { margin-bottom: 1.25rem; opacity: 0.5; }
.expired-box h2 { color: var(--red); margin-bottom: 0.5rem; font-size: 1.1rem; font-weight: 600; }
.expired-box p { color: var(--stone); font-size: 0.875rem; }
.expired-box code { background: var(--earth); padding: 0.15rem 0.5rem; border-radius: var(--radius-sm); font-size: 0.8rem; color: var(--ash); font-family: var(--font-mono); }
.expired-box a { display: inline-block; margin-top: 0.75rem; padding: 0.6rem 1.75rem; background: var(--earth); color: var(--parchment); border-radius: var(--radius-pill); text-decoration: none; font-weight: 500; font-size: 0.875rem; border: 1px solid var(--border); transition: all var(--transition); }
.expired-box a:hover { background: var(--earth-hover); border-color: var(--border-hover); }

/* ─── Dashboard ─── */
#dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  animation: fadeIn 0.3s ease-out;
}

/* ─── Header ─── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.75rem;
}

.header-left { display: flex; align-items: center; gap: 0.875rem; }

.header-brand {
  font-size: 1.2rem; font-weight: 700; color: var(--parchment);
  letter-spacing: -0.03em;
}

.header-logo { color: var(--ash); }
.header-divider { width: 1px; height: 1.25rem; background: var(--border); }
.header-subtitle { font-size: 0.75rem; color: var(--stone); font-weight: 400; letter-spacing: 1.4px; text-transform: uppercase; }

.header-right { display: flex; align-items: center; gap: 0.5rem; }

.session-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.header-meta { font-size: 0.75rem; color: var(--stone); }

/* ─── Tabs ─── */
.tabs {
  display: flex; gap: 2px;
  margin-bottom: 1.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1; background: transparent; border: none;
  color: var(--stone);
  padding: 0.6rem 1rem;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  font-size: 0.8125rem; font-weight: 500; font-family: var(--font);
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}

.tab-icon { flex-shrink: 0; opacity: 0.5; transition: opacity var(--transition); }
.tab-btn:hover { color: var(--parchment); background: var(--frosted); }
.tab-btn:hover .tab-icon { opacity: 0.8; }
.tab-btn.active { background: var(--earth); color: var(--parchment); }
.tab-btn.active .tab-icon { opacity: 1; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease-out; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  border: none; cursor: pointer;
  font-size: 0.8125rem; font-weight: 500; font-family: var(--font);
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: var(--earth); color: var(--parchment); border: 1px solid var(--border); }
.btn-primary:hover:not(:disabled) { background: var(--earth-hover); border-color: var(--border-hover); }

.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.2); }
.btn-success:hover:not(:disabled) { background: rgba(74, 222, 128, 0.18); }

.btn-warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.2); }
.btn-warning:hover:not(:disabled) { background: rgba(251, 191, 36, 0.18); }

.btn-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(167, 139, 250, 0.2); }
.btn-purple:hover:not(:disabled) { background: rgba(167, 139, 250, 0.18); }

.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red-dim); }
.btn-danger:hover:not(:disabled) { background: var(--red-dim); }

.btn-ghost { background: transparent; color: var(--stone); border: 1px solid var(--border-subtle); }
.btn-ghost:hover:not(:disabled) { color: var(--parchment); border-color: var(--border); background: var(--frosted); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.75rem; }

/* ─── Section header ─── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }

.section-title {
  font-size: 0.7rem; font-weight: 600; color: var(--stone);
  text-transform: uppercase; letter-spacing: 1.6px;
}

/* ─── Inputs ─── */
textarea, input[type="text"], input[type="number"], input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--parchment);
  padding: 0.6rem 0.75rem;
  font-size: 0.8125rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

textarea { width: 100%; resize: vertical; font-family: var(--font-mono); }
textarea:focus, input:focus { border-color: var(--border-hover); }
textarea::placeholder, input::placeholder { color: var(--purple-gray); }

.url-input-area { margin-bottom: 1.25rem; }
.url-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

.input-label { font-size: 0.7rem; font-weight: 600; color: var(--stone); text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 0.5rem; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-subtle); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead { background: var(--surface); }
th { padding: 0.625rem 0.875rem; text-align: left; font-size: 0.7rem; font-weight: 600; color: var(--stone); text-transform: uppercase; letter-spacing: 1.2px; border-bottom: 1px solid var(--border-subtle); }
td { padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; color: var(--ash); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--frosted); }

.td-link { color: var(--ash); text-decoration: none; font-family: var(--font-mono); font-size: 0.75rem; }
.td-link:hover { color: var(--parchment); text-decoration: underline; }
.td-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.remarks-input {
  width: 100%; min-width: 100px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--parchment);
  padding: 0.25rem 0.375rem; font-size: 0.8125rem;
  transition: all var(--transition);
}
.remarks-input:hover { border-color: var(--border-subtle); }
.remarks-input:focus { border-color: var(--border-hover); background: var(--surface); outline: none; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.8px; text-transform: uppercase;
}

.badge-pending  { background: var(--frosted-btn); color: var(--stone); }
.badge-scraped  { background: var(--yellow-dim); color: var(--yellow); }
.badge-manual   { background: var(--yellow-dim); color: var(--yellow); }
.badge-approved { background: var(--green-dim); color: var(--green); }
.badge-draft    { background: var(--frosted-btn); color: var(--ash); }
.badge-queued   { background: var(--purple-dim); color: var(--purple); }
.badge-posted   { background: var(--green-dim); color: var(--green); }

/* ─── Post cards ─── */
.posts-grid { display: flex; flex-direction: column; gap: 1rem; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.post-card:hover { border-color: var(--border); }

.post-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap; gap: 0.5rem;
}

.post-card-product { font-size: 0.8125rem; font-weight: 500; color: var(--parchment); }
.post-card-price { font-size: 0.75rem; color: var(--stone); margin-left: 0.375rem; }
.post-card-meta-right { display: flex; align-items: center; gap: 0.5rem; }

.post-block { padding: 0.75rem 1rem; border-left: 3px solid transparent; }
.post-block + .post-block { border-top: 1px solid var(--border-subtle); }
.post-block-purple { border-left-color: var(--purple); }
.post-block-yellow { border-left-color: var(--yellow); }

.post-block-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: var(--stone); margin-bottom: 0.375rem; }
.post-block-purple .post-block-label { color: var(--purple); }
.post-block-yellow .post-block-label { color: var(--yellow); }

.post-block-text { font-size: 0.8125rem; line-height: 1.6; color: var(--ash); white-space: pre-wrap; word-break: break-word; }

.post-card-actions {
  display: flex; gap: 0.375rem;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--frosted);
  flex-wrap: wrap;
}

/* ─── Stats ─── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border); }

.stat-card-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.4px; color: var(--stone); margin-bottom: 0.5rem; }
.stat-card-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }

.stat-card-green .stat-card-value { color: var(--green); }
.stat-card-purple .stat-card-value { color: var(--purple); }
.stat-card-yellow .stat-card-value { color: var(--yellow); }
.stat-card-text .stat-card-value { color: var(--parchment); }

/* ─── Ratio control ─── */
.ratio-control {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.ratio-control label { font-size: 0.8125rem; color: var(--stone); white-space: nowrap; }
.ratio-control input { width: 70px; }

/* ─── Queue list ─── */
.queue-list { display: flex; flex-direction: column; gap: 0.5rem; }

.queue-item {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: border-color var(--transition);
}
.queue-item:hover { border-color: var(--border); }

.queue-item-order { font-size: 0.7rem; font-weight: 600; color: var(--stone); width: 1.5rem; flex-shrink: 0; margin-top: 0.125rem; }
.queue-item-content { flex: 1; min-width: 0; }
.queue-item-text { font-size: 0.8125rem; color: var(--ash); overflow: hidden; text-overflow: ellipsis; }
.queue-item-meta { font-size: 0.65rem; color: var(--stone); margin-top: 0.25rem; }
.queue-item-actions { display: flex; gap: 0.375rem; flex-shrink: 0; align-items: center; }

/* ─── Library ─── */
.library-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.library-count { font-size: 0.8125rem; color: var(--stone); }
.library-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }

.library-item {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex; gap: 0.75rem; align-items: flex-start;
  transition: border-color var(--transition);
}
.library-item:hover { border-color: var(--border); }

.library-item-num { font-size: 0.65rem; color: var(--stone); width: 1.5rem; flex-shrink: 0; padding-top: 0.125rem; font-family: var(--font-mono); }
.library-item-body { flex: 1; min-width: 0; }
.library-item-category {
  display: inline-block; font-size: 0.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--ash); background: var(--frosted-btn);
  padding: 0.1rem 0.5rem; border-radius: var(--radius-pill);
  margin-bottom: 0.375rem;
}
.library-item-text { font-size: 0.8125rem; color: var(--ash); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.library-item-actions { display: flex; gap: 0.375rem; flex-shrink: 0; align-items: flex-start; padding-top: 0.125rem; }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.pagination-info { font-size: 0.75rem; color: var(--stone); }

/* ─── States ─── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--stone); }
.empty-state p { font-size: 0.875rem; }

.loading { text-align: center; padding: 2rem; color: var(--stone); font-size: 0.875rem; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--ash);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin-right: 0.5rem; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─── */
#toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.6rem 1.25rem;
  font-size: 0.8125rem; color: var(--parchment);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0; transition: all 0.25s ease;
  pointer-events: none; white-space: nowrap; z-index: 9999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-success { border-color: rgba(74, 222, 128, 0.3); color: var(--green); }
#toast.toast-error { border-color: rgba(248, 113, 113, 0.3); color: var(--red); }
#toast.toast-info { border-color: var(--border); color: var(--ash); }

/* ─── Product cards (mobile) ─── */
.product-cards { display: none; flex-direction: column; gap: 0.75rem; }

.product-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color var(--transition);
}
.product-card:hover { border-color: var(--border); }

.product-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.product-card-name { font-size: 0.875rem; font-weight: 500; color: var(--parchment); flex: 1; min-width: 0; word-break: break-word; }
.product-card-link { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--stone); text-decoration: none; margin-bottom: 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-card-link:hover { color: var(--ash); }

.product-card-remarks {
  width: 100%; background: var(--bg); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); color: var(--parchment);
  padding: 0.4rem 0.625rem; font-size: 0.8125rem;
  margin-bottom: 0.625rem; outline: none;
}
.product-card-remarks:focus { border-color: var(--border-hover); }
.product-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.product-card-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

/* ─── Highlight (manual entry) ─── */
.input-highlight { border-color: rgba(251, 191, 36, 0.4) !important; background: rgba(251, 191, 36, 0.05) !important; }

/* ─── Touch targets ─── */
@media (pointer: coarse) {
  .btn { min-height: 38px; padding: 0.5rem 1.1rem; }
  .btn-sm { min-height: 34px; padding: 0.4rem 0.85rem; }
  .tab-btn { padding: 0.7rem 1rem; }
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  body { font-size: 15px; }
  #dashboard { padding: 0 0.75rem 2rem; }
  .header { flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0.75rem 0; margin-bottom: 1rem; }
  .tabs { flex-wrap: wrap; gap: 2px; }
  .tab-btn { flex: none; width: calc(50% - 2px); padding: 0.65rem 0.5rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-card { padding: 0.75rem; }
  .stat-card-value { font-size: 1.25rem; }
  .url-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .url-actions .btn { justify-content: center; }
  .table-wrap { display: none; }
  .product-cards { display: flex; }
  .post-card-meta { flex-direction: column; align-items: flex-start; }
  .post-card-actions .btn { flex: 1; justify-content: center; }
  .post-block { padding: 0.625rem 0.75rem; }
  .queue-item { flex-wrap: wrap; }
  .queue-item-text { white-space: normal; }
  .queue-item-actions { width: 100%; justify-content: flex-end; margin-top: 0.25rem; }
  .library-item { flex-wrap: wrap; }
  .library-item-actions { width: 100%; justify-content: flex-end; margin-top: 0.25rem; }
  .ratio-control { flex-wrap: wrap; }
  .pagination { gap: 0.375rem; }
}

@media (min-width: 641px) {
  .product-cards { display: none; }
}

/* ─── Library tags ─── */
.library-tags {
  display: flex; gap: 0.375rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tag-btn {
  background: var(--frosted-btn); color: var(--stone);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-pill);
  padding: 0.3rem 0.75rem; font-size: 0.75rem; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  transition: all var(--transition);
}
.tag-btn:hover { color: var(--parchment); border-color: var(--border); }
.tag-active { background: var(--earth); color: var(--parchment); border-color: var(--border); }
.tag-count { opacity: 0.5; font-size: 0.65rem; margin-left: 0.125rem; }
