/* css/dashboard/ai-agent.css */

.content-body.ai-agent-body {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 540px;
    padding: 16px 8px !important;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
}

.ai-agent-stage {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 484px;
}

/* ========================================================
   ORBITAL SFERA DOCK (MARKAZ <-> CHETGA ANIMATSION KO'CHISH)
   ======================================================== */
.ai-orbital-dock {
    position: absolute;
    width: 400px;
    height: 400px;
    top: calc(50% - 78px);
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition:
        top 0.78s cubic-bezier(0.22, 1, 0.36, 1),
        left 0.78s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.78s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Natija chiqqanda kichrayib ekranning o'ng yuqori chetiga silliq o'tadi */
.ai-agent-stage[data-layout="result"] .ai-orbital-dock {
    top: 66px;
    left: calc(100% - 72px);
    transform: translate(-50%, -50%) scale(0.3);
}

.ai-orbital-scene {
    --orb-primary: #0ea5e9;
    --orb-secondary: #2563eb;
    --orb-accent: #7dd3fc;
    --orb-glow: rgba(14, 165, 233, 0.38);

    position: relative;
    width: 400px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1100px;
    transform-style: preserve-3d;
    cursor: pointer;
    user-select: none;
    outline: none;
    transition: transform 0.3s ease;
}

.ai-orbital-scene:hover {
    transform: scale(1.025);
}

/* Holatlar bo'yicha rang palitrasi */
.ai-orbital-scene[data-state="listening"] {
    --orb-primary: #10b981;
    --orb-secondary: #06b6d4;
    --orb-accent: #6ee7b7;
    --orb-glow: rgba(16, 185, 129, 0.46);
}

.ai-orbital-scene[data-state="speaking"] {
    --orb-primary: #6366f1;
    --orb-secondary: #a855f7;
    --orb-accent: #38bdf8;
    --orb-glow: rgba(99, 102, 241, 0.52);
}

/* Orqa nurlanish */
.ai-orbital-glow {
    position: absolute;
    width: 290px;
    height: 290px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--orb-glow) 0%, transparent 70%);
    filter: blur(26px);
    pointer-events: none;
    animation: aiGlowBreath 4.5s ease-in-out infinite;
    transition: background 0.5s ease;
}

@keyframes aiGlowBreath {
    0%, 100% {
        transform: scale(0.92);
        opacity: 0.72;
    }
    50% {
        transform: scale(1.12);
        opacity: 1;
    }
}

/* Sonar to'lqinlari */
.ai-listen-ripple {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 2px solid var(--orb-accent);
    opacity: 0;
    pointer-events: none;
}

.ai-orbital-scene[data-state="idle"] .ai-listen-ripple {
    animation: aiIdlePulse 6s ease-out infinite;
}
.ai-orbital-scene[data-state="idle"] .ai-listen-ripple.r2 { animation-delay: 2s; }
.ai-orbital-scene[data-state="idle"] .ai-listen-ripple.r3 { animation-delay: 4s; }

