/**
 * Gorilla Returns — Portal stylesheet.
 *
 * Self-contained: doesn't depend on the host theme. Uses CSS custom
 * properties so merchants can rebrand by overriding a handful of vars.
 * Tested on light backgrounds; dark mode is via prefers-color-scheme.
 */

.gr-portal {
    --gr-bg: #f9fafb;
    --gr-surface: #ffffff;
    --gr-text: #111827;
    --gr-muted: #6b7280;
    --gr-border: #e5e7eb;
    --gr-accent: #3f4a5c;
    --gr-accent-text: #ffffff;
    --gr-bonus: #16a34a;
    --gr-bonus-soft: #dcfce7;
    --gr-warn-soft: #fef3c7;
    --gr-error-soft: #fee2e2;
    --gr-error-text: #b91c1c;
    --gr-radius: 10px;
    --gr-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
    margin: 0;
    /* No default background — inherit the theme's page background so the
       portal blends into wherever it's embedded. The .gr-portal-container's
       card surfaces still get white backgrounds via .gr-portal-item and
       .gr-portal-card, so form content still reads as a distinct section. */
    background: transparent;
    color: var(--gr-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.gr-portal * { box-sizing: border-box; }

/* Reset theme bleed-through. Themes commonly apply `ul { list-style: disc }`,
   `img { max-width: 100% }`, `a { text-decoration: underline }`, etc., often
   at high specificity. We re-assert our defaults on every element inside the
   portal so the layout looks identical regardless of host theme. */
.gr-portal ul,
.gr-portal ol { list-style: none; padding: 0; margin: 0; }
.gr-portal li { list-style: none; margin: 0; padding: 0; }
.gr-portal li::marker { content: ''; }
.gr-portal img { max-width: 100%; height: auto; vertical-align: middle; }
.gr-portal a { color: var(--gr-accent); text-decoration: none; }
.gr-portal a:hover { text-decoration: underline; }
.gr-portal button { font-family: inherit; }
.gr-portal h1, .gr-portal h2, .gr-portal h3, .gr-portal h4 {
    margin: 0; font-family: inherit; line-height: 1.25;
}
.gr-portal p { margin: 0 0 12px; }
.gr-portal p:last-child { margin-bottom: 0; }
.gr-portal input, .gr-portal select, .gr-portal textarea {
    font-family: inherit; font-size: 14px;
}

.gr-portal-container { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* Header / footer ---------------------------------------------------------- */
.gr-portal-header {
    background: var(--gr-surface);
    border-bottom: 1px solid var(--gr-border);
    padding: 16px 0;
}
.gr-portal-header .gr-portal-container {
    display: flex; justify-content: space-between; align-items: center;
}
.gr-portal-brand {
    font-weight: 600; color: var(--gr-text); text-decoration: none; font-size: 18px;
    display: inline-flex; align-items: center;
}
.gr-portal {
    --gr-logo-max-width: 160px;
}
.gr-portal-logo {
    max-width: var(--gr-logo-max-width);
    max-height: 60px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}
.gr-portal-back {
    color: var(--gr-muted); text-decoration: none; font-size: 14px;
}
.gr-portal-back:hover { color: var(--gr-text); }

.gr-portal-footer {
    margin-top: 60px; padding: 24px 0; border-top: 1px solid var(--gr-border);
    color: var(--gr-muted); font-size: 13px; text-align: center;
}
.gr-portal-footer a { color: var(--gr-muted); }
.gr-portal-powered { font-size: 11px; color: #9ca3af; margin-top: 6px; }

/* Main / titles ------------------------------------------------------------ */
.gr-portal-main { padding: 40px 0 60px; }
.gr-portal-title { font-size: 28px; font-weight: 600; margin: 8px 0 24px; }
.gr-portal-intro { color: var(--gr-muted); font-size: 15px; margin: 0 0 24px; }

/* Progress dots ------------------------------------------------------------ */
.gr-portal-progress { display: flex; gap: 8px; margin-bottom: 12px; }
.gr-portal-progress-dot {
    width: 28px; height: 4px; border-radius: 2px; background: var(--gr-border);
}
.gr-portal-progress-dot.is-active { background: var(--gr-accent); }

/* Forms -------------------------------------------------------------------- */
.gr-portal-form { background: var(--gr-surface); border: 1px solid var(--gr-border); border-radius: var(--gr-radius); padding: 24px; box-shadow: var(--gr-shadow); }
.gr-portal-field { display: block; margin-bottom: 18px; }
.gr-portal-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.gr-portal-help { display: block; font-size: 12px; color: var(--gr-muted); margin-top: 4px; }

.gr-portal-form input[type="text"],
.gr-portal-form input[type="email"],
.gr-portal-form select,
.gr-portal-form textarea {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    background: var(--gr-surface); color: var(--gr-text);
    border: 1px solid var(--gr-border); border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.gr-portal-form input:focus,
.gr-portal-form select:focus,
.gr-portal-form textarea:focus {
    outline: none; border-color: var(--gr-accent);
    box-shadow: 0 0 0 3px rgba(15,23,42,0.1);
}

.gr-portal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 12px; }

/* Buttons ------------------------------------------------------------------ */
.gr-portal-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 20px; font-size: 15px; font-weight: 500; font-family: inherit;
    text-decoration: none; cursor: pointer;
    border: 1px solid transparent; border-radius: 8px;
    transition: background 0.15s, transform 0.05s;
}
.gr-portal-btn:active { transform: translateY(1px); }
.gr-portal-btn-primary {
    background: var(--gr-accent); color: var(--gr-accent-text);
}
.gr-portal-btn-primary:hover { background: #4b5768; }
.gr-portal-btn-secondary {
    background: transparent;
    color: var(--gr-accent);
    border: 1px solid var(--gr-accent);
}
.gr-portal-btn-secondary:hover { background: var(--gr-accent); color: var(--gr-accent-text); }

/* "Can't find your order number?" callout on the lookup page.
   The container styling lives inline on the <summary> tag so it
   works even if this stylesheet is blocked. This block just adds
   the interactive states — hover darkening and chevron rotation
   on open — that can't be expressed inline. */
.gr-portal-find-order > summary:hover {
    background: #dbeafe !important;
    border-color: #93c5fd !important;
}
.gr-portal-find-order[open] > summary .gr-portal-find-order-chevron {
    transform: rotate(180deg);
}
/* Modern browsers respect list-style:none on summary, but WebKit
   still shows a triangle marker without this. */
.gr-portal-find-order > summary::-webkit-details-marker { display: none; }
.gr-portal-find-order > summary::marker { content: ''; }
.gr-portal-btn-link {
    background: transparent; color: var(--gr-muted); padding: 12px 0;
}
.gr-portal-btn-link:hover { color: var(--gr-text); }

/* Alerts ------------------------------------------------------------------- */
.gr-portal-alert {
    display: block !important;
    padding: 14px 16px !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    line-height: 1.4 !important;
    margin-bottom: 20px !important;
    border: 1px solid transparent !important;
    font-weight: 500 !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.gr-portal-alert-error {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border-color: #fca5a5 !important;
}
.gr-portal-alert-error a { color: #7f1d1d !important; text-decoration: underline !important; }
.gr-portal-alert-error a:hover { color: #450a0a !important; }

/* Items list (step 2) ------------------------------------------------------ */
.gr-portal-items {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    background: var(--gr-surface);
    border: 1px solid var(--gr-border);
    border-radius: var(--gr-radius);
    overflow: hidden;
}
.gr-portal-item {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 18px; border-bottom: 1px solid var(--gr-border);
    background: var(--gr-surface);
}
.gr-portal-item:last-child { border-bottom: none; }
.gr-portal-item.is-excluded { opacity: 0.55; }
.gr-portal-item-label {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    cursor: pointer;
    padding-left: 4px;
}
.gr-portal-item-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0 4px 0 0;
    flex-shrink: 0;
    cursor: pointer;
}
.gr-portal-item-img {
    width: 56px !important;
    height: 56px !important;
    max-width: 56px !important;
    object-fit: cover;
    border-radius: 6px;
    background: var(--gr-bg);
    flex-shrink: 0;
    display: block;
}
.gr-portal-item-img.is-placeholder { display: inline-block; }
.gr-portal-item-meta { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.gr-portal-item-meta strong { font-weight: 500; }
.gr-portal-item-meta span { color: var(--gr-muted); font-size: 13px; }
.gr-portal-tag {
    display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px;
    background: var(--gr-warn-soft); color: #92400e; margin-top: 4px; align-self: flex-start;
}
.gr-portal-qty { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--gr-muted); }
.gr-portal-qty select { min-width: 70px; }

/* Reasons (step 3) --------------------------------------------------------- */
.gr-portal-reason-block {
    border: 1px solid var(--gr-border); border-radius: 8px;
    padding: 16px; margin-bottom: 16px;
}
.gr-portal-reason-block legend { padding: 0 8px; font-size: 14px; }

/* Resolutions (step 4) — THE FUNNEL ---------------------------------------- */
.gr-portal-resolutions { display: flex; flex-direction: column; gap: 12px; }
.gr-portal-resolution {
    position: relative;
    display: flex; gap: 14px; align-items: flex-start;
    padding: 18px 18px 18px 52px;
    border: 2px solid var(--gr-border); border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--gr-surface);
}
.gr-portal-resolution:hover { border-color: #cbd5e1; }
/* Hide the native radio input. We use the label's ::before to draw our own
   consistent circle so themes with aggressive form styling don't inject
   double-radios or weird pseudo-elements next to ours. */
.gr-portal-resolution input[type="radio"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.gr-portal-resolution::before {
    content: "";
    position: absolute;
    left: 18px; top: 20px;
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}
.gr-portal-resolution:has(input:checked)::before {
    border-color: var(--gr-accent);
    background: radial-gradient(circle, var(--gr-accent) 0 5px, #fff 6px);
}
.gr-portal-resolution:has(input:checked) {
    border-color: var(--gr-accent);
    box-shadow: 0 0 0 3px rgba(63,74,92,0.10);
}
/* Keyboard focus ring on the card */
.gr-portal-resolution:focus-within {
    border-color: var(--gr-accent);
    box-shadow: 0 0 0 3px rgba(63,74,92,0.15);
}
.gr-portal-resolution-body { flex: 1; }
.gr-portal-resolution-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gr-portal-resolution-title { font-size: 17px; font-weight: 600; }
.gr-portal-resolution-tag {
    font-size: 11px; padding: 3px 8px; border-radius: 12px;
    background: var(--gr-bg); color: var(--gr-muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.gr-portal-resolution-tag.is-bonus { background: var(--gr-bonus-soft); color: var(--gr-bonus); }
.gr-portal-resolution-desc { margin: 0; color: var(--gr-text); font-size: 14px; }
.gr-portal-resolution-extra { display: none; margin-top: 14px; }
.gr-portal-resolution:has(input:checked) .gr-portal-resolution-extra { display: block; }

/* De-emphasize the refund option visually. Keep the 52px left padding so
   the ::before radio circle from the base rule has room to render — the
   compact 14px vertical padding is fine but we can't collapse the left. */
.gr-portal-resolution-refund { padding: 14px 18px 14px 52px; }
.gr-portal-resolution-refund::before { top: 16px; }
.gr-portal-resolution-refund .gr-portal-resolution-title { font-size: 15px; font-weight: 500; color: var(--gr-muted); }
.gr-portal-resolution-refund .gr-portal-resolution-desc { color: var(--gr-muted); font-size: 13px; }
.gr-portal-resolution-refund:has(input:checked) .gr-portal-resolution-title,
.gr-portal-resolution-refund:has(input:checked) .gr-portal-resolution-desc { color: var(--gr-text); }

/* Confirmation (step 5) ---------------------------------------------------- */
.gr-portal-confirmation { text-align: center; padding: 20px 0; }
.gr-portal-checkmark { display: flex; justify-content: center; margin-bottom: 16px; }
.gr-portal-confirmation h2 { font-size: 24px; margin: 0 0 8px; }
.gr-portal-confirmation-meta { color: var(--gr-muted); font-size: 14px; margin-bottom: 24px; }
.gr-portal-confirmation-meta code { background: var(--gr-bg); padding: 2px 8px; border-radius: 4px; font-size: 13px; }

.gr-portal-card {
    background: var(--gr-surface); border: 1px solid var(--gr-border);
    border-radius: var(--gr-radius); padding: 24px;
    margin: 16px 0; text-align: left;
}
.gr-portal-card.is-highlight { border-color: var(--gr-accent); }
.gr-portal-card h3 { margin-top: 0; font-size: 17px; }
.gr-portal-credit-code code {
    display: block; padding: 14px 16px;
    background: var(--gr-bg); border-radius: 8px;
    font-size: 22px; font-weight: 600; letter-spacing: 0.05em;
    text-align: center; margin: 8px 0;
}
.gr-portal-confirmation-foot { color: var(--gr-muted); font-size: 13px; margin-top: 24px; }

/* Exchange variant picker (step 4b) ---------------------------------------- */
.gr-portal-exchange-block {
    border: 1px solid var(--gr-border); border-radius: 8px;
    padding: 16px; margin-bottom: 16px;
}
.gr-portal-exchange-block legend {
    padding: 0 8px; font-size: 14px; display: inline-flex; gap: 8px; align-items: center;
}
.gr-portal-variant-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.gr-portal-variant {
    border: 1px solid var(--gr-border); border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
}
.gr-portal-variant:hover:not(.is-disabled) { border-color: #cbd5e1; }
.gr-portal-variant:has(input:checked) {
    border-color: var(--gr-accent);
    background: rgba(15,23,42,0.03);
}
.gr-portal-variant.is-disabled { opacity: 0.55; background: var(--gr-bg); }
.gr-portal-variant.is-disabled label { cursor: not-allowed; }
.gr-portal-variant label {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px 10px 40px;
    cursor: pointer;
}
.gr-portal-variant input[type="radio"] {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.gr-portal-variant label::before {
    content: "";
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #fff;
    box-sizing: border-box;
}
.gr-portal-variant:has(input:checked) label::before {
    border-color: var(--gr-accent);
    background: radial-gradient(circle, var(--gr-accent) 0 4px, #fff 5px);
}
.gr-portal-variant-attrs { flex: 1; font-size: 14px; font-weight: 500; }
.gr-portal-variant-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.gr-portal-variant-price { color: var(--gr-muted); }
.gr-portal-tag.is-warn { background: var(--gr-warn-soft); color: #92400e; }

/* Mobile ------------------------------------------------------------------- */
@media (max-width: 540px) {
    .gr-portal-title { font-size: 22px; }
    .gr-portal-form { padding: 18px; }
    .gr-portal-item { flex-direction: column; align-items: flex-start; }
    .gr-portal-actions { flex-direction: column-reverse; gap: 8px; }
    .gr-portal-btn { width: 100%; }
}

/* Dark mode ---------------------------------------------------------------- */
/* Intentionally not respecting prefers-color-scheme: dark by default. The
   portal is embedded in the merchant's WordPress theme, which may or may not
   have its own dark-mode handling — auto-switching us based on the visitor's
   OS setting produced portals that looked jarring against light themes and
   inconsistent with the surrounding page. Merchants who want a dark portal
   should set a dark primary color and dark accent text color in the Portal
   settings, which is a deliberate choice they can see previewed. */

/* Inline (shortcode) mode ------------------------------------------------- */
/* When the portal is embedded via [gorilla_returns_portal] inside a theme
   page, we want it to feel like part of that page rather than a standalone
   takeover. So we drop the page-level background, lighten the header, and
   loosen the container width so it fits any theme. */
.gr-portal-inline {
    background: transparent;
    min-height: 0;
    padding: 0;
    /* Inherit text color from theme so dark themes look right */
    color: inherit;
}
.gr-portal-header-inline {
    background: transparent;
    border-bottom: 1px solid var(--gr-border);
    padding: 12px 0;
}
.gr-portal-header-inline .gr-portal-brand {
    font-size: 16px;
    color: var(--gr-muted);
}
.gr-portal-header-inline .gr-portal-logo {
    /* Inherits from .gr-portal-logo above; max-width comes from --gr-logo-max-width. */
}
.gr-portal-footer-inline {
    background: transparent;
    border-top: 1px solid var(--gr-border);
    margin-top: 24px;
    padding: 14px 0;
    font-size: 12px;
    color: var(--gr-muted);
    text-align: center;
}
.gr-portal-inline .gr-portal-container {
    max-width: 100%;
    padding: 16px 0;
}
.gr-portal-inline .gr-portal-title {
    font-size: 22px;
    margin-top: 0;
}
