/* ==========================================================================
   Calorify Web Demo Styles
   Interactive Meal Analysis & Polling Pipeline Demonstration
   ========================================================================== */

.demo-main {
    min-height: calc(100vh - 80px);
    padding: 3rem 1.5rem 6rem;
    background: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%);
}

.demo-container {
    max-width: 960px;
    margin: 0 auto;
}

/* Breadcrumb / Back Link */
.demo-back-nav {
    margin-bottom: 1.5rem;
}

.demo-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s ease, transform 0.2s ease;
}

.demo-back-link:hover {
    color: var(--primary);
    transform: translateX(-2px);
}

.demo-back-link svg {
    width: 16px;
    height: 16px;
}

/* Header / Hero */
.demo-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.demo-header .eyebrow {
    background: rgba(63, 138, 224, 0.1);
    color: var(--primary-dark);
    margin-bottom: 1rem;
    display: inline-flex;
}

.demo-header h1 {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 0.85rem;
}

.demo-header p {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Input Card */
.demo-card {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: box-shadow 0.3s ease;
}

.demo-card:hover {
    box-shadow: 0 8px 30px -4px rgba(15, 23, 42, 0.08);
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title-row h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title-row h2 svg {
    color: var(--primary);
    width: 20px;
    height: 20px;
}

.demo-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.65rem;
    background: rgba(63, 138, 224, 0.08);
    color: var(--primary);
    border: 1px solid rgba(63, 138, 224, 0.25);
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
}

.demo-mode-badge .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--primary);
    box-shadow: 0 0 0 0 rgba(63, 138, 224, 0.7);
    animation: pulseDot 2s infinite;
}

.demo-mode-badge.live {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.25);
}

.demo-mode-badge.live .pulse-dot {
    background-color: #10B981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

.demo-mode-badge.offline {
    background: rgba(245, 158, 11, 0.1);
    color: #B45309;
    border-color: rgba(245, 158, 11, 0.3);
}

.demo-mode-badge.offline .pulse-dot {
    background-color: #F59E0B;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: none;
}

.api-config-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
}

.api-config-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.api-config-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-weight: 600;
}

.api-config-label svg {
    width: 14px;
    height: 14px;
}

.api-endpoint-code {
    background: rgba(63, 138, 224, 0.08);
    color: var(--primary);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.btn-api-edit, .btn-toggle-mode {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0;
}

.btn-api-edit:hover, .btn-toggle-mode:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Collapsible request metadata */
.meta-details {
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.meta-details summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.meta-details summary::-webkit-details-marker {
    display: none;
}

.meta-details summary svg {
    width: 14px;
    height: 14px;
}

.meta-details summary::after {
    content: 'Show';
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

.meta-details[open] summary::after {
    content: 'Hide';
}

.meta-hint {
    font-weight: 500;
    color: #94A3B8;
}

.meta-details .meta-config-strip {
    margin: 0;
    padding: 0 0.85rem 0.85rem;
}

.meta-config-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0 1.25rem;
}

.meta-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 7rem;
}

.meta-field-wide {
    flex: 2 1 12rem;
}

.meta-field label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.meta-field input {
    padding: 0.45rem 0.6rem;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
}

.meta-field input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(63, 138, 224, 0.05);
}

.api-error-banner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    border-radius: var(--radius-md);
    color: #991B1B;
}

.api-error-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.api-error-content i, .api-error-content svg {
    color: #DC2626;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.api-error-text strong {
    display: block;
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.api-error-text p {
    font-size: 0.85rem;
    margin: 0;
    color: #7F1D1D;
    line-height: 1.4;
}

.api-error-text code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: monospace;
}

.api-error-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 2rem;
}

.btn-error-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    background: #DC2626;
    color: #fff;
    border: none;
    transition: opacity 0.2s;
}

.btn-error-action:hover {
    opacity: 0.9;
}

