/* ========================================
   DIGITAILOR — Automation Demos Styles
   Dedicated animations for workflow demos
   ======================================== */

/* ── Demo Section ────────────────────────── */
.demo-section {
    padding: 5rem 0;
    position: relative;
}

.demo-section:nth-child(even) {
    background: var(--bg-secondary);
}

.demo-header {
    margin-bottom: 3rem;
}

.demo-header .demo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    background: rgba(79, 142, 255, 0.08);
    border: 1px solid rgba(79, 142, 255, 0.2);
    color: var(--accent-blue);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.demo-header h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 0.75rem;
}

.demo-header p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 700px;
}

/* ── Workflow Visualizer ─────────────────── */
.workflow-visualizer {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

/* Progress bar at top of each demo */
.workflow-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
    transition: width 0.6s var(--ease-out);
}

.workflow-visualizer.playing .workflow-progress {
    box-shadow: 0 0 12px rgba(79, 142, 255, 0.4);
}

/* ── Workflow Nodes ──────────────────────── */
.workflow-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2.5rem;
    position: relative;
    justify-content: center;
}

.workflow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    position: relative;
    z-index: 2;
    min-width: 100px;
    flex-shrink: 0;
}

.node-circle {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(14, 17, 28, 0.8);
    border: 2px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.5s var(--ease-out);
    position: relative;
}

.node-circle svg {
    width: 22px;
    height: 22px;
    transition: all 0.5s var(--ease-out);
}

.node-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    transition: color 0.5s var(--ease-out);
    max-width: 90px;
}

/* Node active state */
.workflow-node.active .node-circle {
    border-color: var(--accent-blue);
    background: rgba(79, 142, 255, 0.12);
    color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(79, 142, 255, 0.2), 0 0 40px rgba(79, 142, 255, 0.08);
    transform: scale(1.08);
}

.workflow-node.active .node-label {
    color: var(--accent-blue);
}

/* Node completed state */
.workflow-node.completed .node-circle {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.workflow-node.completed .node-label {
    color: #22c55e;
}

/* Checkmark overlay for completed nodes */
.workflow-node.completed .node-circle::after {
    content: '✓';
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: white;
    font-weight: 700;
}

/* ── Connectors ──────────────────────────── */
.workflow-connector {
    flex: 1;
    height: 2px;
    background: var(--border-subtle);
    position: relative;
    min-width: 40px;
    max-width: 100px;
    overflow: visible;
}

.connector-line {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.6s var(--ease-out);
    border-radius: 2px;
}

.workflow-connector.active .connector-line {
    width: 100%;
}

/* Flowing particle on active connector */
.workflow-connector.active::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 10px rgba(79, 142, 255, 0.6);
    animation: flowParticle 0.8s var(--ease-out) forwards;
}

@keyframes flowParticle {
    0% {
        left: 0;
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        left: calc(100% - 8px);
        opacity: 0;
    }
}

/* ── Data Panel ──────────────────────────── */
.data-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

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

.data-panel-header h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-heading);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.data-panel-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    background: rgba(79, 142, 255, 0.1);
    color: var(--accent-blue);
}

.data-panel-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

/* Step content panels (only visible when step is active) */
.step-content {
    display: none;
    animation: fadeSlideIn 0.5s var(--ease-out) forwards;
}

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

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Simulated Data Rows ─────────────────── */
.sim-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    opacity: 0;
    animation: rowAppear 0.4s var(--ease-out) forwards;
}

.sim-row:nth-child(1) {
    animation-delay: 0.1s;
}

.sim-row:nth-child(2) {
    animation-delay: 0.25s;
}

.sim-row:nth-child(3) {
    animation-delay: 0.4s;
}

.sim-row:nth-child(4) {
    animation-delay: 0.55s;
}

@keyframes rowAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sim-row .sim-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(79, 142, 255, 0.1);
    color: var(--accent-blue);
}

.sim-row .sim-text {
    flex: 1;
}

.sim-row .sim-text .sim-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.1rem;
}

.sim-row .sim-text .sim-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sim-row .sim-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.sim-badge.blue {
    background: rgba(79, 142, 255, 0.12);
    color: var(--accent-blue);
}