.ai-orbital-scene[data-state="listening"] .ai-listen-ripple {
    animation: aiListenSonar 2.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.ai-orbital-scene[data-state="listening"] .ai-listen-ripple.r2 { animation-delay: 0.85s; }
.ai-orbital-scene[data-state="listening"] .ai-listen-ripple.r3 { animation-delay: 1.7s; }

.ai-orbital-scene[data-state="speaking"] .ai-listen-ripple {
    border-width: 2.5px;
    animation: aiSpeakShockwave 1.5s ease-out infinite;
}
.ai-orbital-scene[data-state="speaking"] .ai-listen-ripple.r2 { animation-delay: 0.5s; }
.ai-orbital-scene[data-state="speaking"] .ai-listen-ripple.r3 { animation-delay: 1s; }

@keyframes aiIdlePulse {
    0% { transform: scale(0.95); opacity: 0.28; }
    100% { transform: scale(1.72); opacity: 0; }
}

@keyframes aiListenSonar {
    0% { transform: scale(1.75); opacity: 0; }
    35% { opacity: 0.58; }
    100% { transform: scale(0.86); opacity: 0; }
}

@keyframes aiSpeakShockwave {
    0% { transform: scale(0.92); opacity: 0.75; }
    100% { transform: scale(1.78); opacity: 0; }
}

/* 3D Orbital halqalar tekisligi */
.ai-orbit-plane {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    pointer-events: none;
    transition: transform 0.6s ease;
}

.ai-orbit-plane.orbit-1 {
    transform: rotateX(68deg) rotateY(-18deg);
}

.ai-orbit-plane.orbit-2 {
    transform: rotateX(64deg) rotateY(42deg);
}

.ai-orbit-plane.orbit-3 {
    transform: rotateX(72deg) rotateY(-64deg);
}

.ai-orbital-scene[data-state="listening"] .ai-orbit-plane.orbit-1 {
    transform: rotateX(58deg) rotateY(-10deg) scale(0.93);
}
.ai-orbital-scene[data-state="listening"] .ai-orbit-plane.orbit-2 {
    transform: rotateX(58deg) rotateY(30deg) scale(0.96);
}
.ai-orbital-scene[data-state="listening"] .ai-orbit-plane.orbit-3 {
    transform: rotateX(62deg) rotateY(-50deg) scale(0.94);
}

.ai-orbital-scene[data-state="speaking"] .ai-orbit-plane.orbit-1 {
    animation: aiSpeakTilt1 2.2s ease-in-out infinite alternate;
}
.ai-orbital-scene[data-state="speaking"] .ai-orbit-plane.orbit-2 {
    animation: aiSpeakTilt2 2.6s ease-in-out infinite alternate;
}
.ai-orbital-scene[data-state="speaking"] .ai-orbit-plane.orbit-3 {
    animation: aiSpeakTilt3 1.9s ease-in-out infinite alternate;
}

@keyframes aiSpeakTilt1 {
    0% { transform: rotateX(62deg) rotateY(-25deg) scale(1.02); }
    100% { transform: rotateX(76deg) rotateY(15deg) scale(1.1); }
}
@keyframes aiSpeakTilt2 {
    0% { transform: rotateX(55deg) rotateY(52deg) scale(1.06); }
    100% { transform: rotateX(74deg) rotateY(18deg) scale(0.98); }
}
@keyframes aiSpeakTilt3 {
    0% { transform: rotateX(70deg) rotateY(-70deg) scale(1); }
    100% { transform: rotateX(52deg) rotateY(-32deg) scale(1.08); }
}

.ai-orbit-ring {
    position: relative;
    border-radius: 50%;
    border: 2.5px solid rgba(125, 211, 252, 0.45);
    box-shadow: 0 0 18px var(--orb-glow);
    transition: border-color 0.45s ease, box-shadow 0.45s ease;
}

.orbit-1 .ai-orbit-ring {
    width: 332px;
    height: 332px;
    border-color: var(--orb-accent);
    border-top-color: transparent;
    animation: aiSpinCW 11s linear infinite;
}

.orbit-2 .ai-orbit-ring {
    width: 364px;
    height: 364px;
    border-color: var(--orb-primary);
    border-bottom-color: transparent;
    animation: aiSpinCCW 15s linear infinite;
}

.orbit-3 .ai-orbit-ring {
    width: 300px;
    height: 300px;
    border-color: var(--orb-secondary);
    border-left-color: transparent;
    animation: aiSpinCW 19s linear infinite;
}

.ai-orbital-scene[data-state="listening"] .orbit-1 .ai-orbit-ring { animation-duration: 5.5s; }
.ai-orbital-scene[data-state="listening"] .orbit-2 .ai-orbit-ring { animation-duration: 7s; }
.ai-orbital-scene[data-state="listening"] .orbit-3 .ai-orbit-ring { animation-duration: 8.5s; }

.ai-orbital-scene[data-state="speaking"] .orbit-1 .ai-orbit-ring { animation-duration: 2.6s; border-width: 3px; }
.ai-orbital-scene[data-state="speaking"] .orbit-2 .ai-orbit-ring { animation-duration: 3.4s; border-width: 3px; }
.ai-orbital-scene[data-state="speaking"] .orbit-3 .ai-orbit-ring { animation-duration: 2.9s; border-width: 3px; }

.ai-orbit-node {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 0 14px 4px var(--orb-accent);
}

@keyframes aiSpinCW {
    from { transform: rotateZ(0deg); }
    to { transform: rotateZ(360deg); }
}

@keyframes aiSpinCCW {
    from { transform: rotateZ(360deg); }
    to { transform: rotateZ(0deg); }
}

/* Markaziy katta sfera (Yadro) */
.ai-core-sphere {
    position: relative;
    width: 196px;
    height: 196px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(
        circle at 32% 28%,
        var(--orb-accent) 0%,
        var(--orb-primary) 42%,
        var(--orb-secondary) 82%,
        #0f172a 100%
    );
    box-shadow:
        0 0 46px var(--orb-glow),
        inset 0 0 28px rgba(255, 255, 255, 0.34);
    animation: aiCoreIdle 4.5s ease-in-out infinite;
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

.ai-orbital-scene[data-state="listening"] .ai-core-sphere {
    animation: aiCoreListen 2.2s ease-in-out infinite;
}

.ai-orbital-scene[data-state="speaking"] .ai-core-sphere {
    animation: aiCoreSpeak 0.9s ease-in-out infinite;
}

@keyframes aiCoreIdle {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.035) translateY(-5px); }
}

