/* ═══════════════════════════════════════════════════
   AlphaView Star — Pre-Consultation Survey Styles
   Brand: Gold #8F6A42, Beige #CEA87F, Burgundy #723736, BG #F0EDE9
   ═══════════════════════════════════════════════════ */

:root {
    --gold: #8F6A42;
    --gold-light: #A4804E;
    --beige: #CEA87F;
    --beige-light: #E4CDB0;
    --burgundy: #723736;
    --burgundy-light: #8D4A49;
    --bg: #F0EDE9;
    --bg-card: #FFFFFF;
    --bg-selected: #FFF8F0;
    --text: #3A3A3A;
    --text-light: #7A7A7A;
    --text-muted: #B0A8A0;
    --border: #E5DDD5;
    --shadow: 0 2px 16px rgba(143, 106, 66, 0.08);
    --shadow-lg: 0 8px 32px rgba(143, 106, 66, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 50px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Montserrat', 'Inter', sans-serif;
}

/* ── Reset ────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-primary);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ── Loading Screen ───────────────────────────────── */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #F0EDE9 0%, #E9E2D9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    width: 180px;
    margin-bottom: 32px;
    animation: pulse 2s ease-in-out infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--beige-light);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-light);
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ── Error Screen ─────────────────────────────────── */
.error-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.error-content {
    text-align: center;
    padding: 40px;
}

.error-icon {
    font-size: 64px;
    color: var(--burgundy);
    margin-bottom: 16px;
}

.error-content h2 {
    font-family: var(--font-heading);
    color: var(--burgundy);
    font-size: 1.8rem;
    margin-bottom: 12px;
}

.error-content p {
    color: var(--text-light);
    margin-bottom: 24px;
    max-width: 300px;
}

/* ── App Container ────────────────────────────────── */
.app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ── Header ───────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92);
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-patient {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 500;
}

.header-patient .material-icons-round {
    font-size: 18px;
}

.patient-name-text {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Progress Bar ─────────────────────────────────── */
.progress-container {
    position: sticky;
    top: 57px;
    z-index: 99;
    background: #FFFFFF;
    padding: 8px 20px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--beige-light);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--progress, 6.67%);
    background: linear-gradient(90deg, var(--gold), var(--beige));
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 45px;
    text-align: right;
}

/* ── Steps ────────────────────────────────────────── */
.step-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.step {
    position: absolute;
    inset: 0;
    padding: 24px 20px 120px;
    overflow-y: auto;
    opacity: 0;
    transform: translateX(60px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    -webkit-overflow-scrolling: touch;
}

.step.active {
    position: relative;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.step.exit-left {
    transform: translateX(-60px);
    opacity: 0;
}

.step-content {
    max-width: 520px;
    margin: 0 auto;
}

/* ── Welcome Step ─────────────────────────────────── */
.welcome-step {
    text-align: center;
    padding-top: 20px;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--beige));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 8px 24px rgba(143, 106, 66, 0.2);
}

.welcome-icon .material-icons-round {
    font-size: 36px;
    color: #FFFFFF;
}

.welcome-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 16px;
}

.brand-name {
    color: var(--gold);
    display: block;
    font-size: 1.8rem;
}

.welcome-subtitle {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.welcome-text {
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 20px;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--gold), var(--beige));
    color: #FFFFFF;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 28px;
}

.time-badge .material-icons-round {
    font-size: 18px;
}

/* ── Patient Card ─────────────────────────────────── */
.patient-card {
    background: #FFFFFF;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: left;
}

.patient-card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text);
}

.patient-card-row:not(:last-child) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.patient-card-row .material-icons-round {
    font-size: 20px;
    color: var(--gold);
}

/* ── Section Headers ──────────────────────────────── */
.section-header {
    text-align: center;
    margin-bottom: 24px;
}

.section-icon {
    font-size: 40px;
    color: var(--burgundy);
    display: block;
    margin-bottom: 12px;
}

.section-emoji {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--burgundy);
    margin-bottom: 6px;
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Option Cards (Radio Grid) ────────────────────── */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.options-grid.single-col {
    grid-template-columns: 1fr;
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: #FFFFFF;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--text);
    box-shadow: var(--shadow);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.option-card .material-icons-round {
    font-size: 32px;
    color: var(--beige);
    transition: var(--transition);
}

.option-card:active {
    transform: scale(0.96);
}

.option-card.selected {
    border-color: var(--gold);
    background: var(--bg-selected);
    box-shadow: 0 0 0 1px var(--gold), var(--shadow-lg);
}

.option-card.selected .material-icons-round {
    color: var(--gold);
}

.option-card.wide {
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    padding: 16px 20px;
}

.option-card.wide .material-icons-round {
    font-size: 28px;
}

.option-label {
    font-weight: 500;
}

/* ── Option Pills (Checkbox List) ─────────────────── */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: #FFFFFF;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    color: var(--text);
    text-align: left;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.option-pill:active {
    transform: scale(0.98);
}

.check-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 6px;
    border: 2px solid var(--beige);
    transition: var(--transition);
    position: relative;
    background: #FFFFFF;
}

.check-icon::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #FFFFFF;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition);
}

.option-pill.selected {
    border-color: var(--gold);
    background: var(--bg-selected);
}

.option-pill.selected .check-icon {
    background: var(--gold);
    border-color: var(--gold);
}

