/* ============================================================
   SQL exercise widget : styles
   ------------------------------------------------------------
   Designed to sit inside the SQL course's lesson-redesign pages
   (body.lesson-redesign). Uses the --rd-* tokens so it inherits
   the same peach + lavender + Fraunces feel as the rest of the
   redesigned course. Self-contained : works on plain pages too
   thanks to :root fallbacks at the top of redesign.css.
============================================================ */

.sqlx {
  margin: 2rem 0;
  font-family: var(--rd-font-body, 'Inter', system-ui, sans-serif);
  color: var(--rd-text, #1F1B30);
}

.sqlx-card {
  background: var(--rd-bg-white, #fff);
  border: 1px solid rgba(31, 27, 48, 0.08);
  border-radius: var(--rd-radius-md, 22px);
  box-shadow:
    0 1px 2px rgba(31, 27, 48, 0.04),
    0 16px 36px -22px rgba(123, 107, 191, 0.22);
  padding: 1.5rem 1.5rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.sqlx-card::before {
  content: "";
  position: absolute;
  top: -56px;
  right: -56px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--rd-bg-peach, #F8E2D2), transparent 70%);
  opacity: 0.7;
  pointer-events: none;
}

.sqlx-header {
  position: relative;
  margin-bottom: 1.25rem;
}
.sqlx-eyebrow {
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rd-accent-deep, #5B4DA0);
  margin: 0 0 6px;
}
.sqlx-title {
  font-family: var(--rd-font-serif, 'Fraunces', Georgia, serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--rd-text, #1F1B30);
  margin: 0 0 8px;
}
.sqlx-prompt {
  font-size: 15px;
  line-height: 1.55;
  color: var(--rd-text-muted, #6B6878);
  margin: 0;
}

/* ---- Sample data preview ------------------------------- */
.sqlx-preview {
  background: var(--rd-accent-soft, rgba(123, 107, 191, 0.08));
  border: 1px solid rgba(123, 107, 191, 0.16);
  border-radius: var(--rd-radius-sm, 14px);
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  position: relative;
}
.sqlx-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sqlx-preview-label {
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rd-accent-deep, #5B4DA0);
}
.sqlx-preview-name {
  font-family: var(--rd-font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 12px;
  color: var(--rd-text, #1F1B30);
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(31, 27, 48, 0.06);
}

/* ---- Editor ------------------------------------------ */
.sqlx-editor-wrap {
  position: relative;
}
.sqlx-editor-label {
  display: block;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rd-text-muted, #6B6878);
  margin-bottom: 6px;
}
.sqlx-editor {
  width: 100%;
  background: #FBFAF6;
  border: 1px solid rgba(31, 27, 48, 0.12);
  border-radius: var(--rd-radius-sm, 14px);
  padding: 14px 16px;
  font-family: var(--rd-font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 14px;
  line-height: 1.55;
  color: var(--rd-text, #1F1B30);
  resize: vertical;
  min-height: 110px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.sqlx-editor:focus {
  outline: none;
  background: #fff;
  border-color: var(--rd-accent, #7B6BBF);
  box-shadow: 0 0 0 4px rgba(123, 107, 191, 0.16);
}

/* ---- Action row -------------------------------------- */
.sqlx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 1rem;
}
.sqlx-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}
.sqlx-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sqlx-btn-primary {
  background: var(--rd-text, #1F1B30);
  color: #fff;
  box-shadow: 0 6px 18px -10px rgba(31, 27, 48, 0.45);
}
.sqlx-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(31, 27, 48, 0.55);
}
.sqlx-btn-ghost {
  background: rgba(255, 255, 255, 0.75);
  color: var(--rd-text, #1F1B30);
  border-color: rgba(31, 27, 48, 0.12);
}
.sqlx-btn-ghost:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(31, 27, 48, 0.22);
}

/* ---- Result panel ------------------------------------ */
.sqlx-result {
  margin-top: 1rem;
}
.sqlx-result:empty { display: none; }
.sqlx-feedback {
  border-radius: var(--rd-radius-sm, 14px);
  padding: 0.875rem 1rem;
  margin-bottom: 0.875rem;
  border: 1px solid transparent;
}
.sqlx-feedback-title {
  margin: 0 0 4px;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 14px;
  font-weight: 700;
}
.sqlx-feedback-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  font-family: var(--rd-font-mono, 'JetBrains Mono', ui-monospace, monospace);
  color: var(--rd-text, #1F1B30);
  white-space: pre-wrap;
  word-break: break-word;
}
.sqlx-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--rd-text, #1F1B30);
}
.sqlx-feedback-ok {
  background: rgba(1, 105, 111, 0.08);
  border-color: rgba(1, 105, 111, 0.22);
}
.sqlx-feedback-ok .sqlx-feedback-title { color: #064F55; }
.sqlx-feedback-wrong {
  background: rgba(232, 148, 106, 0.12);
  border-color: rgba(232, 148, 106, 0.32);
}
.sqlx-feedback-wrong .sqlx-feedback-title { color: #8B4A26; }
.sqlx-feedback-error {
  background: #F8E2E2;
  border-color: #E7B7B7;
}
.sqlx-feedback-error .sqlx-feedback-title { color: #8A2A2A; }

/* ---- Result + sample tables -------------------------- */
.sqlx-table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid rgba(31, 27, 48, 0.08);
  border-radius: var(--rd-radius-sm, 14px);
  position: relative;
}
.sqlx-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--rd-font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 13px;
}
.sqlx-table thead th {
  text-align: left;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-text-muted, #6B6878);
  padding: 10px 14px;
  background: rgba(248, 226, 210, 0.32);
  border-bottom: 1px solid rgba(31, 27, 48, 0.08);
  white-space: nowrap;
}
.sqlx-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(31, 27, 48, 0.05);
  color: var(--rd-text, #1F1B30);
  vertical-align: top;
}
.sqlx-table tbody tr:last-child td { border-bottom: 0; }
.sqlx-table tbody tr:nth-child(even) {
  background: rgba(123, 107, 191, 0.035);
}
.sqlx-table-footer {
  margin: 0;
  padding: 8px 14px;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
  font-size: 12px;
  color: var(--rd-text-muted, #6B6878);
  background: rgba(248, 226, 210, 0.20);
  border-top: 1px solid rgba(31, 27, 48, 0.05);
}

/* ---- Loading + error states -------------------------- */
.sqlx-loading {
  margin: 0;
  font-size: 13px;
  color: var(--rd-text-muted, #6B6878);
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
}
.sqlx-error {
  margin: 0;
  font-size: 13px;
  color: #8A2A2A;
  font-family: var(--rd-font-display, 'Inter Tight', sans-serif);
}

/* ---- Solved-state ribbon ----------------------------- */
.sqlx.is-solved .sqlx-card {
  border-color: rgba(1, 105, 111, 0.35);
  box-shadow:
    0 1px 2px rgba(1, 105, 111, 0.10),
    0 16px 36px -22px rgba(1, 105, 111, 0.30);
}

/* ---- Small screens ----------------------------------- */
@media (max-width: 640px) {
  .sqlx-card { padding: 1.25rem 1rem 1rem; }
  .sqlx-title { font-size: 20px; }
  .sqlx-editor { font-size: 13px; padding: 12px 14px; }
  .sqlx-table { font-size: 12px; }
  .sqlx-table thead th, .sqlx-table tbody td { padding: 8px 10px; }
  .sqlx-actions .sqlx-btn { flex: 1 1 auto; justify-content: center; }
}
