/* ═══════════════════════════════════════════════
   SurveyFlow Frontend — Polished Survey UI
═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
    --sf-fe-bg:        #0f0f1a;
    --sf-fe-surface:   #1a1a2e;
    --sf-fe-card:      #22223a;
    --sf-fe-border:    rgba(255,255,255,.1);
    --sf-fe-text:      #f0f0f8;
    --sf-fe-muted:     rgba(240,240,248,.5);
    --sf-fe-accent:    #7c6fff;
    --sf-fe-accent2:   #5ffbb0;
    --sf-fe-danger:    #ff6b8a;
    --sf-fe-radius:    18px;
    --sf-fe-glow:      0 0 40px rgba(124,111,255,.18);
}

/* ── Wrap ── */
.sf-survey-wrap {
    font-family: 'DM Sans', sans-serif;
    color: var(--sf-fe-text);
    position: relative;
    min-height: 400px;
}

/* ── Loading ── */
.sf-loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 16px;
    color: var(--sf-fe-muted);
}
.sf-loader {
    width: 40px; height: 40px;
    border: 3px solid rgba(124,111,255,.2);
    border-top-color: var(--sf-fe-accent);
    border-radius: 50%;
    animation: sfSpin .7s linear infinite;
}
@keyframes sfSpin { to { transform: rotate(360deg); } }

/* ── Container ── */
.sf-survey-container {
    background: var(--sf-fe-bg);
    border-radius: var(--sf-fe-radius);
    overflow: hidden;
    box-shadow: var(--sf-fe-glow), 0 20px 60px rgba(0,0,0,.4);
    position: relative;
}

/* ── Decorative bg gradient ── */
.sf-survey-container::before {
    content: '';
    position: absolute;
    top: -80px; right: -80px;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124,111,255,.18) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Header ── */
.sf-survey-header {
    padding: 36px 40px 24px;
    position: relative;
    z-index: 1;
}
.sf-survey-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.9rem;
    color: var(--sf-fe-text);
    margin: 0 0 8px;
    line-height: 1.2;
}
.sf-survey-desc {
    color: var(--sf-fe-muted);
    font-size: .95rem;
    margin: 0 0 20px;
    line-height: 1.6;
}

/* ── Progress ── */
.sf-progress-wrap { margin-top: 12px; }
.sf-progress-bar {
    height: 5px;
    background: rgba(255,255,255,.08);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 6px;
}
.sf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sf-fe-accent), var(--sf-fe-accent2));
    border-radius: 20px;
    transition: width .5s cubic-bezier(.4,0,.2,1);
}
.sf-progress-label {
    font-size: .78rem;
    color: var(--sf-fe-muted);
    text-align: right;
}

/* ── Viewport ── */
.sf-questions-viewport {
    overflow: hidden;
    position: relative;
    z-index: 1;
    min-height: 300px;
}
/* Track is just a relative container; slides stack via absolute positioning */
.sf-questions-track {
    position: relative;
    min-height: 300px;
}

/* ── Question card ── */
.sf-question-slide {
    width: 100%;
    padding: 32px 40px;
    box-sizing: border-box;
    /* hidden by default; JS calls .show()/.hide() */
}
.sf-question-number {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--sf-fe-accent);
    margin-bottom: 10px;
}
.sf-question-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sf-fe-muted);
    margin-bottom: 6px;
}
.sf-question-text {
    font-family: 'DM Serif Display', serif;
    font-size: 1.45rem;
    line-height: 1.4;
    color: var(--sf-fe-text);
    margin-bottom: 28px;
}
.sf-required-asterisk { color: var(--sf-fe-danger); }

/* ── Answer types ── */

