/* ========================================
   DIAGNOSTIC FLOW SECTION
   ======================================== */
#diagnostic-flow {
    background: var(--dark);
    color: var(--white);
    padding: var(--spacing-3xl) 0;
    overflow: hidden;
    position: relative;
    /* Removed custom font; inheriting from body */
}

/* Background Grid Overlay */
#diagnostic-flow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 0;
    pointer-events: none;
}

.diagnostic-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-2xl);
    align-items: center;
    position: relative;
    z-index: 10;
}

/* Left Content */
.diagnostic-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.diagnostic-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    line-height: 1;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: -0.05em;
    color: var(--white);
    margin-bottom: var(--spacing-sm);
}

.diagnostic-text-highlight {
    display: block;
    transition: color 0.3s ease;
}

.diagnostic-text-highlight.status-normal {
    color: var(--secondary-light);
    /* Blue */
}

.diagnostic-text-highlight.status-success {
    color: var(--primary-light);
    /* Green */
}

.diagnostic-text-highlight.status-error {
    color: #ef4444;
    /* Tailwind Red-500 equivalent */
}

.diagnostic-desc {
    font-size: 1.125rem;
    color: var(--gray-400);
    max-width: 28rem;
    line-height: 1.6;
}

/* Terminal Box */
.terminal-box {
    border: 1px solid var(--gray-700);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.4);
    font-family: 'Courier New', monospace;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.5s ease;
    width: 100%;
    margin-top: var(--spacing-md);
}

.terminal-box.status-error {
    background: rgba(69, 10, 10, 0.4);
    /* Red tint */
    border-color: rgba(127, 29, 29, 0.5);
}

.terminal-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
    color: var(--secondary-light);
    /* Blue-ish */
    opacity: 0.7;
}

.terminal-header.status-error {
    color: #f87171;
    /* Red-400 */
}

.terminal-log {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--secondary-light);
    /* Blue-400 */
    white-space: pre-line;
    overflow: visible;
    line-height: 1.5;
}

.terminal-log.status-error {
    color: #ef4444;
    /* Red-500 */
}

/* Controls */
.diagnostic-controls {
    margin-top: var(--spacing-md);
}

.btn-diagnostic {
    padding: 1rem 2.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    color: var(--white);
}

.btn-diagnostic:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

.btn-run {
    background: var(--secondary);
    /* Blue */
}

.btn-run:hover {
    background: var(--secondary-light);
}

.btn-repair {
    background: #dc2626;
    /* Red-600 */
    animation: pulseBtn 2s infinite;
}

.btn-repair:hover {
    background: #ef4444;
    /* Red-500 */
}

.btn-view {
    background: var(--primary);
    /* Green */
    width: 100%;
}

.btn-view:hover {
    background: var(--primary-light);
}

@keyframes pulseBtn {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* Right Visual */
.diagnostic-visual {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 500px;
}

/* Mechanic Icon (Desktop only) */
.mechanic-figure {
    position: absolute;
    right: -30px;
    bottom: 30px;
    z-index: 20;
    width: 180px;
    height: 180px;
    /* Square for the new icon */
    filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.2));
    display: none;
    transition: transform 0.5s ease, opacity 0.5s ease;
    opacity: 0;
    transform: translateX(50px);
}

.mechanic-figure svg {
    overflow: visible;
}

@media (min-width: 1024px) {
    .mechanic-figure {
        display: block;
    }

    .mechanic-figure.show {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animations for SVG parts */
.animate-pulse {
    animation: pulseEye 2s infinite;
}

@keyframes pulseEye {

    0%,
    100% {
        fill-opacity: 1;
        filter: drop-shadow(0 0 5px #60a5fa);
    }

    50% {
        fill-opacity: 0.5;
        filter: drop-shadow(0 0 1px #60a5fa);
    }
}

/* Blueprint Phone Frame */
.blueprint-frame {
    position: relative;
    width: 300px;
    height: 480px;
    border-radius: 2.5rem;
    border: 1px solid var(--gray-700);
    background: rgba(15, 23, 42, 0.4);
    /* Slate-900/40 equivalent */
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.7s ease;
}

.blueprint-frame.status-error {
    background: rgba(69, 10, 10, 0.2);
    border-color: rgba(127, 29, 29, 0.5);
}

/* Background Grid inside Phone */
.blueprint-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--secondary) 1px, transparent 1px),
        linear-gradient(90deg, var(--secondary) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
    z-index: 1;
}

/* Scanning Laser Line */
.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--secondary-light);
    box-shadow: 0 0 15px var(--secondary-light);
    z-index: 5;
    top: 0%;
    display: none;
    /* JS will toggle */
}

