/* =====================================================================
   Discord Webhook Tester Pro — app.css
   Extends the shared design system (base.css). Colors derive ONLY from
   base.css CSS variables so dark + light themes both work — except the
   Discord embed preview, which intentionally mirrors Discord's own
   (always-dark) embed styling regardless of site theme.
   ===================================================================== */

/* ---- Theme toggle icon swap (sun in dark, moon in light) ---- */
[data-theme="light"] .icon-sun { display: none; }
.icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: inline-block; }

/* ---- Eye toggle icon swap ---- */
.icon-eye-off { display: none; }
#btnToggleUrl.is-visible .icon-eye { display: none; }
#btnToggleUrl.is-visible .icon-eye-off { display: inline-block; }

.panel-title {
  margin: 0 0 var(--space-4);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.section-title {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ===================== Privacy note ===================== */
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  background: var(--info-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}
.privacy-note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--info); }

/* ===================== Content counter ===================== */
#contentCounter.warning { color: var(--warning); font-weight: 600; }

/* ===================== Error panel ===================== */
.error-panel {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  background: linear-gradient(var(--danger-soft), var(--danger-soft)), var(--glass);
}
.error-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--danger);
  margin-bottom: var(--space-2);
}
.error-head svg { width: 18px; height: 18px; flex: none; }
.error-head strong { font-size: 14px; }
.error-head .badge { margin-left: auto; }
.error-msg { margin: 0; color: var(--text); font-size: 13px; word-break: break-word; white-space: pre-wrap; }

/* ===================== Builder layout ===================== */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-top: var(--space-5);
  align-items: start;
}
.builder-panel > hr, .preview-panel > hr { margin: var(--space-5) 0; }
.builder-panel .field { margin-bottom: var(--space-4); }
.builder-panel .field:last-child { margin-bottom: 0; }

/* ===================== Field rows (embed fields) ===================== */
.field-rows { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.field-row input[type=text] { min-width: 0; }
.field-row .check { font-size: 12px; gap: var(--space-2); white-space: nowrap; }
.field-row .check .switch { width: 38px; height: 22px; }
.field-row .check .switch .thumb { width: 14px; height: 14px; }
.field-row .check .switch input:checked ~ .thumb { transform: translateX(16px); }
.btn--remove-field {
  width: 32px; height: 32px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--dur-1), transform var(--dur-1);
}
.btn--remove-field:hover { background: var(--danger); color: #fff; transform: translateY(-1px); }
.btn--remove-field svg { width: 15px; height: 15px; }

/* ===================== Raw JSON payload ===================== */
.payload-preview {
  margin: 0;
  padding: var(--space-4);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  color: var(--text-secondary);
}

/* =====================================================================
   Discord embed preview — mirrors Discord's actual (always-dark) look,
   independent of the site's own theme.
   ===================================================================== */
.discord-message {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  background: #313338;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
}
.discord-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: #5865f2; color: #fff;
  display: grid; place-items: center; overflow: hidden;
}
.discord-avatar img { width: 100%; height: 100%; object-fit: cover; }
.discord-avatar svg { width: 24px; height: 24px; }

.discord-body { min-width: 0; flex: 1; }
.discord-header { display: flex; align-items: baseline; gap: 8px; }
.discord-username { color: #f2f3f5; font-weight: 600; font-size: 15px; }
.discord-app-badge {
  background: #5865f2; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 4px; border-radius: 3px; border: none; letter-spacing: 0;
}
.discord-content {
  margin: 2px 0 0; color: #dbdee1; font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.discord-content:empty { display: none; }

.discord-embed {
  display: flex;
  margin-top: 8px;
  max-width: 520px;
  border-radius: 4px;
  background: #2b2d31;
  overflow: hidden;
}
.discord-embed-accent { width: 4px; flex: none; background: #5865f2; }
.discord-embed-body { padding: 10px 14px 14px; min-width: 0; flex: 1; }

.discord-embed-author { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.discord-embed-author img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.discord-embed-author span { color: #f2f3f5; font-size: 13px; font-weight: 600; }

.discord-embed-title {
  display: block; color: #f2f3f5; font-size: 15px; font-weight: 700;
  margin-bottom: 6px; text-decoration: none; cursor: default;
}
a.discord-embed-title.is-link { color: #00a8fc; cursor: pointer; }
a.discord-embed-title.is-link:hover { text-decoration: underline; }

.discord-embed-description {
  margin: 0 0 8px; color: #dbdee1; font-size: 13.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

.discord-embed-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.discord-embed-field { min-width: 0; }
.discord-embed-field.is-full { grid-column: 1 / -1; }
.discord-embed-field-name { color: #f2f3f5; font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.discord-embed-field-value { color: #dbdee1; font-size: 13px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }

.discord-embed-image {
  display: block; margin-top: 4px; margin-bottom: 4px;
  max-width: 100%; max-height: 300px; border-radius: 4px; object-fit: cover;
}
.discord-embed-thumbnail-wrap {
  float: right; margin-left: 12px; width: 80px; height: 80px;
}
.discord-embed-thumbnail-wrap img { width: 80px; height: 80px; border-radius: 4px; object-fit: cover; }

.discord-embed-footer {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; clear: both;
  color: #949ba4; font-size: 12px;
}
.discord-embed-footer img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }

/* Preview empty state */
#previewEmpty.is-hidden { display: none; }

/* ===================== Responsive ===================== */
@media (max-width: 980px) {
  .builder-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .check { grid-column: 1 / 2; }
  .btn--remove-field { grid-column: 2 / 3; justify-self: end; }
  .discord-embed-fields { grid-template-columns: 1fr; }
  .discord-embed-fields .discord-embed-field { grid-column: 1 / -1; }
}
