/**
 * ============================================================================
 * FLOW ENGINE PREVIEW SCREEN - PROFESSIONAL DESIGN
 * ============================================================================
 */

.flow-preview-screen {
    background: linear-gradient(
        135deg,
        rgba(15, 23, 42, 0.95),
        rgba(30, 41, 59, 0.9)
    );
    border: 2px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    height: 100%;
    min-height: 500px;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
}

.preview-header {
    background: rgba(15, 23, 42, 0.8);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h4 {
    margin: 0;
    color: var(--primary-text, #f8fafc);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

.preview-controls button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

/* Preview Output - Perfect Screen Dimensions */
.preview-output {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 400px;
    height: 100%;
}

.preview-output--with-background {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(0, 0, 0, 0.85);
    background-blend-mode: multiply;
}

.preview-placeholder {
    color: rgba(148, 163, 184, 0.6);
    text-align: center;
    padding: 3rem 1.5rem;
    font-size: 0.9rem;
}

/* Output Item - Perfect Media Fitting */
.output-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    animation: fadeInMedia 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInMedia {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Text Output - Centered & Readable */
.output-text {
    font-size: 1.15rem;
    color: #ffffff;
    line-height: 1.6;
    text-align: center;
    width: 100%;
    max-width: 100%;
    padding: 1.5rem 2rem;
    box-sizing: border-box;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Audio Output - Clean Player */
.output-audio {
    color: rgba(203, 213, 225, 0.9);
    text-align: center;
    width: 100%;
    max-width: 600px;
    padding: 2rem;
}

.output-audio audio {
    width: 100%;
    margin-top: 1rem;
    border-radius: 8px;
}

/* Image Output - Perfect Fit */
.output-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
}

.output-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    display: block;
}

/* Video Output - Perfect Fit */
.output-video {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
}

.output-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
    display: block;
}

/* Message Variants */
.output-message {
    color: rgba(203, 213, 225, 0.9);
    font-size: 0.9rem;
    padding: 1.5rem;
    text-align: center;
}

.output-variable .output-message {
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    color: rgba(129, 140, 248, 0.95);
    font-size: 0.95rem;
}

/* Preview Console - Modern & Clean */
.preview-console {
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    padding: 0.75rem 1rem;
    max-height: 140px;
    overflow-y: auto;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.75rem;
}

.preview-console h5 {
    margin: 0 0 0.5rem 0;
    color: rgba(148, 163, 184, 0.7);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.console-messages {
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.console-message {
    padding: 0.2rem 0.5rem;
    border-left: 2px solid transparent;
    word-break: break-word;
    border-radius: 2px;
}

.console-message.console-info {
    color: rgba(129, 140, 248, 0.9);
    border-left-color: rgba(129, 140, 248, 0.5);
    background: rgba(129, 140, 248, 0.05);
}

.console-message.console-error {
    color: rgba(248, 113, 113, 0.95);
    border-left-color: rgba(248, 113, 113, 0.7);
    background: rgba(248, 113, 113, 0.08);
}

.console-message.console-warning {
    color: rgba(251, 191, 36, 0.95);
    border-left-color: rgba(251, 191, 36, 0.7);
    background: rgba(251, 191, 36, 0.08);
}

.console-message.console-success {
    color: rgba(74, 222, 128, 0.95);
    border-left-color: rgba(74, 222, 128, 0.7);
    background: rgba(74, 222, 128, 0.08);
}

/* Custom Scrollbars - Sleek Design */
.preview-output::-webkit-scrollbar,
.preview-console::-webkit-scrollbar,
.console-messages::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.preview-output::-webkit-scrollbar-track,
.preview-console::-webkit-scrollbar-track,
.console-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.preview-output::-webkit-scrollbar-thumb,
.preview-console::-webkit-scrollbar-thumb,
.console-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
    transition: background 0.2s ease;
}

.preview-output::-webkit-scrollbar-thumb:hover,
.preview-console::-webkit-scrollbar-thumb:hover,
.console-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Button States */
.preview-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

/* Responsive Preview Screen */
@media (max-width: 1024px) {
    .flow-preview-screen {
        max-width: 100%;
        height: 500px;
    }
}

@media (max-width: 768px) {
    .flow-preview-screen {
        height: 450px;
        border-radius: 12px;
    }

    .preview-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
        padding: 0.75rem 1rem;
    }

    .preview-controls {
        width: 100%;
        justify-content: space-between;
    }

    .preview-controls button {
        flex: 1;
        min-width: 0;
    }

    .output-text {
        font-size: 1rem;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .flow-preview-screen {
        height: 400px;
    }

    .preview-console {
        max-height: 100px;
        font-size: 0.7rem;
    }
}

/* ============================================================================
 * SUBTITLE OVERLAY - Text as Subtitles
 * ============================================================================ */

.subtitle-overlay {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 0 1rem 0 !important; /* keep a small bottom gutter */
    background: transparent !important;
    pointer-events: none;
    z-index: 100;
}

.subtitle-overlay .output-text {
    background: rgba(0, 0, 0, 0.85) !important;
    color: #ffffff !important;
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
    padding: 0.75rem 1.5rem !important;
    margin: 0 !important;
    width: auto !important;
    max-width: 90% !important;
    text-align: center !important;
    border: none !important;
    border-radius: 8px !important; /* subtle rounded pill */
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.45);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: subtitleFadeIn 0.3s ease-out;
    display: inline-block !important; /* shrink to content */
    box-sizing: border-box;
}

@keyframes subtitleFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive subtitle text */
@media (max-width: 768px) {
    .subtitle-overlay .output-text {
        font-size: 1.1rem !important;
        padding: 0.875rem 1.5rem !important;
    }
}

@media (max-width: 480px) {
    .subtitle-overlay .output-text {
        font-size: 1rem !important;
        padding: 0.75rem 1rem !important;
    }
}
