/* =========================================================
   Demo Modal System — Overlay + Popup Windows
   ========================================================= */

/* Overlay */
.demo-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.demo-overlay--open {
    opacity: 1;
    pointer-events: all;
}

/* Modal */
.demo-modal {
    background: #0d1328;
    border: 1px solid rgba(0, 163, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 0 60px rgba(0, 163, 255, 0.15), 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.demo-modal--open {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Size variants */
.demo-modal--sm { width: min(420px, 92vw); }
.demo-modal--md { width: min(600px, 92vw); }
.demo-modal--lg { width: min(800px, 92vw); }
.demo-modal--xl { width: min(1000px, 95vw); }

/* Header */
.demo-modal__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 163, 255, 0.1);
    background: rgba(0, 163, 255, 0.03);
}

.demo-modal__icon {
    font-size: 1.3rem;
    color: #00e5ff;
}

.demo-modal__title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
    letter-spacing: 0.5px;
}

.demo-modal__close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.6rem;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
    line-height: 1;
}

.demo-modal__close:hover {
    color: #fff;
}

/* Body */
.demo-modal__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* =========================================================
   Shared Demo Components
   ========================================================= */

/* Phone Frame */
.demo-phone {
    width: 280px;
    margin: 0 auto;
    border: 2px solid rgba(0, 163, 255, 0.3);
    border-radius: 28px;
    padding: 12px 8px;
    background: #0a0e1a;
    box-shadow: 0 0 30px rgba(0, 163, 255, 0.1);
    position: relative;
}

.demo-phone__notch {
    width: 100px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin: 0 auto 8px;
}

.demo-phone__screen {
    border-radius: 16px;
    overflow: hidden;
    background: #111827;
    min-height: 400px;
}

/* Chat UI */
.demo-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.demo-chat__header {
    padding: 10px 14px;
    background: rgba(0, 163, 255, 0.08);
    border-bottom: 1px solid rgba(0, 163, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.demo-chat__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00a3ff, #00e5ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #fff;
    font-weight: 700;
}

.demo-chat__name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
}

.demo-chat__status {
    font-size: 0.7rem;
    color: rgba(0, 229, 255, 0.7);
}

.demo-chat__messages {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 350px;
}

.demo-chat__msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    animation: msgAppear 0.3s ease;
}

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

.demo-chat__msg--user {
    align-self: flex-end;
    background: #00a3ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.demo-chat__msg--bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

.demo-chat__typing {
    align-self: flex-start;
    padding: 8px 16px;
    display: flex;
    gap: 4px;
}

.demo-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 229, 255, 0.6);
    animation: typeDot 1.2s ease-in-out infinite;
}

.demo-chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.demo-chat__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typeDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.demo-chat__quick-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.demo-chat__quick-btn {
    padding: 5px 12px;
    border: 1px solid rgba(0, 163, 255, 0.3);
    border-radius: 100px;
    background: rgba(0, 163, 255, 0.05);
    color: #00e5ff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.demo-chat__quick-btn:hover {
    background: rgba(0, 163, 255, 0.15);
    border-color: #00e5ff;
}

/* Dashboard Components */
.demo-dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.demo-metric {
    background: rgba(0, 163, 255, 0.05);
    border: 1px solid rgba(0, 163, 255, 0.1);
    border-radius: 10px;
    padding: 14px;
}

.demo-metric__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

.demo-metric__value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.demo-metric__value--green { color: #00c853; }
.demo-metric__value--cyan { color: #00e5ff; }

/* Chart (canvas placeholder) */
.demo-chart-wrap {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 163, 255, 0.08);
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
}

.demo-chart-wrap canvas {
    width: 100%;
    height: 160px;
    display: block;
}

/* Pipeline Nodes */
.demo-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 16px 0;
}

.demo-pipeline__node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 90px;
    text-align: center;
}

.demo-pipeline__circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(0, 163, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: rgba(0, 229, 255, 0.5);
    transition: all 0.5s ease;
    background: rgba(0, 163, 255, 0.03);
}

.demo-pipeline__circle--active {
    border-color: #00e5ff;
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.demo-pipeline__circle--done {
    border-color: #00c853;
    color: #00c853;
    background: rgba(0, 200, 83, 0.1);
}

.demo-pipeline__label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'JetBrains Mono', monospace;
}

.demo-pipeline__arrow {
    color: rgba(0, 163, 255, 0.3);
    font-size: 1.2rem;
    margin: 0 -4px;
    flex-shrink: 0;
}

.demo-pipeline__arrow--active {
    color: #00e5ff;
}

/* Agent Network */
.demo-agents {
    position: relative;
    height: 280px;
}

.demo-agent-node {
    position: absolute;
    width: 80px;
    text-align: center;
}

.demo-agent-node__circle {
    width: 52px;
    height: 52px;
    margin: 0 auto 6px;
    border-radius: 50%;
    border: 2px solid rgba(0, 163, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 163, 255, 0.03);
    transition: all 0.5s ease;
}

.demo-agent-node__circle--active {
    border-color: #00e5ff;
    color: #fff;
    background: rgba(0, 229, 255, 0.15);
    box-shadow: 0 0 24px rgba(0, 229, 255, 0.35);
}

.demo-agent-node__name {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
}

/* Log Window */
.demo-log {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 163, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    max-height: 180px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.8;
    margin-top: 12px;
}

.demo-log__entry {
    animation: msgAppear 0.3s ease;
}

.demo-log__time {
    color: rgba(0, 163, 255, 0.5);
}

.demo-log__text {
    color: rgba(255, 255, 255, 0.6);
}

.demo-log__text--highlight {
    color: #00e5ff;
}

.demo-log__text--success {
    color: #00c853;
}

/* Trade Entry */
.demo-trade {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    animation: msgAppear 0.3s ease;
}

.demo-trade__pair { color: #fff; font-weight: 600; }
.demo-trade__type--buy { color: #00c853; }
.demo-trade__type--sell { color: #ff5252; }
.demo-trade__profit--pos { color: #00c853; }
.demo-trade__profit--neg { color: #ff5252; }

/* Responsive */
@media (max-width: 600px) {
    .demo-modal--lg, .demo-modal--xl {
        width: 96vw;
        max-height: 95vh;
        border-radius: 12px;
    }
    .demo-dashboard {
        grid-template-columns: 1fr;
    }
    .demo-phone {
        width: 240px;
    }
}