.btn-error-action.secondary {
    background: #fff;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

@keyframes pulseDot {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Prompt Input */
.prompt-input-wrapper {
    position: relative;
    margin-bottom: 1.25rem;
}

.meal-textarea {
    width: 100%;
    min-height: 110px;
    padding: 1rem 1.2rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    background: #FAFBFC;
    resize: vertical;
    outline: none;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.meal-textarea:focus {
    background: #FFFFFF;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(63, 138, 224, 0.15);
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Preset Chips */
.presets-section {
    margin-bottom: 1.5rem;
}

.presets-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.presets-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-chip {
    background: #F1F5F9;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.preset-chip:hover {
    background: #E2E8F0;
    border-color: #CBD5E1;
    transform: translateY(-1px);
}

.preset-chip svg {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}

.preset-chip.active {
    background: rgba(63, 138, 224, 0.12);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}

.preset-chip.active svg {
    color: var(--primary);
}

/* Action Button Bar */
.input-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-analyze {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #FFFFFF;
    border: none;
    padding: 0.9rem 2rem;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(63, 138, 224, 0.35);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-analyze:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(63, 138, 224, 0.45);
    filter: brightness(1.05);
}

.btn-analyze:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn-analyze svg {
    width: 18px;
    height: 18px;
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.85rem 1.4rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    background: #F1F5F9;
    color: var(--text-main);
}

/* Polling Telemetry Bar */
.telemetry-strip {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.telemetry-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.telemetry-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94A3B8;
    flex-shrink: 0;
}

.telemetry-indicator.active {
    background: var(--primary);
    animation: pulseDotPrimary 1.5s infinite;
}

.telemetry-indicator.complete {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.telemetry-endpoint {
    color: var(--text-main);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.telemetry-metric {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.telemetry-cycle {
    background: #FFFFFF;
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.telemetry-badge-code {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@keyframes pulseDotPrimary {
    0% {
        box-shadow: 0 0 0 0 rgba(63, 138, 224, 0.5);
    }
    70% {
        box-shadow: 0 0 0 5px rgba(63, 138, 224, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(63, 138, 224, 0);
    }
}

/* Pipeline Stepper */
.stepper-container {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.75rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.stepper-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.stepper-heading h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stepper-progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.stepper-progress-bar {
    height: 6px;
    background: #E2E8F0;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.stepper-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, #38BDF8 100%);
    transition: width 0.4s ease;
}

.steps-list {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.6rem;
}

.step-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-sm);
    background: #F8FAFC;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.step-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #E2E8F0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.step-icon-circle svg {
    width: 16px;
    height: 16px;
}

.step-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.step-sub {
    font-size: 0.7rem;
    color: #94A3B8;
}

/* Step States */
.step-box.pending .step-icon-circle {
    background: #F1F5F9;
    color: #94A3B8;
}

.step-box.active {
    background: rgba(63, 138, 224, 0.05);
    border-color: rgba(63, 138, 224, 0.3);
}

.step-box.active .step-icon-circle {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(63, 138, 224, 0.2);
    animation: rotatePulse 1.5s infinite;
}

.step-box.active .step-title {
    color: var(--primary-dark);
}

.step-box.completed {
    background: rgba(16, 185, 129, 0.04);
    border-color: rgba(16, 185, 129, 0.2);
}

.step-box.completed .step-icon-circle {
    background: #10B981;
    color: #FFFFFF;
}

.step-box.completed .step-title {
    color: #065F46;
}

@keyframes rotatePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

/* Results Section */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Intermediate Stage Card */
.stage-card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.75rem;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stage-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.85rem;
    margin-bottom: 1.25rem;
}

.stage-badge-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stage-number-pill {
    background: #EFF6FF;
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(63, 138, 224, 0.2);
}

.stage-badge-title h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.stage-timestamp {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Stage 1 (Components) Content */
.components-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.component-item-card {
    background: #FAFBFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.component-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prep-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #E2E8F0;
    color: var(--text-muted);
    text-transform: uppercase;
}

.component-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.component-meta span {
    color: var(--text-main);
    font-weight: 600;
}

/* Stage 2 (Ingredients) Content */
.ingredients-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.ingredients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.ingredients-table th {
    background: #F8FAFC;
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.ingredients-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #F1F5F9;
    color: var(--text-main);
}

.ingredients-table tr:last-child td {
    border-bottom: none;
}

.ingredient-primary-name {
    font-weight: 600;
    color: var(--text-main);
}

.ingredient-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gram-estimate-pill {
    background: #EFF6FF;
    color: var(--primary-dark);
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    font-size: 0.82rem;
}

.gram-variance {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 0.3rem;
}

/* Clarification Options */
.clarification-box {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.clarification-question {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.clarification-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.clarification-chip {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: #FFFFFF;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: default;
}

.clarification-chip.selected {
    background: rgba(63, 138, 224, 0.1);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}

/* Spinner */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Stage 3 (USDA) Content */
.usda-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.usda-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.usda-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fdc-badge {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.72rem;
    font-weight: 700;
    background: #E0E7FF;
    color: #4338CA;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.similarity-badge {
    font-size: 0.72rem;
    font-weight: 700;
    background: #ECFDF5;
    color: #065F46;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.usda-matched-food {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
}

.usda-hydrated-macros {
    display: flex;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-top: 0.5rem;
    border-top: 1px dashed #E2E8F0;
}

.usda-hydrated-macros strong {
    color: var(--text-main);
}

/* ==========================================================================
   Stage 4 / FINAL COMPLETE RESPONSE
   ========================================================================== */

.final-response-card {
    background: #FFFFFF;
    border: 2px solid rgba(63, 138, 224, 0.35);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 35px -5px rgba(63, 138, 224, 0.15);
    padding: 2.25rem;
    position: relative;
    overflow: hidden;
}

.final-response-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, #10B981 100%);
}

.final-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.meal-title-group h3 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.meal-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.meal-category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #EFF6FF;
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
}

.health-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.85rem;
}

.health-status-badge.healthy {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.health-status-badge.neutral {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* Hero Nutrition Gauge Grid */
.nutrition-hero-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    margin-bottom: 2rem;
    align-items: center;
}

.calories-hero-box {
    text-align: center;
    padding-right: 1.5rem;
    border-right: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.calories-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.calories-number {
    font-size: 3.25rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    letter-spacing: -0.04em;
}

.calories-unit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.calories-bounds {
    font-size: 0.78rem;
    color: #94A3B8;
    margin-top: 0.5rem;
    background: #EDF2F7;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

/* Macros Bars */
.macros-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.macro-box {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.macro-box-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.macro-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.macro-amount {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.macro-bar-track {
    height: 8px;
    background: #E2E8F0;
    border-radius: var(--radius-full);
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.macro-bar-fill.protein {
    background: #3B82F6;
}

.macro-bar-fill.carb {
    background: #F97316;
}

.macro-bar-fill.fat {
    background: #EAB308;
}

.macro-bar-fill.fiber {
    background: #10B981;
}

.macro-pct {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Health Reasoning & Smart Tip */
.insights-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.insight-card {
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.55;
    border: 1px solid transparent;
}

.insight-card.health-reason {
    background: #F0FDF4;
    border-color: #BBF7D0;
    color: #166534;
}

.insight-card.smart-tip {
    background: #FFFBEB;
    border-color: #FDE68A;
    color: #92400E;
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.insight-header svg {
    width: 17px;
    height: 17px;
}

/* Final Actions Bar */
.final-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.final-actions-left {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-secondary-action {
    background: #FFFFFF;
    border: 1.5px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.4rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-secondary-action:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
    transform: translateY(-1px);
}

.btn-secondary-action svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.btn-download-app {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #FFFFFF;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 12px rgba(63, 138, 224, 0.3);
    transition: all 0.2s ease;
}

.btn-download-app:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(63, 138, 224, 0.4);
    filter: brightness(1.05);
}

.btn-download-app svg {
    width: 16px;
    height: 16px;
}

/* Responsive Rules for Demo Page */
@media (max-width: 820px) {
    .steps-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .nutrition-hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .calories-hero-box {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid #E2E8F0;
        padding-bottom: 1.25rem;
    }

    .macros-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .insights-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 580px) {
    .demo-header h1 {
        font-size: 2.1rem;
    }

    .demo-card {
        padding: 1.35rem;
    }

    .steps-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .macros-grid {
        grid-template-columns: 1fr;
    }

    .final-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .final-actions-left {
        flex-direction: column;
    }

    .btn-secondary-action,
    .btn-download-app {
        justify-content: center;
        width: 100%;
    }
}