@keyframes aiCoreListen {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.06); }
}

@keyframes aiCoreSpeak {
    0% { transform: scale(1); }
    25% { transform: scale(1.09); }
    50% { transform: scale(0.97); }
    75% { transform: scale(1.07); }
    100% { transform: scale(1); }
}

.ai-core-plasma {
    position: absolute;
    inset: -30%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(255, 255, 255, 0.28) 90deg,
        transparent 180deg,
        rgba(255, 255, 255, 0.18) 270deg,
        transparent 360deg
    );
    filter: blur(10px);
    animation: aiSpinCW 8s linear infinite;
    pointer-events: none;
}

.ai-orbital-scene[data-state="speaking"] .ai-core-plasma {
    animation-duration: 2.5s;
}

.ai-core-bars {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 60px;
}

.ai-core-bars span {
    display: block;
    width: 6px;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.65);
    transition: height 0.25s ease;
}

.ai-orbital-scene[data-state="idle"] .ai-core-bars span:nth-child(1) { animation: aiBarIdle 3.2s ease-in-out infinite 0.0s; }
.ai-orbital-scene[data-state="idle"] .ai-core-bars span:nth-child(2) { animation: aiBarIdle 3.2s ease-in-out infinite 0.2s; }
.ai-orbital-scene[data-state="idle"] .ai-core-bars span:nth-child(3) { animation: aiBarIdle 3.2s ease-in-out infinite 0.4s; }
.ai-orbital-scene[data-state="idle"] .ai-core-bars span:nth-child(4) { animation: aiBarIdle 3.2s ease-in-out infinite 0.6s; }
.ai-orbital-scene[data-state="idle"] .ai-core-bars span:nth-child(5) { animation: aiBarIdle 3.2s ease-in-out infinite 0.8s; }

