/* ===== Demo Popup - Mobile-First ===== */

/* Trigger bar - slides up from bottom */
.demo-trigger {
    position: fixed;
    bottom: -120px;
    left: 0;
    right: 0;
    z-index: 1999;
    background: #0f172a;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.25);
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 2px solid #22c55e;
}

.demo-trigger.visible {
    bottom: 0;
}

.demo-trigger-text {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.demo-trigger-text strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

.demo-trigger-text span {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
    margin-top: 1px;
}

.demo-trigger-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    animation: demoTriggerPulse 2s ease-in-out infinite;
}

.demo-trigger-btn:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

@keyframes demoTriggerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.demo-trigger-close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

/* Overlay */
.demo-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.demo-overlay.active {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

/* Popup container - full screen on mobile, bottom sheet on desktop */
.demo-popup {
    background: #fff;
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: demoSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding-top: env(safe-area-inset-top);
}

@keyframes demoSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Close button */
.demo-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    z-index: 2;
}

.demo-close:hover {
    color: #475569;
}

/* Progress dots */
.demo-progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px 0 8px;
}

.demo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: all 0.3s ease;
}

.demo-dot.active {
    background: #2563eb;
    width: 24px;
    border-radius: 4px;
}

.demo-dot.done {
    background: #2563eb;
}

/* Step container */
.demo-step {
    display: none;
    padding: 16px 24px 32px;
}

.demo-step.active {
    display: block;
}

.demo-step h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px;
    text-align: center;
}

.demo-step p.demo-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    text-align: center;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Step 1: Form */
.demo-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.demo-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.demo-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.demo-field input {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    color: #0f172a;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.demo-field input:focus {
    outline: none;
    border-color: #2563eb;
}

.demo-submit {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
}

.demo-submit:hover {
    background: #1d4ed8;
}

.demo-submit:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* Step 2: Type selection cards */
.demo-types {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.demo-type-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 14px;
}

.demo-type-card:hover {
    border-color: #2563eb;
    background: #f8fafc;
}

.demo-type-card:active {
    transform: scale(0.98);
}

.demo-type-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563eb;
}

.demo-type-icon svg {
    width: 22px;
    height: 22px;
}

.demo-type-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 2px;
}

.demo-type-info p {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

/* Step 3: Examples + input */
.demo-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.demo-examples-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.demo-example {
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.4;
}

.demo-example:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.demo-input-area {
    margin-bottom: 12px;
}

.demo-input-area textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #0f172a;
    resize: vertical;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.demo-input-area textarea:focus {
    outline: none;
    border-color: #2563eb;
}


/* Input bottom bar: char count + mic button */
.demo-input-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.demo-char-count {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Mic button — pulsing green idle, red when recording */
.demo-mic-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #22c55e;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s, transform 0.15s;
    animation: demoMicPulse 2s ease-in-out infinite;
}

.demo-mic-btn svg {
    width: 20px;
    height: 20px;
}

.demo-mic-btn:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.demo-mic-btn:active {
    transform: scale(0.95);
}

/* Pulsing green glow to draw attention */
@keyframes demoMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}

/* Recording state — red with pulsing red glow */
.demo-mic-btn.recording {
    background: #ef4444;
    animation: demoMicRecording 1s ease-in-out infinite;
}

.demo-mic-btn.recording:hover {
    background: #dc2626;
}

@keyframes demoMicRecording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

/* Transcribing state — grey, disabled look */
.demo-mic-btn.transcribing {
    background: #94a3b8;
    animation: none;
    cursor: wait;
}

/* Recording status bar */
.demo-mic-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #dc2626;
    margin-top: 8px;
}

.demo-mic-recording-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    animation: demoRecDot 1s ease-in-out infinite;
}

@keyframes demoRecDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Transcribing dot — blue spinner-style */
.demo-mic-transcribing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2563eb;
    flex-shrink: 0;
    animation: demoRecDot 0.6s ease-in-out infinite;
}