.scan-line.scanning {
    display: block;
    animation: scanAnimation 2s linear infinite;
}

.scan-line.repairing {
    background: var(--primary-light);
    /* Green */
    box-shadow: 0 0 15px var(--primary-light);
    display: block;
    animation: scanAnimation 2s linear infinite;
}

@keyframes scanAnimation {
    0% {
        top: 0%;
    }

    50% {
        top: 100%;
    }

    100% {
        top: 0%;
    }
}

/* Car Chassis UI */
/* Car Chassis UI */
.chassis-ui {
    position: relative;
    width: 200px;
    height: 360px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 360" fill="none" stroke="%23374151" stroke-width="2"><path d="M40 60 C40 30 160 30 160 60 L180 100 L180 280 L160 320 L130 320 L130 340 L70 340 L70 320 L40 320 L20 280 L20 100 Z" /><circle cx="40" cy="80" r="10" /><circle cx="160" cy="80" r="10" /><circle cx="40" cy="280" r="10" /><circle cx="160" cy="280" r="10" /><path d="M50 120 L150 120" stroke-opacity="0.3" /><path d="M50 240 L150 240" stroke-opacity="0.3" /></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: none;
    /* Removed simpler border */
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center content vertically */
    transition: filter 0.5s ease;
}

.chassis-ui.status-error {
    filter: drop-shadow(0 0 5px #ef4444);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 360" fill="none" stroke="%23ef4444" stroke-width="2"><path d="M40 60 C40 30 160 30 160 60 L180 100 L180 280 L160 320 L130 320 L130 340 L70 340 L70 320 L40 320 L20 280 L20 100 Z" /><circle cx="40" cy="80" r="10" /><circle cx="160" cy="80" r="10" /><circle cx="40" cy="280" r="10" /><circle cx="160" cy="280" r="10" /><path d="M50 120 L150 120" stroke-opacity="0.3" /><path d="M50 240 L150 240" stroke-opacity="0.3" /></svg>');
}

.chassis-ui.status-error {
    border-color: #ef4444;
}

/* Icon Box inside Chassis */
.icon-box {
    margin-top: 2.5rem;
    width: 6rem;
    height: 6rem;
    border: 1px solid var(--gray-700);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-light);
    transition: all 0.5s ease;
}

.icon-box svg {
    width: 4rem;
    height: 4rem;
    transition: all 0.5s ease;
}

.icon-box.status-error {
    color: #ef4444;
}

.icon-box.status-error svg {
    transform: scale(1.1);
}

.icon-box.status-success {
    color: var(--primary-light);
    /* Green */
}

/* Progress HUD at bottom of phone */
.progress-hud {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    padding: 0 2rem;
    width: 100%;
}

.progress-track {
    height: 4px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    width: 100%;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--secondary-light);
    box-shadow: 0 0 8px currentColor;
    transition: width 0.1s linear, background-color 0.3s ease;
}

.progress-bar.repairing {
    background: var(--primary-light);
}

.hud-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    font-family: monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.05em;
}

#diag-status-text {
    color: var(--secondary-light);
}

#diag-status-text.status-error {
    color: #ef4444;
}

#diag-status-text.status-success {
    color: var(--primary-light);
}

.hud-percent {
    color: var(--gray-500);
}

/* Error Overlay */
.error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(220, 38, 38, 0.15);
    backdrop-filter: blur(2px);
    display: none;
    /* Flex when active */
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.error-overlay.active {
    display: flex;
    opacity: 1;
}

.error-badge {
    background: #dc2626;
    color: var(--white);
    padding: 0.25rem 1rem;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    transform: rotate(-12deg);
}

/* Success Overlay */
.success-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    /* Slate-950/85 */
    backdrop-filter: blur(6px);
    display: none;
    /* Flex when active */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.success-overlay.active {
    display: flex;
    opacity: 1;
}

.success-icon-circle {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--primary);
    /* Green base */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: 0 10px 25px rgba(35, 65, 10, 0.3);
}

.success-title {
    font-weight: 900;
    color: var(--white);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.success-subtitle {
    font-size: 0.65rem;
    color: var(--secondary-light);
    font-family: monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.success-desc {
    font-size: 0.7rem;
    color: var(--gray-400);
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 1023px) {
    .diagnostic-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }

    .diagnostic-visual {
        height: 400px;
    }

    .diagnostic-content {
        text-align: center;
        align-items: center;
    }

    .terminal-box {
        text-align: left;
        align-self: stretch;
    }
}