/* Shared Demo System CSS */
.demo-section {
    position: relative;
    padding: clamp(40px, 6vw, 60px) 0;
    overflow: hidden;
}
.demo-container {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 24px);
    font-family: 'Inter', 'Roboto', sans-serif;
    color: #333;
    box-sizing: border-box;
}
.ui-frame {
    background: #fff;
    border-radius: clamp(8px, 2vw, 16px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    text-align: left;
    width: 100%;
    min-height: 400px; /* Fluid height instead of fixed 600px */
}
.ui-header {
    background: #f1f3f4;
    border-bottom: 1px solid #e0e0e0;
    padding: clamp(8px, 2vw, 12px) clamp(16px, 3vw, 20px);
    display: flex;
    align-items: center;
    gap: 12px;
}
.ui-header-dots {
    display: flex;
    gap: 6px;
}
.ui-header-dot {
    width: clamp(10px, 1.5vw, 12px);
    height: clamp(10px, 1.5vw, 12px);
    border-radius: 50%;
    background: #ccc;
}
.ui-header-dot:nth-child(1) { background: #ff5f56; }
.ui-header-dot:nth-child(2) { background: #ffbd2e; }
.ui-header-dot:nth-child(3) { background: #27c93f; }

.ui-body {
    display: flex;
    flex: 1;
    flex-direction: row;
    overflow: hidden;
}

@media (max-width: 768px) {
    .ui-body {
        flex-direction: column;
    }
}

.ui-content {
    flex: 1;
    padding: clamp(20px, 4vw, 30px);
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

/* Chat & Emails */
.email-content {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.email-thread-viewport {
    height: 400px;
    overflow-y: auto;
    padding-right: 16px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}
.email-thread-viewport::-webkit-scrollbar {
    width: 6px;
}
.email-thread-viewport::-webkit-scrollbar-track {
    background: transparent; 
    border-radius: 4px;
}
.email-thread-viewport::-webkit-scrollbar-thumb {
    background: #ddd; 
    border-radius: 4px;
}

.email-thread {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 20px);
    padding-bottom: 24px;
}
.message-bubble {
    padding: clamp(12px, 3vw, 16px);
    border-radius: clamp(8px, 2vw, 12px);
    max-width: 85%;
    line-height: 1.5;
    font-size: clamp(14px, 2.5vw, 15px);
    opacity: 0;
    transform: translateY(15px);
    display: none; 
}

@keyframes messageReveal {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

.message-bubble.show {
    display: flex;
    flex-direction: column;
    animation: messageReveal 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@media (prefers-reduced-motion: reduce) {
    .message-bubble {
        transition: none;
    }
}

.message-broker {
    background: #f1f3f4;
    align-self: flex-start;
}
.message-dispatcher {
    background: #e8f0fe;
    align-self: flex-end;
}
.message-ai {
    background: #fdf5ff;
    border-left: 4px solid #ab47bc;
    align-self: flex-end;
}
.message-meta {
    font-size: clamp(11px, 2vw, 12px);
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
}

.typed-text-rejected {
    position: relative;
    display: inline-block;
}
.rejection-sweep {
    position: absolute;
    top: -2px;
    left: -4px;
    height: calc(100% + 4px);
    width: 0;
    background: rgba(255, 60, 60, 0.4);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}
@media (prefers-reduced-motion: reduce) {
    .rejection-sweep {
        transition: none;
    }
}
.rejection-sweep.sweep-active {
    width: calc(100% + 8px);
}
.rejection-sweep.sweep-done {
    display: none;
}
.ai-typed-content p {
    margin-bottom: 8px;
}
.ai-typed-content p:last-child {
    margin-bottom: 0;
}

.success-banner {
    background: #e6f4ea;
    color: #137333;
    font-size: clamp(24px, 5vw, 32px);
    font-weight: 700;
    text-align: center;
    padding: clamp(16px, 4vw, 24px);
    border-radius: clamp(8px, 2vw, 16px);
    margin-top: clamp(24px, 5vw, 40px);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #cce8d6;
    display: none;
    box-shadow: 0 8px 24px rgba(19, 115, 51, 0.15);
}
.success-banner.show {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}
@media (prefers-reduced-motion: reduce) {
    .success-banner {
        transition: none;
    }
}

/* Broker Hub */
.broker-list {
    flex: 1;
    border-right: 1px solid #e0e0e0;
}
@media (max-width: 768px) {
    .broker-list {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
}
.broker-row {
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: clamp(12px, 3vw, 16px);
    border-radius: 6px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
@media (prefers-reduced-motion: reduce) {
    .broker-row {
        transition: none;
    }
}
.broker-row:active {
    background: #f8fbff;
    border-color: #3186FF;
}

.broker-row.active {
    background: #f8fbff;
    border-color: #3186FF;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(49, 134, 255, 0.1);
}

@media (hover: hover) and (pointer: fine) {
    .broker-row:hover {
        background: #f8fbff;
        border-color: #3186FF;
        transform: translateX(4px);
        box-shadow: 0 4px 12px rgba(49, 134, 255, 0.1);
    }
}

@media (max-width: 768px) {
    .broker-row.active {
        transform: none; /* No shifting on mobile */
    }
    .broker-row:active {
        transform: scale(0.98); /* Touch feedback */
    }
}

.broker-details {
    width: 100%;
    max-width: 360px;
    background: #fafafa;
    padding: clamp(20px, 4vw, 30px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
@media (max-width: 768px) {
    .broker-details {
        max-width: none;
    }
}

.broker-detail-card {
    display: none;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.broker-detail-card.active {
    display: flex;
    opacity: 1;
}

.intel-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    background: #fff;
}
.intel-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}
.intel-card p {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
    margin: 0;
}

/* Tags & Badges */
.tag-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.tag {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #eee;
    color: #555;
    font-weight: 600;
}
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 13px;
}
.tag-safe { background: #e6f4ea; color: #137333; }
.tag-caution { background: #fef7e0; color: #b08d00; }
.tag-avoid { background: #fce8e6; color: #c5221f; }

/* Factoring Carousel / MC Check */
.carousel-viewport {
    width: 100%;
    overflow: hidden;
    padding: 40px 0;
    position: relative;
    box-sizing: border-box;
}
.carousel-track {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 2vw, 24px);
    width: 100%;
}
.carousel-card {
    flex: 0 0 clamp(280px, 32%, 360px);
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0.6;
    transform: scale(0.9);
    cursor: pointer;
    position: relative;
    z-index: 1;
}
.carousel-card.active {
    opacity: 1;
    transform: scale(1);
    z-index: 2;
    box-shadow: 0 24px 48px rgba(0,0,0,0.12);
}
@media (max-width: 768px) {
    .carousel-track {
        flex-direction: column;
    }
    .carousel-card {
        flex: 0 0 auto;
        width: 100%;
        max-width: 400px;
        transform: scale(0.95);
    }
    .carousel-card.active {
        transform: scale(1);
    }
}

.inline-check-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Highlighting */
.highlight-text {
    position: relative;
    display: inline-block;
}
.highlight-overlay {
    position: absolute;
    inset: -2px -4px;
    background: rgba(255, 213, 0, 0.3);
    border-radius: 4px;
    opacity: 0;
}

/* MC Check Animations */
.inline-check-container .highlight-overlay { opacity: 0; }
.inline-check-container .checking-spinner { display: none; }
.inline-check-container .badge-result { display: none; opacity: 0; }

/* Default / Email Style & Broker Details */
.mc-card.playing-animation .type-email .highlight-overlay,
.broker-detail-card.playing-animation .highlight-overlay { animation: fadeIn 0.2s forwards 0.25s; }

.mc-card.playing-animation .type-email .checking-spinner,
.broker-detail-card.playing-animation .checking-spinner { display: block; animation: fadeIn 0.1s forwards 0.5s, fadeOut 0.1s forwards 1.5s; }

.mc-card.playing-animation .type-email .badge-result,
.broker-detail-card.playing-animation .badge-result { display: inline-flex; animation: popIn 0.2s forwards 1.6s; }

/* Load Board Style */
.mc-card.playing-animation .type-loadboard .highlight-overlay { animation: fadeIn 0.2s forwards 0.2s; }
.mc-card.playing-animation .type-loadboard .checking-spinner { display: block; animation: fadeIn 0.1s forwards 0.4s, fadeOut 0.1s forwards 1.4s; }
.mc-card.playing-animation .type-loadboard .badge-result { display: inline-flex; animation: popIn 0.2s forwards 1.5s; }

/* Utilities */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeOut {
    to { opacity: 0; display: none; }
}
@keyframes popIn {
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
    .mobile-stack-grid {
        grid-template-columns: 1fr !important;
    }
}
