/* ============================================================================
   viewer-style.css - Survey Viewer (Editorial Theme)
   Redesigned to match the "Aldercroft Research" style reference:
   warm cream page, slim brand bar, numbered questions,
   hairline dividers, boxed rating scales, outlined amber buttons.
   Typography is sans-serif throughout for both EN and AR (no serif/Lora
   split) so the two languages render with matching styling.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');

/* ── RTL: force Cairo everywhere, including the serif hero ─────────────────── */
[dir="rtl"] body,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] p,
[dir="rtl"] a,
[dir="rtl"] span,
[dir="rtl"] label,
[dir="rtl"] button,
[dir="rtl"] .sd-btn,
[dir="rtl"] .filter-select,
[dir="rtl"] .survey-hero-title,
[dir="rtl"] .survey-eyebrow,
[dir="rtl"] .sd-question__title,
[dir="rtl"] .sd-element__num {
    font-family: "Cairo", sans-serif !important;
}

[dir="ltr"] #surveyContainer,
[dir="ltr"] .sd-root-modern {
    direction: ltr;
    text-align: left;
}

[dir="rtl"] #surveyContainer,
[dir="rtl"] .sd-root-modern {
    direction: rtl;
    text-align: right;
}

:root {
    /* ── Tenant-themed (set per subsidiary by themeManager) ──────────────── */
    --primary-color: #a57c35;
    --secondary-color: #766e64;
    --light-color: #f4efe6;
    --dark-color: #222323;
    /* ── Editorial palette (static, not tenant-themed) ───────────────────── */
    --page-bg: #f6f4ee;
    --nav-bg: #ffffff;
    --ink: #262a41;
    --ink-soft: #454a63;
    --muted: #8b8d7f;
    --hairline: #e3e0d4;
    --card-bg: #ffffff;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    /* Serif ("editorial") treatment retired — EN now matches AR's sans styling everywhere.
       Kept as an alias (rather than rewriting every rule below) so this is a one-line fix. */
    --font-serif: var(--font-sans);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--page-bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   Top brand bar — slim, white, single hairline border
   ========================================================================== */

.survey-header {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--hairline);
    padding: 16px 32px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
}

.survey-logo {
    height: 32px;
    width: auto;
    justify-self: start;
}

/* The old small centered title bar is retired in favour of the hero below —
   keep the element in the DOM (JS still targets #surveyHeaderTitle) but hide
   it visually so nothing breaks if a page hasn't had the hero markup added yet. */
