/* =====================================================================
   Discord Embed Builder Pro — app.css
   App-specific styles. Builds on base.css tokens (never hardcode
   surface/text colors). Discord preview uses its own fixed palette
   on purpose so it looks faithful in both light and dark themes.
   ===================================================================== */

/* ---------------------------- Layout ---------------------------- */
.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: var(--space-6);
  align-items: start;
  padding-bottom: var(--space-12);
}
.preview-col { display: flex; flex-direction: column; gap: var(--space-6); position: sticky; top: 84px; }

@media (max-width: 940px) {
  .builder { grid-template-columns: 1fr; }
  .preview-col { position: static; }
}

/* ---------------------------- Groups ---------------------------- */
.group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.group > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
  transition: background var(--dur-1);
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary:hover { background: var(--surface-2); }
.group > summary::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--dur-2) var(--ease);
  flex: none;
}
.group[open] > summary::before { transform: rotate(45deg); }
.group-body {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: fadeIn .25s var(--ease);
}
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .grid.two { grid-template-columns: 1fr; } }

/* ---------------------- Limit counters -------------------------- */
.lim, .lim-inline {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: var(--space-1);
}
.lim.over, .lim-inline.over { color: var(--danger); }

/* ---------------------------- Color ----------------------------- */
.color-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
input[type=color] {
  -webkit-appearance: none; appearance: none;
  width: 44px; height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); cursor: pointer; flex: none;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 4px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 8px; }
input[type=color]::-moz-color-swatch { border: none; border-radius: 8px; }
#colorHex { width: 120px; flex: none; text-transform: uppercase; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 24px; height: 24px; border-radius: 7px;
  border: 1px solid var(--border-strong); cursor: pointer; padding: 0;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1);
}
.swatch:hover { transform: scale(1.15); box-shadow: var(--shadow-sm); }
.swatch:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ---------------------------- Fields ---------------------------- */
.field-list { display: flex; flex-direction: column; gap: var(--space-3); }
.field-empty { font-size: 13px; margin: 0; padding: var(--space-2) 0; }
.field-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: rise .3s var(--ease) both;
}
.field-row-head { display: flex; align-items: center; gap: var(--space-3); }
.field-row-num { font-size: 12px; font-weight: 700; }
.field-inline-toggle { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field-inline-toggle input { width: 16px; height: 16px; accent-color: var(--brand-500); }
.field-del { width: 32px; height: 32px; }
.field-del:hover { color: var(--danger); }

/* ---------------------------------------------------------------- *
 * DISCORD PREVIEW — faithful palette (intentionally fixed colors)  *
 * ---------------------------------------------------------------- */
.preview-panel { overflow: hidden; }
.discord-surface {
  background: #313338;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: #dbdee1;
  font-family: 'gg sans', 'Noto Sans', var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  min-height: 120px;
  transition: box-shadow var(--dur-2);
}
.discord-surface.pulse { animation: dcPulse .6s var(--ease); }
@keyframes dcPulse {
  0% { box-shadow: 0 0 0 0 rgba(99,102,241,.55); }
  100% { box-shadow: 0 0 0 14px rgba(99,102,241,0); }
}

.dc-message { display: flex; gap: 14px; align-items: flex-start; }
.dc-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #5865f2; display: grid; place-items: center; flex: none;
}
.dc-avatar svg { width: 24px; height: 24px; }
.dc-body { min-width: 0; flex: 1; }
.dc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.dc-user { color: #f2f3f5; font-weight: 600; font-size: 15px; }
.dc-bot {
  background: #5865f2; color: #fff; font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 4px; line-height: 1.3; text-transform: uppercase;
}
.dc-time { color: #949ba4; font-size: 12px; }

/* Embed card with colored accent bar */
.dc-embed {
  --accent: #5865f2;
  position: relative;
  margin-top: 8px;
  max-width: 520px;
  background: #2b2d31;
  border-radius: 4px;
  border-left: 4px solid var(--accent);
  padding: 12px 16px 16px;
}
.dc-embed-grid { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.dc-embed-content { min-width: 0; flex: 1; }

.dc-author { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dc-author-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; }
.dc-author-name { color: #f2f3f5; font-weight: 600; font-size: 14px; }
a.dc-author-name:hover { text-decoration: underline; }

.dc-title { color: #f2f3f5; font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.dc-title a { color: #00a8fc; text-decoration: none; }
.dc-title a:hover { text-decoration: underline; }

.dc-desc { color: #dbdee1; font-size: 14px; white-space: pre-wrap; word-break: break-word; }

/* Fields */
.dc-fields { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.dc-field-row { display: flex; gap: 8px; }
.dc-field { min-width: 0; }
.dc-field.is-inline { flex: 1; }
.dc-field-name { color: #f2f3f5; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.dc-field-value { color: #dbdee1; font-size: 14px; white-space: pre-wrap; word-break: break-word; }

/* Thumbnail (top-right) */
.dc-thumb { flex: none; }
.dc-thumb-img {
  width: 80px; height: 80px; max-width: 80px;
  border-radius: 4px; object-fit: cover; display: block;
}

/* Big image (bottom) */
.dc-image { margin-top: 12px; }
.dc-image-img { max-width: 100%; max-height: 300px; border-radius: 4px; display: block; }

/* Footer */
.dc-footer { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.dc-footer-icon { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.dc-footer-text { color: #949ba4; font-size: 12px; font-weight: 500; }

/* Markdown atoms inside the preview */
.dc-embed strong { font-weight: 700; color: inherit; }
.dc-embed em { font-style: italic; }
.dc-embed u { text-decoration: underline; }
.dc-embed del { text-decoration: line-through; }
.dc-embed a { color: #00a8fc; text-decoration: none; }
.dc-embed a:hover { text-decoration: underline; }
.dc-inline {
  font-family: var(--font-mono); font-size: .85em;
  background: #1e1f22; padding: 1px 4px; border-radius: 4px; color: #dbdee1;
}
.dc-codeblock {
  background: #1e1f22; border: 1px solid #2b2d31; border-radius: 4px;
  padding: 8px 10px; margin: 6px 0; overflow-x: auto;
}
.dc-codeblock code { font-family: var(--font-mono); font-size: 13px; color: #dbdee1; white-space: pre-wrap; }

.dc-empty {
  text-align: center; color: #949ba4; font-size: 14px;
  padding: var(--space-8) var(--space-4);
}

/* Broken image placeholder */
.img-broken {
  position: relative; background: #1e1f22;
  min-width: 24px; min-height: 24px;
}
.img-broken::after {
  content: "image"; position: absolute; inset: 0;
  display: grid; place-items: center; font-size: 10px; color: #5c5e66;
  font-family: var(--font-sans);
}

/* ---------------------------- JSON ------------------------------ */
.json-out {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 320px;
  overflow: auto;
  white-space: pre;
  color: var(--text-secondary);
  margin: 0;
}

/* ---------------------------- Modals ---------------------------- */
.shortcut-table { width: 100%; border-collapse: collapse; }
.shortcut-table td { padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-secondary); }
.shortcut-table tr:last-child td { border-bottom: none; }
.shortcut-table td:first-child { white-space: nowrap; width: 1%; padding-right: var(--space-5); }
.modal code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }

/* light theme: sun icon swaps handled by base via tokens; nothing extra needed */