.ai-orbital-scene[data-state="listening"] .ai-core-bars span:nth-child(1) { animation: aiBarListen 1.2s ease-in-out infinite 0.1s; }
.ai-orbital-scene[data-state="listening"] .ai-core-bars span:nth-child(2) { animation: aiBarListen 1.2s ease-in-out infinite 0.3s; }
.ai-orbital-scene[data-state="listening"] .ai-core-bars span:nth-child(3) { animation: aiBarListen 1.2s ease-in-out infinite 0.0s; }
.ai-orbital-scene[data-state="listening"] .ai-core-bars span:nth-child(4) { animation: aiBarListen 1.2s ease-in-out infinite 0.4s; }
.ai-orbital-scene[data-state="listening"] .ai-core-bars span:nth-child(5) { animation: aiBarListen 1.2s ease-in-out infinite 0.2s; }

.ai-orbital-scene[data-state="speaking"] .ai-core-bars span:nth-child(1) { animation: aiBarSpeak 0.55s ease-in-out infinite 0.0s; }
.ai-orbital-scene[data-state="speaking"] .ai-core-bars span:nth-child(2) { animation: aiBarSpeak 0.42s ease-in-out infinite 0.15s; }
.ai-orbital-scene[data-state="speaking"] .ai-core-bars span:nth-child(3) { animation: aiBarSpeak 0.48s ease-in-out infinite 0.05s; }
.ai-orbital-scene[data-state="speaking"] .ai-core-bars span:nth-child(4) { animation: aiBarSpeak 0.38s ease-in-out infinite 0.25s; }
.ai-orbital-scene[data-state="speaking"] .ai-core-bars span:nth-child(5) { animation: aiBarSpeak 0.52s ease-in-out infinite 0.1s; }

@keyframes aiBarIdle {
    0%, 100% { height: 9px; opacity: 0.7; }
    50% { height: 18px; opacity: 0.95; }
}

@keyframes aiBarListen {
    0%, 100% { height: 12px; opacity: 0.82; }
    50% { height: 34px; opacity: 1; }
}

@keyframes aiBarSpeak {
    0%, 100% { height: 12px; }
    45% { height: 52px; }
    75% { height: 28px; }
}

.ai-core-glass {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.1) 24%, transparent 50%);
    pointer-events: none;
}

/* ========================================================
   MARKAZDAGI MATN VA HOLAT TUGMALARI
   ======================================================== */
.ai-agent-caption {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    z-index: 4;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.ai-agent-stage[data-layout="result"] .ai-agent-caption {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(16px);
}

.ai-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #0284c7;
    background-color: var(--background-color);
    box-shadow:
        3px 3px 7px var(--shadow-dark),
        -3px -3px 7px var(--shadow-light);
}

body.dark-mode .ai-status-pill {
    color: #38bdf8;
}

.ai-status-pill[data-state="listening"] {
    color: #059669;
}
body.dark-mode .ai-status-pill[data-state="listening"] {
    color: #34d399;
}

.ai-status-pill[data-state="speaking"] {
    color: #4f46e5;
}
body.dark-mode .ai-status-pill[data-state="speaking"] {
    color: #818cf8;
}

.ai-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: aiDotBlink 1.6s ease-in-out infinite;
}

@keyframes aiDotBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.75); }
}

.ai-agent-caption h2 {
    margin: 2px 0 0 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-text-color);
}

.ai-agent-caption p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--secondary-text-color);
    max-width: 500px;
}

.ai-state-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.ai-state-btn,
.ai-demo-btn,
.ai-reset-btn {
    border: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 12px;
    cursor: pointer;
    background-color: var(--element-bg);
    color: var(--secondary-text-color);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow:
        4px 4px 9px var(--shadow-dark),
        -4px -4px 9px var(--shadow-light);
    transition: all 0.2s ease;
}

.ai-state-btn:hover,
.ai-demo-btn:hover,
.ai-reset-btn:hover {
    color: var(--primary-text-color);
}

.ai-state-btn.active {
    color: var(--primary-text-color);
    box-shadow:
        inset 3px 3px 7px var(--shadow-dark),
        inset -3px -3px 7px var(--shadow-light);
}

.ai-demo-btn {
    color: #0284c7;
}

body.dark-mode .ai-demo-btn {
    color: #38bdf8;
}

