/*
 * Public Page Styles
 * Modern, minimal, neutral — designed to look native on any website.
 * Brand-overridable via CSS custom properties set in the EJS template.
 */

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

body {
  font-family: var(--gr-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--gr-body-color, #1e1e1e);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Draft banner ===== */

.gr-draft-banner {
  background: #fffbeb;
  color: #92400e;
  text-align: center;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-bottom: 1px solid #fde68a;
}

/* ===== Standalone page layout ===== */

body.gr-standalone {
  background: var(--gr-bg, #fafafa);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Embed layout ===== */

body.gr-embed {
  background: transparent;
}

body.gr-embed.gr-embed-card {
  background: #fff;
  border: 1px solid #f0f0f0;
}

body.gr-embed .gr-main {
  padding: 20px;
  max-width: 100%;
}

/* ===== Embed header (optional title/description inside embed) ===== */

.gr-embed-header {
  padding: 20px 20px 0;
}

.gr-embed-title {
  font-size: 17px;
  font-weight: 600;
  color: #1e1e1e;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.gr-embed-description {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

/* ===== Standalone header ===== */

.gr-header {
  width: 100%;
  max-width: var(--gr-content-width, 560px);
  padding: 48px 24px 0;
}

.gr-header-image {
  width: 100%;
  height: 160px;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  margin-bottom: 28px;
}

.gr-header-content {
  text-align: center;
}

.gr-logo {
  max-height: 40px;
  max-width: 160px;
  margin-bottom: 20px;
}

.gr-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--gr-title-color, #111);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.gr-description {
  font-size: 15px;
  color: var(--gr-desc-color, #6b7280);
  line-height: 1.5;
}

/* ===== Main content ===== */

.gr-main {
  width: 100%;
  max-width: var(--gr-content-width, 560px);
  padding: 32px 24px 56px;
}

/* Card container — wraps the form when card background is set */
.gr-card-container {
  background: var(--gr-card-bg, transparent);
  border-radius: var(--gr-card-radius, 0);
  border: 1px solid var(--gr-card-border, transparent);
  padding: 32px;
}

/* ===== Form ===== */

#gr-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gr-density-gap, 24px);
}

/* ===== Field wrappers ===== */

.gr-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gr-field-full {
  width: 100%;
}

.gr-field-half {
  width: calc(50% - 10px);
}

@media (max-width: 560px) {
  .gr-field-half {
    width: 100%;
  }
}

/* ===== Labels ===== */

.gr-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gr-label-color, #374151);
  letter-spacing: 0.01em;
}

.gr-required {
  color: #ef4444;
  margin-left: 1px;
}

/* ===== Inputs ===== */

.gr-field input[type="text"],
.gr-field input[type="email"],
.gr-field input[type="number"],
.gr-field input[type="date"],
.gr-field input[type="tel"],
.gr-field textarea,
.gr-field select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gr-input-border, #e5e7eb);
  border-radius: var(--gr-input-radius, 10px);
  font-size: 15px;
  font-family: inherit;
  color: var(--gr-input-color, #1e1e1e);
  background: var(--gr-input-bg, #fff);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

.gr-field input::placeholder,
.gr-field textarea::placeholder {
  color: #a1a1aa;
}

.gr-field input:focus,
.gr-field textarea:focus,
.gr-field select:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.15);
}

.gr-field textarea {
  resize: vertical;
  min-height: 88px;
}

.gr-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.gr-field select[multiple] {
  min-height: 88px;
  background-image: none;
  padding-right: 14px;
}

/* ===== Checkbox ===== */

.gr-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}

.gr-checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gr-btn-color, var(--gr-primary, #6366f1));
  border-radius: 4px;
  cursor: pointer;
}

.gr-checkbox-wrapper label {
  cursor: pointer;
}

/* ===== File input ===== */

.gr-field input[type="file"] {
  padding: 10px 14px;
  font-size: 13px;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  color: #6b7280;
}

.gr-field input[type="file"]:hover {
  border-color: #a5b4fc;
  background: #f5f5ff;
}

/* ===== Help text ===== */

.gr-help {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
}

/* ===== Field-level validation errors ===== */

.gr-field-error {
  font-size: 12px;
  color: #ef4444;
  min-height: 0;
}

.gr-field-error:empty {
  display: none;
}

/* ===== Form-level error ===== */

.gr-form-error {
  width: 100%;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #dc2626;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Submit button ===== */

.gr-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 32px;
  background: var(--gr-btn-color, var(--gr-primary, #18181b));
  color: var(--gr-btn-text, #fff);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
  border: none;
  border-radius: var(--gr-btn-radius, 10px);
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  margin-top: 4px;
}

.gr-submit-btn.gr-btn-full {
  width: 100%;
}

.gr-submit-btn:hover {
  opacity: 0.88;
}

.gr-submit-btn:active {
  transform: scale(0.98);
}

.gr-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Layout elements (headings, paragraphs in form) ===== */

.gr-layout-heading {
  width: 100%;
  font-size: 18px;
  font-weight: 600;
  color: #111;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.gr-layout-paragraph {
  width: 100%;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.6;
}

/* ===== Multi-step section navigation ===== */

.gr-section-nav {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.gr-section-btn {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.gr-section-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.gr-section-btn-primary {
  background: var(--gr-btn-color, var(--gr-primary, #18181b));
  color: #fff;
  border-color: transparent;
}

.gr-section-btn-primary:hover {
  opacity: 0.88;
  background: var(--gr-btn-color, var(--gr-primary, #18181b));
}

/* ===== Loading state ===== */

.gr-loading {
  text-align: center;
  padding: 56px 24px;
  color: #6b7280;
  font-size: 14px;
}

.gr-loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 2.5px solid #e5e7eb;
  border-top-color: #6b7280;
  border-radius: 50%;
  animation: gr-spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes gr-spin {
  to { transform: rotate(360deg); }
}

/* ===== Success state ===== */

.gr-success {
  text-align: center;
  padding: 56px 24px;
}

.gr-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #ecfdf5;
  border-radius: 50%;
  margin-bottom: 16px;
}

.gr-success-icon::after {
  content: '✓';
  font-size: 20px;
  color: #059669;
  font-weight: 600;
}

.gr-success h2 {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.gr-success p {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

/* ===== Result display ===== */

.gr-result {
  padding: 20px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  color: #374151;
}

.gr-result table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.gr-result th, .gr-result td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}

.gr-result th {
  font-weight: 600;
  color: #374151;
  background: transparent;
}

/* ===== Empty state (display pages) ===== */

.gr-empty-state {
  text-align: center;
  padding: 56px 24px;
  color: #9ca3af;
  font-size: 14px;
}

/* ===== Display page — fluid layout ===== */

body.gr-standalone.gr-display-page .gr-header,
body.gr-standalone.gr-display-page .gr-main {
  max-width: min(92vw, 1200px);
}

body.gr-standalone.gr-display-page .gr-main {
  padding: 40px 48px 64px;
}

@media (max-width: 768px) {
  body.gr-standalone.gr-display-page .gr-main {
    padding: 24px 20px 48px;
  }
}

/* ===== Display page blocks ===== */

#gr-display {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#gr-display .gr-layout-heading {
  color: var(--gr-title-color, #111);
}

#gr-display .gr-layout-paragraph {
  color: var(--gr-desc-color, #6b7280);
}

.gr-display-output {
  font-size: 15px;
  line-height: 1.7;
  color: var(--gr-body-color, #1e1e1e);
}

.gr-display-output h1,
.gr-display-output h2,
.gr-display-output h3,
.gr-display-output h4 {
  color: var(--gr-title-color, #111);
  margin: 0.8em 0 0.35em;
  line-height: 1.3;
}

.gr-display-output h1 { font-size: 1.6em; }
.gr-display-output h2 { font-size: 1.35em; }
.gr-display-output h3 { font-size: 1.15em; }

.gr-display-output p {
  margin: 0.5em 0;
}

.gr-display-output ul,
.gr-display-output ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.gr-display-output li {
  margin: 0.25em 0;
}

.gr-display-output a {
  color: var(--gr-primary, #6366f1);
  text-decoration: underline;
}

/* Tables — scrollable container for wide data */
.gr-display-output .gr-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  border: 1px solid var(--gr-card-border, #e5e7eb);
  border-radius: 8px;
}

.gr-display-output table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  margin: 0;
}

.gr-display-output th,
.gr-display-output td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gr-card-border, #f3f4f6);
  font-size: 14px;
  white-space: nowrap;
}

.gr-display-output th {
  font-weight: 600;
  color: var(--gr-title-color, #374151);
  background: rgba(0, 0, 0, 0.02);
  position: sticky;
  top: 0;
}

.gr-display-output td {
  white-space: normal;
  min-width: 100px;
}

.gr-display-output tr:last-child td {
  border-bottom: none;
}

@media (max-width: 768px) {
  .gr-display-output th,
  .gr-display-output td {
    padding: 8px 12px;
    font-size: 13px;
  }
}

.gr-display-output img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
}

.gr-display-output pre {
  background: rgba(0, 0, 0, 0.04);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

.gr-display-output code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
}

.gr-display-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--gr-card-radius, 8px);
  display: block;
}

.gr-display-divider {
  border: none;
  border-top: 1px solid var(--gr-card-border, #e5e7eb);
  margin: 4px 0;
}

/* ===== Error pages ===== */

.gr-error-page {
  text-align: center;
  padding: 80px 24px;
}

.gr-error-page h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.gr-error-page p {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}