.sim-badge.green {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.sim-badge.violet {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-violet);
}

.sim-badge.amber {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

/* ── Typing Animation ────────────────────── */
.typing-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
    overflow: hidden;
}

.typing-text .cursor-blink {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent-blue);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* ── Processing Animation ────────────────── */
.processing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.processing-dots {
    display: flex;
    gap: 3px;
}

.processing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: dotBounce 1.2s ease-in-out infinite;
}

.processing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.processing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Gauge / Metric Boxes ────────────────── */
.sim-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.sim-metric {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    opacity: 0;
    animation: metricPop 0.5s var(--ease-out) forwards;
}

.sim-metric:nth-child(1) {
    animation-delay: 0.1s;
}

.sim-metric:nth-child(2) {
    animation-delay: 0.3s;
}

.sim-metric:nth-child(3) {
    animation-delay: 0.5s;
}

@keyframes metricPop {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sim-metric .metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-blue);
    margin-bottom: 0.2rem;
}

.sim-metric .metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Progress Fill Bar ───────────────────── */
.fill-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.fill-bar-inner {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 1s var(--ease-out);
}

/* ── Email-style Card ────────────────────── */
.sim-email {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
}

.sim-email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sim-email-from {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sim-email-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(79, 142, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.sim-email-from .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.sim-email-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.sim-email-subject {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.3rem;
}

.sim-email-body {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Replay Button ───────────────────────── */
.replay-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(79, 142, 255, 0.08);
    border: 1px solid rgba(79, 142, 255, 0.2);
    border-radius: var(--radius-pill);
    color: var(--accent-blue);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 1.5rem;
}

.replay-btn:hover {
    background: rgba(79, 142, 255, 0.15);
    border-color: rgba(79, 142, 255, 0.4);
}

.replay-btn svg {
    width: 14px;
    height: 14px;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 1024px) {
    .workflow-pipeline {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .workflow-connector {
        min-width: 20px;
    }

    .sim-metrics {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .workflow-pipeline {
        flex-direction: column;
        align-items: stretch;
    }

    .workflow-node {
        flex-direction: row;
        min-width: initial;
        gap: 1rem;
    }

    .node-label {
        text-align: left;
    }

    .workflow-connector {
        width: 2px;
        height: 24px;
        min-width: 2px;
        max-width: 2px;
        margin-left: 27px;
    }

    .workflow-connector.active::after {
        animation: flowParticleV 0.8s var(--ease-out) forwards;
        top: 0;
        left: -3px;
    }

    .sim-metrics {
        grid-template-columns: 1fr;
    }

    .demo-header h2 {
        font-size: 1.5rem;
    }
}

@keyframes flowParticleV {
    0% {
        top: 0;
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        top: calc(100% - 8px);
        opacity: 0;
    }
}

/* ── Floating Section Nav ───────────────── */
.floating-nav {
    position: fixed;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: rgba(10, 13, 22, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.floating-nav.visible {
    opacity: 1;
    visibility: visible;
}

/* Light mode */
[data-theme="light"] .floating-nav {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.fnav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.5rem;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
}

.fnav-item:hover {
    background: rgba(79, 142, 255, 0.08);
}

.fnav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.35;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.fnav-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    letter-spacing: 0.02em;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.3s ease, opacity 0.25s ease, color 0.25s ease;
}

/* Show labels on hover of the entire nav */
.floating-nav:hover .fnav-label {
    max-width: 100px;
    opacity: 1;
}

/* Active state */
.fnav-item.active .fnav-dot {
    background: var(--accent-blue);
    opacity: 1;
    box-shadow: 0 0 8px rgba(79, 142, 255, 0.5);
    width: 10px;
    height: 10px;
}

.fnav-item.active .fnav-label {
    color: var(--accent-blue);
}

/* Always show active label */
.fnav-item.active .fnav-label {
    max-width: 100px;
    opacity: 1;
}

/* Hide on smaller screens */
@media (max-width: 1200px) {
    .floating-nav {
        display: none;
    }
}