/* Step 4: Loading */
.demo-loading {
    text-align: center;
    padding: 40px 20px;
}

.demo-loading-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: #eff6ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: demoPulse 2s ease-in-out infinite;
}

.demo-loading-icon svg {
    width: 32px;
    height: 32px;
    color: #2563eb;
}

@keyframes demoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

.demo-loading h2 {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.demo-loading-bar {
    width: 100%;
    max-width: 280px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin: 16px auto 0;
    overflow: hidden;
}

.demo-loading-bar-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 3px;
    width: 0%;
    animation: demoProgress 25s ease-out forwards;
}

@keyframes demoProgress {
    0% { width: 0%; }
    20% { width: 30%; }
    50% { width: 55%; }
    80% { width: 75%; }
    100% { width: 90%; }
}

.demo-loading-tip {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 16px;
}

/* Step 5: Result */
.demo-result-preview {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
}

.demo-result-preview iframe {
    width: 100%;
    min-height: 350px;
    border: none;
    display: block;
}

/* Scroll hint overlay — fades out bottom to signal more content */
.demo-scroll-hint {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(transparent, rgba(255,255,255,0.95));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 2;
}
.demo-scroll-hint span {
    font-size: 12px;
    color: #64748b;
    animation: demoScrollBounce 1.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes demoScrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.demo-result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.demo-btn-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: #0f172a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.demo-btn-pdf:hover {
    background: #1e293b;
}

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

.demo-cta-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.demo-cta-main:hover {
    background: #1d4ed8;
    color: #fff;
}

.demo-cta-main svg {
    width: 20px;
    height: 20px;
}

/* Revision box */
.demo-revise-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.demo-revise-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 10px;
}

.demo-revise-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.demo-revise-textarea-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.demo-revise-textarea-row textarea {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #0f172a;
    resize: none;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.demo-revise-textarea-row textarea:focus {
    outline: none;
    border-color: #2563eb;
}

/* Revise mic button */
.demo-revise-mic {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    background: #22c55e;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    animation: demoMicPulse 2s ease-in-out infinite;
}

.demo-revise-mic svg {
    width: 20px;
    height: 20px;
}

.demo-revise-mic:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.demo-revise-mic.recording {
    background: #ef4444;
    animation: demoMicRecording 1s ease-in-out infinite;
}

.demo-revise-mic.transcribing {
    background: #94a3b8;
    animation: none;
    cursor: wait;
}

.demo-revise-mic-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 0.78rem;
    color: #dc2626;
}

.demo-revise-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

.demo-revise-btn:hover {
    background: #1d4ed8;
}

.demo-revise-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.demo-revise-note {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 8px;
}

/* Revision used message */
.demo-revise-used {
    display: none;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: #166534;
    line-height: 1.4;
}

.demo-revise-used svg {
    flex-shrink: 0;
    color: #22c55e;
}

.demo-upgrade-note {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.demo-upgrade-note p {
    font-size: 0.8rem;
    color: #166534;
    margin: 0;
    line-height: 1.5;
}

.demo-upgrade-note p strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.demo-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #dc2626;
    text-align: center;
    display: none;
}

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

/* Desktop */
@media (min-width: 640px) {
    .demo-overlay.active {
        align-items: center;
    }

    .demo-popup {
        max-width: 480px;
        border-radius: 20px;
        max-height: 85vh;
        min-height: auto;
        padding-top: 0;
        animation-name: demoFadeIn;
    }

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

    .demo-trigger {
        left: auto;
        right: 24px;
        bottom: -120px;
        border-radius: 14px 14px 0 0;
        max-width: 460px;
        border-top: 2px solid #22c55e;
        border-left: 2px solid rgba(34,197,94,0.2);
        border-right: 2px solid rgba(34,197,94,0.2);
    }

    .demo-trigger.visible {
        bottom: 0;
    }

    .demo-types {
        flex-direction: row;
        gap: 10px;
    }

    .demo-type-card {
        flex-direction: column;
        text-align: center;
        flex: 1;
        padding: 16px 12px;
    }
}