.survey-header-title {
    justify-self: start;
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 15px;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.language-selector {
    display: flex;
    gap: 8px;
    justify-self: end;
}

.lang-btn {
    padding: 6px 14px;
    border: 1px solid var(--hairline);
    background: transparent;
    color: var(--ink-soft);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

    .lang-btn:hover {
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .lang-btn.active {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: #ffffff;
    }

/* ============================================================================
   Hero — eyebrow, serif title, description, meta line
   ========================================================================== */

.survey-hero {
    max-width: 720px;
    margin: 0 auto;
    padding: 56px 24px 28px;
    width: 100%;
}

.survey-eyebrow {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 14px;
    display: block;
}

.survey-hero-title {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 40px;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 18px;
}

.survey-hero-desc {
    font-size: 15.5px;
    line-height: 1.75;
    color: var(--ink-soft);
    max-width: 620px;
    margin-bottom: 22px;
}

.survey-hero-rule {
    max-width: 720px;
    margin: 0 auto;
    border: none;
    border-top: 1px solid var(--hairline);
}

/* ============================================================================
   Container / survey body
   ========================================================================== */

.container {
    flex: 1;
    width: 100%;
}

/* ============================================================================
   Loading state
   ========================================================================== */

.loading-container {
    text-align: center;
    padding: 100px 20px;
}

.loading-spinner {
    border: 3px solid var(--hairline);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 20px;
}

.loading-container p {
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   Error / gate state
   ========================================================================== */

.error-container {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    max-width: 560px;
    margin: 60px auto;
}

    .error-container h2 {
        font-family: var(--font-serif);
        color: var(--ink);
        margin-bottom: 16px;
        text-align: center;
    }

    .error-container p {
        text-align: center;
        color: var(--ink-soft);
        font-size: 15px;
    }

    .error-container button {
        background: transparent;
        color: var(--primary-color);
        border: 1px solid var(--primary-color);
        padding: 10px 22px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        margin-top: 20px;
        transition: all 0.15s;
    }

        .error-container button:hover {
            background: var(--primary-color);
            color: #ffffff;
        }

/* ============================================================================
   Survey container — no card box, sits directly on the cream page
   ========================================================================== */

#surveyContainer {
    background: transparent;
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 24px 60px;
}

/* Thank-you screen */
.thank-you-content {
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 64px 40px;
    max-width: 560px;
    margin: 60px auto;
}

    .thank-you-content h2 {
        font-family: var(--font-serif);
        color: var(--ink);
        font-size: 30px;
        margin-bottom: 16px;
    }

    .thank-you-content p {
        color: var(--ink-soft);
        font-size: 16px;
    }

/* ============================================================================
   SurveyJS — question header, numbering, dividers
   ========================================================================== */

#surveyContainer {
    counter-reset: qNum;
}

/* Every top-level question gets a hairline divider above it, and a
   zero-padded number in the left gutter. Panels/rows are excluded from the
   counter so nested content doesn't throw off the sequence. */
.sd-question,
.sd-element--with-frame {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.sd-question {
    counter-increment: qNum;
    position: relative;
    padding: 26px 0 26px 44px !important;
    margin: 0 !important;
    border-top: 1px solid var(--hairline);
}

    .sd-question::before {
        content: counter(qNum, decimal-leading-zero);
        position: absolute;
        left: 0;
        top: 30px;
        font-family: var(--font-serif);
        font-style: italic;
        font-size: 13px;
        font-weight: 600;
        color: var(--primary-color);
    }

[dir="rtl"] .sd-question {
    padding: 26px 44px 26px 0 !important;
}

    [dir="rtl"] .sd-question::before {
        left: auto;
        right: 0;
    }

/* Hide SurveyJS's own numbering — we render our own via ::before above */
.sd-element__num {
    display: none !important;
}

.sd-title.sd-element__title,
.sd-question__title {
    font-family: var(--font-sans) !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    color: var(--ink) !important;
    text-align: inherit !important;
}

/* Question description (the "Choose one." / "Select all that apply." caption) */
.sd-description,
.sd-question__description {
    font-size: 13px !important;
    color: var(--muted) !important;
    margin-top: 4px !important;
    font-style: italic;
}

/* Survey-level title/description are switched off in JS in favour of the
   hero block, but keep a safe fallback style in case either ever renders. */
.sd-title.sd-container-modern__title {
    font-family: var(--font-serif) !important;
    color: var(--ink) !important;
    padding: 15px !important;
}

/* ============================================================================
   Choice inputs — radio / checkbox
   ========================================================================== */

.sd-selectbase__item {
    margin-bottom: 10px !important;
}

.sd-item__decorator {
    border-color: #cfcabb !important;
}

.sd-radio__decorator {
    border-radius: 50% !important;
}

.sd-selectbase__item--checked .sd-item__decorator {
    border-color: var(--primary-color) !important;
}

/* Only the SELECTED item's dot/check gets coloured — unselected items keep
   a plain outline with no inner fill. */
.sd-selectbase__item--checked .sd-radio__decorator use,
.sd-selectbase__item--checked .sd-radio__svg use,
.sd-selectbase__item--checked .sd-checkbox__svg use {
    fill: var(--primary-color) !important;
}

.sd-selectbase__item--checked .sd-checkbox__decorator {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.sd-item__control-label {
    font-size: 14.5px !important;
    font-weight: 400 !important;
    color: var(--ink-soft) !important;
}

.sd-selectbase__item--checked .sd-item__control-label {
    color: var(--ink) !important;
    font-weight: 500 !important;
}







.sd-rating__min-text,
.sd-rating__max-text {
    font-size: 11px !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted) !important;
}


.sd-rating__item-star {
    border: none !important;
    background: transparent !important;
}

    .sd-rating__item-star .sv-star {
        fill: var(--hairline) !important;
    }

    .sd-rating__item-star .sv-star-2 {
        fill: var(--primary-color) !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

.sd-rating__item-star--selected .sv-star-2 {
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
}

/* ============================================================================
   Boolean — Yes / No segmented toggle
   ========================================================================== */

.sd-boolean__switch {
    display: none !important; /* replaced visually by the label buttons below */
}

.sd-boolean {
    display: flex !important;
    gap: 8px;
}

.sd-boolean__label {
    border: 1px solid var(--hairline) !important;
    border-radius: 4px !important;
    padding: 8px 20px !important;
    font-size: 14px !important;
    color: var(--ink-soft) !important;
}

.sd-boolean--checked .sd-boolean__label,
.sd-boolean__thumb-text--checked {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    font-weight: 600;
}

/* ============================================================================
   Matrix
   ========================================================================== */

.sd-table {
    border-collapse: collapse !important;
}

.sd-table__cell {
    border-color: var(--hairline) !important;
    font-size: 13.5px !important;
    color: var(--ink-soft) !important;
}

.sd-table__cell--header {
    color: var(--muted) !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================================
   Ranking (drag to reorder)
   ========================================================================== */

.sd-ranking-item__index {
    background: transparent !important;
    color: var(--primary-color) !important;
    font-family: var(--font-serif) !important;
    font-style: italic;
}

.sd-ranking-item__content {
    border: 1px solid var(--hairline) !important;
    border-radius: 4px !important;
    background: #ffffff !important;
}

.sd-ranking-item__icon-container svg {
    fill: var(--muted) !important;
}

/* ============================================================================
   Comment / long text
   ========================================================================== */

.sd-comment,
.sd-input {
    border: 1px solid var(--hairline) !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: var(--ink) !important;
    font-size: 14.5px !important;
}

    .sd-comment:focus,
    .sd-input:focus {
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 3px rgba(165, 124, 53, 0.12) !important;
    }

    .sd-comment::placeholder,
    .sd-input::placeholder {
        color: #b3ae9e !important;
    }

.sd-charcounter,
.sd-text__char-counter {
    font-size: 11.5px !important;
    color: var(--muted) !important;
}

/* ============================================================================
   Navigation / footer buttons
   ========================================================================== */

.sd-body__navigation,
.sd-action-bar {
    border-top: 1px solid var(--hairline) !important;
    padding-top: 22px !important;
    margin-top: 6px !important;
}

.sd-navigation__complete-btn,
.sd-btn--action,
.sd-btn--action.sd-navigation__complete-btn {
    background: transparent !important;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    padding: 11px 26px !important;
    opacity: 1 !important;
    transition: all 0.15s;
}

    .sd-navigation__complete-btn *,
    .sd-btn--action * {
        color: inherit !important;
    }

    .sd-navigation__complete-btn:hover,
    .sd-btn--action:hover,
    .sd-btn--action.sd-navigation__complete-btn:hover {
        background-color: var(--primary-color) !important;
        color: #ffffff !important;
    }

    /* Disabled (e.g. required questions still unanswered) — dimmed but legible,
   never pale-on-pale. */
    .sd-navigation__complete-btn:disabled,
    .sd-btn--action:disabled,
    .sd-btn--action.sd-navigation__complete-btn:disabled {
        background: transparent !important;
        color: var(--muted) !important;
        border-color: var(--hairline) !important;
        opacity: 1 !important;
        cursor: not-allowed;
    }

.sd-navigation__prev-btn {
    color: var(--ink-soft) !important;
    border-color: var(--hairline) !important;
    background: transparent !important;
}

    .sd-navigation__prev-btn:hover {
        border-color: var(--primary-color) !important;
        color: var(--primary-color) !important;
    }

.sd-progress__bar {
    background-color: var(--primary-color) !important;
}

.sd-progress {
    background-color: var(--hairline) !important;
}

/* ============================================================================
   Responsive — condensed nav, tighter hero, stacked meta
   ========================================================================== */

@media (max-width: 768px) {
    .survey-header {
        padding: 12px 16px;
        grid-template-columns: auto 1fr auto;
        gap: 10px;
    }

    .survey-logo {
        height: 24px;
    }

    .survey-header-title {
        font-size: 13px;
    }

    .language-selector {
        gap: 6px;
    }

    .lang-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .survey-hero {
        padding: 32px 18px 20px;
    }

    .survey-eyebrow {
        font-size: 10.5px;
        margin-bottom: 10px;
    }

    .survey-hero-title {
        font-size: 26px;
        margin-bottom: 12px;
    }

    .survey-hero-desc {
        font-size: 14px;
        line-height: 1.65;
        margin-bottom: 16px;
    }

    .survey-hero-rule {
        margin: 0 18px;
    }

    #surveyContainer {
        padding: 0 18px 40px;
    }

    .sd-question {
        padding: 20px 0 20px 32px !important;
    }

    [dir="rtl"] .sd-question {
        padding: 20px 32px 20px 0 !important;
    }

    .sd-question::before {
        font-size: 12px;
        top: 24px;
    }

    .sd-title.sd-element__title,
    .sd-question__title {
        font-size: 14.5px !important;
    }

    .thank-you-content {
        padding: 40px 24px;
        margin: 30px auto;
    }

        .thank-you-content h2 {
            font-size: 24px;
        }

        .thank-you-content p {
            font-size: 15px;
        }

    .error-container {
        margin: 30px auto;
        padding: 40px 20px;
    }
}

/* ============================================================================
   Signature pad
   ========================================================================== */

.sjs_sp_container,
.sd-signaturepad,
[class*="sp_container"] {
    overflow: visible !important;
}

.sjs_sp_clear,
.sd-signaturepad__clear,
[class*="sp_clear"],
[class*="signaturepad__clear"] {
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

.sjs_sp_container canvas,
.sd-signaturepad canvas,
[class*="sp_container"] canvas {
    position: relative !important;
    z-index: 0 !important;
    display: block !important;
}