.ai-demo-btn:active,
.ai-reset-btn:active {
    box-shadow:
        inset 3px 3px 7px var(--shadow-dark),
        inset -3px -3px 7px var(--shadow-light);
}

/* ========================================================
   NATIJA MAYDONI (TEKST VA JADVALLAR)
   ======================================================== */
.ai-result-panel {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.45s ease 0.2s, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

.ai-agent-stage[data-layout="result"] .ai-result-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.ai-result-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-right: 155px; /* O'ng yuqori burchakdagi kichraygan orbital sfera uchun bo'shliq */
    min-height: 112px;
    justify-content: center;
}

.ai-result-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.ai-result-title-row h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-text-color);
}

.ai-result-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-result-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding: 4px 4px 12px 4px;
}

.ai-result-text-card {
    padding: 22px 24px;
    border-radius: 18px;
    background-color: var(--element-bg);
    box-shadow:
        6px 6px 14px var(--shadow-dark),
        -6px -6px 14px var(--shadow-light);
    text-align: left;
}

.ai-result-text-card p {
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--primary-text-color);
}

.ai-result-text-card p:last-child {
    margin-bottom: 0;
}

.ai-result-table-card {
    padding: 20px 24px;
    border-radius: 18px;
    background-color: var(--element-bg);
    box-shadow:
        6px 6px 14px var(--shadow-dark),
        -6px -6px 14px var(--shadow-light);
    overflow-x: auto;
}

.ai-result-table-title {
    margin: 0 0 14px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-text-color);
    text-align: left;
}

.ai-result-table {
    width: 100%;
    border-collapse: collapse;
}

.ai-result-table th,
.ai-result-table td {
    padding: 13px 14px;
    text-align: left;
    font-size: 14px;
    border-bottom: 2px solid var(--background-color);
}

.ai-result-table thead th {
    font-weight: 600;
    color: var(--secondary-text-color);
    font-size: 13px;
}

.ai-result-table tbody tr:last-child td {
    border-bottom: none;
}

.ai-result-table tbody tr:hover {
    background-color: var(--background-color);
}

/* ========================================================
   STATISTIKA - TEZ ORADA KARTASI
   ======================================================== */
.stats-soon-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 380px;
}

.stats-soon-card {
    width: 100%;
    max-width: 480px;
    padding: 36px 30px;
    border-radius: 24px;
    background-color: var(--element-bg);
    box-shadow:
        8px 8px 18px var(--shadow-dark),
        -8px -8px 18px var(--shadow-light);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.stats-soon-icon {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background-color: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-text-color);
    box-shadow:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
}

.stats-soon-icon svg {
    width: 30px;
    height: 30px;
}

.stats-soon-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 999px;
    color: #d97706;
    background-color: var(--background-color);
    box-shadow:
        2px 2px 5px var(--shadow-dark),
        -2px -2px 5px var(--shadow-light);
}

body.dark-mode .stats-soon-badge {
    color: #fbbf24;
}

.stats-soon-card h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-text-color);
}

.stats-soon-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--secondary-text-color);
}

@media (max-width: 768px) {
    .ai-agent-body {
        padding: 18px !important;
    }

    .ai-orbital-dock {
        width: 300px;
        height: 300px;
        top: calc(50% - 88px);
    }

    .ai-agent-stage[data-layout="result"] .ai-orbital-dock {
        top: 52px;
        left: calc(100% - 52px);
        transform: translate(-50%, -50%) scale(0.32);
    }

    .ai-orbital-scene {
        width: 300px;
        height: 300px;
    }

    .orbit-1 .ai-orbit-ring { width: 250px; height: 250px; }
    .orbit-2 .ai-orbit-ring { width: 274px; height: 274px; }
    .orbit-3 .ai-orbit-ring { width: 226px; height: 226px; }

    .ai-core-sphere {
        width: 148px;
        height: 148px;
    }

    .ai-result-header {
        padding-right: 110px;
        min-height: 92px;
    }
}