/* Short text / paragraph */
.sf-input-text, .sf-input-para {
    width: 100%;
    background: var(--sf-fe-card);
    border: 2px solid var(--sf-fe-border);
    border-radius: 12px;
    padding: 14px 18px;
    color: var(--sf-fe-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    resize: none;
}
.sf-input-text:focus, .sf-input-para:focus {
    outline: none;
    border-color: var(--sf-fe-accent);
    box-shadow: 0 0 0 4px rgba(124,111,255,.15);
}
.sf-input-para { min-height: 120px; }

/* Yes/No */
.sf-yn-group { display: flex; gap: 14px; }
.sf-yn-btn {
    flex: 1;
    padding: 20px;
    border: 2px solid var(--sf-fe-border);
    border-radius: 14px;
    background: var(--sf-fe-card);
    color: var(--sf-fe-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.sf-yn-btn::after {
    content: '';
    position: absolute; inset: 0;
    background: var(--sf-fe-accent);
    opacity: 0;
    transition: opacity .2s;
    border-radius: inherit;
}
.sf-yn-btn:hover { border-color: var(--sf-fe-accent); transform: translateY(-2px); }
.sf-yn-btn.selected { border-color: var(--sf-fe-accent); background: rgba(124,111,255,.15); }
.sf-yn-btn.selected .sf-yn-icon { color: var(--sf-fe-accent2); }
.sf-yn-icon { display: block; font-size: 1.8rem; margin-bottom: 6px; }

/* Multiple choice */
.sf-mc-list { display: flex; flex-direction: column; gap: 10px; }
.sf-mc-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 2px solid var(--sf-fe-border);
    border-radius: 12px;
    background: var(--sf-fe-card);
    cursor: pointer;
    transition: all .18s;
    font-size: .96rem;
    font-weight: 500;
}
.sf-mc-option:hover { border-color: var(--sf-fe-accent); transform: translateX(4px); }
.sf-mc-option.selected { border-color: var(--sf-fe-accent); background: rgba(124,111,255,.12); }
.sf-mc-option.selected .sf-mc-dot { background: var(--sf-fe-accent); border-color: var(--sf-fe-accent); }
.sf-mc-option.selected .sf-mc-dot::after { opacity:1; }
.sf-mc-dot {
    width: 20px; height: 20px;
    border: 2px solid var(--sf-fe-border);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all .18s;
}
.sf-mc-dot::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .18s;
}
.sf-mc-multi .sf-mc-dot { border-radius: 4px; }
.sf-mc-multi .sf-mc-dot::after { border-radius: 2px; }

/* Scale */
.sf-scale-wrap { padding: 10px 0; }
.sf-scale-labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--sf-fe-muted); margin-bottom: 12px; }
.sf-scale-track {
    position: relative;
    height: 6px;
    background: rgba(255,255,255,.1);
    border-radius: 10px;
    margin-bottom: 20px;
    cursor: pointer;
}
.sf-scale-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: linear-gradient(90deg, var(--sf-fe-accent), var(--sf-fe-accent2));
    border-radius: 10px;
    transition: width .15s;
    pointer-events: none;
}
.sf-scale-thumb {
    position: absolute;
    top: 50%; transform: translate(-50%, -50%);
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.3), 0 0 0 3px var(--sf-fe-accent);
    cursor: grab;
    z-index: 2;
    transition: box-shadow .15s, transform .1s;
}
.sf-scale-thumb:active { cursor: grabbing; transform: translate(-50%,-50%) scale(1.15); }
.sf-scale-numbers { display: flex; justify-content: space-between; font-size: .82rem; color: var(--sf-fe-muted); }
.sf-scale-value-display {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--sf-fe-accent);
    margin-bottom: 10px;
    font-family: 'DM Serif Display', serif;
    min-height: 2.5rem;
}

/* Rubric */
.sf-rubric-wrap { overflow-x: auto; }
.sf-rubric-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 400px; }
.sf-rubric-table th {
    padding: 10px 12px;
    text-align: center;
    color: var(--sf-fe-muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--sf-fe-border);
}
.sf-rubric-table th:first-child { text-align: left; }
.sf-rubric-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.sf-rubric-table td:first-child { text-align: left; color: var(--sf-fe-muted); }
.sf-rubric-radio {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid var(--sf-fe-border);
    display: inline-block;
    cursor: pointer;
    transition: all .15s;
    position: relative;
}
.sf-rubric-radio.selected { background: var(--sf-fe-accent); border-color: var(--sf-fe-accent); box-shadow: 0 0 10px rgba(124,111,255,.4); }