.option-pill.selected .check-icon::after {
    opacity: 1;
    transform: scale(1);
}

/* ── Outro / Text Input ───────────────────────────── */
.outro-field {
    margin-top: 16px;
    animation: slideDown 0.3s ease;
}

.text-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--text);
    background: #FFFFFF;
    transition: var(--transition);
    outline: none;
}

.text-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(143, 106, 66, 0.1);
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* ── Observações Textarea ────────────────────────── */
.observacoes-textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.6;
}

.char-counter {
    margin-top: 8px;
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Info Callout ─────────────────────────────────── */
.info-callout {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 20px;
    padding: 16px;
    background: rgba(143, 106, 66, 0.06);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--gold);
}

.info-callout .material-icons-round {
    font-size: 22px;
    color: var(--gold);
    margin-top: 1px;
}

.info-callout p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ── Navigation ───────────────────────────────────── */
.step-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.btn-back,
.btn-next,
.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-back {
    background: transparent;
    color: var(--text-light);
    border: 2px solid var(--border);
    flex: 0 0 auto;
}

.btn-back:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.btn-back .material-icons-round {
    font-size: 20px;
}

.btn-next {
    flex: 1;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(143, 106, 66, 0.3);
}

.btn-next:active {
    transform: scale(0.97);
}

.btn-next .material-icons-round {
    font-size: 20px;
}

.btn-submit {
    flex: 1;
    background: linear-gradient(135deg, var(--burgundy), var(--burgundy-light));
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(114, 55, 54, 0.3);
}

.btn-submit:active {
    transform: scale(0.97);
}

.btn-submit .material-icons-round {
    font-size: 20px;
}

/* ── Primary Button ───────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(143, 106, 66, 0.3);
    transition: var(--transition);
}

.btn-primary:active {
    transform: scale(0.97);
}

/* ── Success Screen ───────────────────────────────── */
.success-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #F0EDE9 0%, #E9E2D9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.6s ease;
}

.success-content {
    text-align: center;
    padding: 40px 24px;
}

.success-check {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: scaleIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.3);
}

.success-check .material-icons-round {
    font-size: 48px;
    color: #FFFFFF;
}

.success-content h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--burgundy);
    margin-bottom: 12px;
}

.success-content p {
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 340px;
    margin: 0 auto 8px;
}

.success-sub {
    color: var(--text-light) !important;
    font-size: 0.9rem !important;
}

.success-brand {
    margin-top: 32px;
}

.success-logo {
    width: 140px;
    opacity: 0.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ── Submitting Overlay ───────────────────────────── */
.submitting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(240, 237, 233, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.submitting-content {
    text-align: center;
}

.submitting-content p {
    margin-top: 16px;
    color: var(--gold);
    font-weight: 500;
}

/* ── Toast Notifications ──────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    width: 100%;
    max-width: 520px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

.toast .material-icons-round {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-error {
    background: linear-gradient(135deg, #723736, #8D4A49);
    color: #FFFFFF;
}

.toast-error .material-icons-round {
    color: #FFB4AB;
}

.toast-success {
    background: linear-gradient(135deg, #2E7D32, #43A047);
    color: #FFFFFF;
}

.toast-success .material-icons-round {
    color: #A5D6A7;
}

.toast-warning {
    background: linear-gradient(135deg, #8F6A42, #A4804E);
    color: #FFFFFF;
}

.toast-warning .material-icons-round {
    color: #FFE0B2;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 380px) {
    .welcome-title {
        font-size: 1.4rem;
    }

    .brand-name {
        font-size: 1.6rem;
    }

    .section-header h2 {
        font-size: 1.15rem;
    }

    .option-card {
        padding: 16px 10px;
    }

    .option-card .material-icons-round {
        font-size: 28px;
    }
}

@media (min-width: 601px) {
    body {
        background: linear-gradient(135deg, #DDD4C8 0%, #F0EDE9 50%, #DDD4C8 100%);
    }

    .app {
        margin-top: 0;
        box-shadow: var(--shadow-lg);
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* ── Search Screen ────────────────────────────────── */
.search-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #F0EDE9 0%, #E9E2D9 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 9998;
    overflow-y: auto;
    padding: 40px 20px;
}

.search-content {
    width: 100%;
    max-width: 460px;
    text-align: center;
}

.search-logo {
    width: 160px;
    margin-bottom: 24px;
}

.search-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--burgundy);
    margin-bottom: 4px;
}

.search-subtitle {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 28px;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: var(--beige);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 16px 50px 16px 50px;
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--text);
    background: #FFFFFF;
    outline: none;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(143, 106, 66, 0.12), var(--shadow-lg);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.loading-spinner.small {
    width: 22px;
    height: 22px;
    border-width: 2px;
}

.search-hint-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
}

.search-result-card {
    display: block;
    width: 100%;
    padding: 16px 20px;
    background: #FFFFFF;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-primary);
    box-shadow: var(--shadow);
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.search-result-card:hover,
.search-result-card:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold), var(--shadow-lg);
    transform: translateY(-1px);
}

.search-result-card:active {
    transform: scale(0.98);
}

.src-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 8px;
}

.src-name .material-icons-round {
    font-size: 24px;
    color: var(--gold);
}

.src-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-left: 34px;
}

.src-details > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.src-details .material-icons-round {
    font-size: 15px;
    color: var(--beige);
}

/* ── Accessibility ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}