/* ==========================================================================
   SleepWell Web Application Design System & Stylesheet
   Elderly-friendly redesign: light, high-contrast theme, larger type,
   larger touch targets, clearer selected-state feedback.
   ========================================================================== */

:root {
    --bg-main: #eef2f7;
    --bg-card: #ffffff;
    --bg-card-solid: #f8fafc;
    --bg-subtle: #f1f5f9;

    --border-color: #e2e8f0;
    --border-color-strong: #64748b;
    --border-color-hover: #0284c7;

    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-glow: rgba(2, 132, 199, 0.22);

    --accent: #047857;
    --warning: #b45309;
    --danger: #dc2626;
    --danger-bg: #fef2f2;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;

    --shadow-card: 0 10px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
}

/* Base scale bump: 1rem = 18px instead of 16px, so every rem-based size
   below is already ~12% larger before the individual bumps applied to
   previously undersized text (labels, hints, buttons). */
html {
    font-size: 112.5%;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 40px 16px;
    line-height: 1.7;
}

/* App Header */
.app-header {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    height: 46px;
    width: auto;
    object-fit: contain;
}

.brand-title-group h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

.brand-title-group p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Font size adjuster (A- / A / A+) */
.font-size-toggle {
    display: flex;
    gap: 8px;
}

.font-toggle-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    background: var(--bg-card-solid);
    border: 1.5px solid var(--border-color-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.font-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.font-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.font-toggle-btn:focus-visible,
.form-input:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 760px;
}

/* Card Component */
.glass-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.onboarding-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--primary-hover);
    border-bottom: 1.5px solid var(--border-color);
    padding-bottom: 14px;
}

/* Form Controls */
.form-group {
    margin-bottom: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 22px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-label {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.optional {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    background: var(--bg-card-solid);
    border: 1.5px solid var(--border-color-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Radio & Checkbox Card Groups */
.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.radio-card, .checkbox-card {
    position: relative;
    flex: 1 1 calc(50% - 12px);
    min-width: 130px;
}

@media (max-width: 480px) {
    .radio-card, .checkbox-card {
        flex: 1 1 100%;
    }
}

.radio-card input, .checkbox-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-card label, .checkbox-card label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 14px 16px;
    text-align: center;
    background: var(--bg-card-solid);
    border: 2px solid var(--border-color-strong);
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.radio-card input:focus-visible + label,
.checkbox-card input:focus-visible + label {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.radio-card input:checked + label, .checkbox-card input:checked + label {
    background: rgba(2, 132, 199, 0.1);
    border-color: var(--primary);
    border-width: 3px;
    color: var(--primary-hover);
    font-weight: 700;
}

.radio-card input:checked + label::before, .checkbox-card input:checked + label::before {
    content: '✓ ';
}

/* MST Skin Tone Selector */
.mst-container {
    margin-top: 8px;
}

.mst-color-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--bg-card-solid);
    border: 1.5px solid var(--border-color-strong);
}

.mst-block {
    height: 58px;
    position: relative;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease;
    border: 2px solid transparent;
}

.mst-block:hover {
    transform: scale(1.05);
    z-index: 2;
}

.mst-block input {
    position: absolute;
    opacity: 0;
}

.mst-block label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    cursor: pointer;
}

.mst-block input:focus-visible + label {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.mst-block input:checked + label {
    box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px var(--primary);
}

.mst-selected-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: right;
}

/* Buttons */
.btn-primary {
    width: 100%;
    min-height: 58px;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.form-error {
    color: var(--danger);
    background: var(--danger-bg);
    border: 1.5px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: none;
}

.form-error.visible {
    display: block;
}

/* Survey Page Styles */
.survey-section-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 22px;
}

.survey-card-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.survey-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    min-height: 64px;
    background: var(--bg-card-solid);
    border: 2px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.survey-card:hover {
    border-color: var(--primary);
}

.survey-card.selected {
    background: rgba(2, 132, 199, 0.1);
    border-color: var(--primary);
    border-width: 3px;
    box-shadow: 0 0 0 1px var(--primary-glow);
}

.survey-card-num {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary-hover);
}

.survey-card.selected .survey-card-num {
    background: var(--primary);
    color: #fff;
}

.survey-card-text {
    display: flex;
    flex-direction: column;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.survey-card-text small {
    font-size: 0.92rem;
    color: var(--text-muted);
    font-weight: normal;
    margin-top: 2px;
}

/* Likert Group */
.survey-likert-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.survey-likert-item {
    background: var(--bg-card-solid);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
}

.survey-likert-question {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.q-num {
    color: var(--primary-hover);
    margin-right: 8px;
}

.survey-likert-options {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.survey-likert-opt-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.survey-likert-btn {
    width: 100%;
    min-height: 54px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 2px solid var(--border-color-strong);
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.survey-likert-btn:hover {
    border-color: var(--primary);
}

.survey-likert-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.survey-likert-btn.selected {
    background: var(--primary);
    border-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 0 0 3px var(--primary-glow);
    transform: scale(1.06);
}

.survey-likert-opt-label {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
}

/* Survey Footer Controls */
.survey-footer-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1.5px solid var(--border-color);
}

.btn-secondary {
    min-height: 54px;
    padding: 14px 22px;
    background: #ffffff;
    border: 2px solid var(--border-color-strong);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary-hover);
}

.progress-bar-container {
    width: 100%;
    height: 14px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 22px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    width: 25%;
    transition: width 0.3s ease;
}

/* Animations */
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOutLeft {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-30px); }
}