/* ── Nav ── */
.sf-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px 30px;
    position: relative;
    z-index: 1;
}
.sf-btn-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
    border: none;
}
.sf-btn-next {
    background: linear-gradient(135deg, var(--sf-fe-accent), #9b8fff);
    color: #fff;
    box-shadow: 0 4px 18px rgba(124,111,255,.35);
}
.sf-btn-next:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(124,111,255,.45); }
.sf-btn-next:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.sf-btn-back {
    background: rgba(255,255,255,.07);
    color: var(--sf-fe-muted);
    border: 1px solid var(--sf-fe-border);
}
.sf-btn-back:hover { background: rgba(255,255,255,.12); color: var(--sf-fe-text); }

.sf-btn-save-progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--sf-fe-accent);
    color: var(--sf-fe-accent);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: .82rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s;
}
.sf-btn-save-progress:hover { background: rgba(124,111,255,.12); }

/* ── Save modal ── */
.sf-save-modal {
    position: absolute; inset: 0;
    background: rgba(15,15,26,.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--sf-fe-radius);
    animation: sfFadeIn .2s ease;
}
.sf-save-modal-box {
    background: var(--sf-fe-card);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.sf-save-modal-box h3 { margin: 0 0 8px; font-family: 'DM Serif Display', serif; font-size: 1.4rem; }
.sf-save-modal-box p  { margin: 0 0 20px; color: var(--sf-fe-muted); font-size: .9rem; line-height: 1.6; }
.sf-frontend-input {
    width: 100%;
    background: rgba(255,255,255,.06);
    border: 2px solid var(--sf-fe-border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--sf-fe-text);
    font-family: 'DM Sans', sans-serif;
    font-size: .95rem;
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color .18s;
}
.sf-frontend-input:focus { outline:none; border-color: var(--sf-fe-accent); }
.sf-save-actions { display: flex; gap: 10px; margin-top: 8px; justify-content: flex-end; }
.sf-btn-cancel {
    background: none; border: 1px solid var(--sf-fe-border);
    color: var(--sf-fe-muted); border-radius: 10px; padding: 10px 20px;
    cursor: pointer; font-family:'DM Sans',sans-serif; font-size:.9rem;
    transition: all .18s;
}
.sf-btn-cancel:hover { background: rgba(255,255,255,.07); color: var(--sf-fe-text); }
.sf-btn-primary-fe {
    background: linear-gradient(135deg, var(--sf-fe-accent), #9b8fff);
    color: #fff; border: none; border-radius: 10px;
    padding: 10px 20px; cursor: pointer;
    font-family:'DM Sans',sans-serif; font-size:.9rem; font-weight:700;
    transition: all .2s; box-shadow: 0 3px 14px rgba(124,111,255,.3);
}
.sf-btn-primary-fe:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,111,255,.4); }

/* ── Completion ── */
.sf-completion {
    position: absolute; inset: 0;
    background: var(--sf-fe-bg);
    border-radius: var(--sf-fe-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: sfFadeIn .4s ease;
}
.sf-completion-inner { text-align: center; padding: 40px; }
.sf-completion-icon {
    width: 80px; height: 80px;
    margin: 0 auto 24px;
    color: var(--sf-fe-accent2);
    animation: sfCheckIn .5s .2s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes sfCheckIn {
    from { opacity:0; transform: scale(.5); }
    to   { opacity:1; transform: scale(1); }
}
.sf-completion-title {
    font-family: 'DM Serif Display', serif;
    font-size: 2.2rem;
    margin: 0 0 12px;
    color: var(--sf-fe-text);
}
.sf-completion-msg {
    color: var(--sf-fe-muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

/* ── Transition animations ── */
/* NOTE: we use animation-fill-mode: none so that when JS removes the class the element snaps back to its natural state */
@keyframes sfFadeIn { from{opacity:0}to{opacity:1} }

/* Slide – exit leaves at opacity:0 so JS can hide(); enter brings in from side */
.sf-transition-slide-exit-left  { animation: sfSlideOutLeft  .28s ease both; }
.sf-transition-slide-exit-right { animation: sfSlideOutRight .28s ease both; }
.sf-transition-slide-enter-right{ animation: sfSlideInRight  .32s ease both; }
.sf-transition-slide-enter-left { animation: sfSlideInLeft   .32s ease both; }
@keyframes sfSlideOutLeft  { 0%{opacity:1;transform:none}        100%{opacity:0;transform:translateX(-50px)} }
@keyframes sfSlideOutRight { 0%{opacity:1;transform:none}        100%{opacity:0;transform:translateX(50px)}  }
@keyframes sfSlideInRight  { 0%{opacity:0;transform:translateX(50px)}  100%{opacity:1;transform:none} }
@keyframes sfSlideInLeft   { 0%{opacity:0;transform:translateX(-50px)} 100%{opacity:1;transform:none} }

/* Fade */
.sf-transition-fade-exit  { animation: sfFadeOut    .22s ease both; }
.sf-transition-fade-enter { animation: sfFadeInAnim .28s ease both; }
@keyframes sfFadeOut    { 0%{opacity:1} 100%{opacity:0} }
@keyframes sfFadeInAnim { 0%{opacity:0} 100%{opacity:1} }

/* Flip */
.sf-transition-flip-exit  { animation: sfFlipOut .25s ease both; }
.sf-transition-flip-enter { animation: sfFlipIn  .30s ease both; }
@keyframes sfFlipOut { 0%{opacity:1;transform:none} 100%{opacity:0;transform:rotateY(80deg) scale(.96)} }
@keyframes sfFlipIn  { 0%{opacity:0;transform:rotateY(-80deg) scale(.96)} 100%{opacity:1;transform:none} }

/* Zoom */
.sf-transition-zoom-exit  { animation: sfZoomOut .22s ease both; }
.sf-transition-zoom-enter { animation: sfZoomIn  .28s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes sfZoomOut { 0%{opacity:1;transform:none} 100%{opacity:0;transform:scale(.88)} }
@keyframes sfZoomIn  { 0%{opacity:0;transform:scale(.88)} 100%{opacity:1;transform:none} }

/* Bounce */
.sf-transition-bounce-exit  { animation: sfBounceOut .28s ease both; }
.sf-transition-bounce-enter { animation: sfBounceIn  .42s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes sfBounceOut { 0%{opacity:1;transform:none} 100%{opacity:0;transform:translateY(-28px) scale(.96)} }
@keyframes sfBounceIn  { 0%{opacity:0;transform:translateY(36px) scale(.96)} 100%{opacity:1;transform:none} }

/* ── Responsive ── */
@media (max-width: 600px) {
    .sf-survey-header, .sf-question-slide, .sf-nav { padding-left: 20px; padding-right: 20px; }
    .sf-survey-title { font-size: 1.4rem; }
    .sf-question-text { font-size: 1.15rem; }
    .sf-yn-group { flex-direction: column; }
}

.sf-question-subtext { font-size:.9rem; color:var(--sf-fe-muted); margin:-8px 0 20px; line-height:1.5; }

/* ── Category badge ── */
.sf-question-category {
    margin-bottom: 12px;
}
.sf-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    color: var(--sf-fe-accent, #a78bfa);
}
.sf-category-badge::before {
    content: '📂';
    font-size: .8rem;
    letter-spacing: 0;
}

/* ── Identity (name/email) question ── */
.sf-identity-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}
.sf-identity-fields .sf-input-text {
    width: 100%;
}

/* ── Block 2: Category banner ── */
.sf-category-block {
    padding: 0 40px 0;
    position: relative;
    z-index: 1;
}
.sf-category-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    background: rgba(124,111,255,.12);
    border: 1px solid rgba(124,111,255,.3);
    color: var(--sf-fe-accent, #a78bfa);
    margin-bottom: 0;
}
.sf-category-name::before {
    content: '\1F4C2';
    font-size: .85rem;
    letter-spacing: 0;
}
