@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;500;600;700&display=swap');

:root {
    --color-primary: #00d4ff;
    --color-secondary: #00ff88;
    --color-warning: #ffaa00;
    --color-danger: #ff3366;
    --color-bg-dark: #000508;
    --color-bg-light: #0a1628;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Rajdhani', sans-serif;
    background: radial-gradient(ellipse at center, var(--color-bg-light) 0%, var(--color-bg-dark) 100%);
    min-height: 100vh;
    overflow: hidden;
    color: var(--color-primary);
}

/* Сканирующие линии — оптимизировано */
.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08),
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 1000;
    will-change: auto;
}

/* Основной контейнер */
.jarvis-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Центральный интерфейс */
.core-interface {
    position: relative;
    width: 500px;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Вращающиеся кольца — GPU ускорение */
.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    will-change: transform;
}

.ring-1 {
    width: 400px;
    height: 400px;
    border-color: rgba(0, 212, 255, 0.25);
    border-top-color: var(--color-primary);
    border-right-color: var(--color-primary);
    animation: rotate 10s linear infinite;
}

.ring-2 {
    width: 350px;
    height: 350px;
    border-color: rgba(0, 255, 136, 0.15);
    border-bottom-color: var(--color-secondary);
    border-left-color: var(--color-secondary);
    animation: rotate-reverse 8s linear infinite;
}

.ring-3 {
    width: 300px;
    height: 300px;
    border-color: rgba(0, 212, 255, 0.3);
    border-top-color: var(--color-primary);
    animation: rotate 6s linear infinite;
}

.ring-4 {
    width: 250px;
    height: 250px;
    border: 2px dashed rgba(0, 212, 255, 0.2);
    animation: rotate-reverse 12s linear infinite;
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

@keyframes rotate-reverse {
    to { transform: rotate(-360deg); }
}

/* Центральное ядро */
.core {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.2) 0%, transparent 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: box-shadow 0.3s ease;
}

.core::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(0, 212, 255, 0.4);
    animation: pulse-core 2.5s ease-in-out infinite;
}

@keyframes pulse-core {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.6; }
}

/* Canvas визуализатор */
#visualizer {
    position: absolute;
    width: 200px;
    height: 200px;
    z-index: 5;
}

/* Статус панель */
.status-panel {
    position: absolute;
    bottom: 140px;
    text-align: center;
    z-index: 100;
}

.status-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-primary);
    margin-bottom: 0.5rem;
}

.status-hint {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    min-height: 1.2em;
}

/* Кнопки управления */
.controls {
    position: absolute;
    bottom: 50px;
    display: flex;
    gap: 20px;
    z-index: 100;
}

.btn {
    font-family: 'Orbitron', sans-serif;
    padding: 16px 36px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: 2px solid var(--color-primary);
    background: rgba(0, 212, 255, 0.05);
    color: var(--color-primary);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 4px;
}

.btn-icon {
    font-size: 0.8rem;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover:not(:disabled)::before {
    left: 100%;
}

.btn:hover:not(:disabled) {
    background: rgba(0, 212, 255, 0.15);
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.4);
    transform: translateY(-2px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.btn-start {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
    background: rgba(0, 255, 136, 0.05);
}

.btn-start:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.15);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.4);
}

.btn-stop {
    border-color: var(--color-danger);
    color: var(--color-danger);
    background: rgba(255, 51, 102, 0.05);
}

.btn-stop:hover:not(:disabled) {
    background: rgba(255, 51, 102, 0.15);
    box-shadow: 0 0 25px rgba(255, 51, 102, 0.4);
}

/* HUD углы */
.hud-corner {
    position: fixed;
    width: 80px;
    height: 80px;
    border: 2px solid rgba(0, 212, 255, 0.2);
    pointer-events: none;
}

.hud-tl { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.hud-tr { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.hud-bl { bottom: 20px; left: 20px; border-right: none; border-top: none; }
.hud-br { bottom: 20px; right: 20px; border-left: none; border-top: none; }

/* Частицы — оптимизировано */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: float-particle 18s linear infinite;
    opacity: 0.4;
    will-change: transform, opacity;
}

@keyframes float-particle {
    0% { transform: translateY(100vh); opacity: 0; }
    5% { opacity: 0.4; }
    95% { opacity: 0.4; }
    100% { transform: translateY(-100vh); opacity: 0; }
}

/* Волны */
.wave-container {
    position: absolute;
    width: 500px;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.wave {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.4);
    opacity: 0;
    will-change: width, height, opacity;
}

.active .wave {
    animation: wave-expand 2.5s ease-out infinite;
}

.wave:nth-child(1) { animation-delay: 0s; }
.wave:nth-child(2) { animation-delay: 0.6s; }
.wave:nth-child(3) { animation-delay: 1.2s; }
.wave:nth-child(4) { animation-delay: 1.8s; }

@keyframes wave-expand {
    0% { width: 180px; height: 180px; opacity: 0.6; }
    100% { width: 450px; height: 450px; opacity: 0; }
}

/* Заголовок */
.title {
    position: absolute;
    top: 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 12px;
    color: var(--color-primary);
    text-shadow: 0 0 15px var(--color-primary), 0 0 30px rgba(0, 212, 255, 0.5);
}

.subtitle {
    position: absolute;
    top: 95px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

/* Боковая панель данных */
.data-stream {
    position: fixed;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Rajdhani', monospace;
    font-size: 0.75rem;
    color: rgba(0, 212, 255, 0.5);
    line-height: 2;
}

.data-stream span {
    display: block;
    transition: color 0.3s;
}

.data-stream span:hover {
    color: var(--color-primary);
}

/* Панель транскрипции */
.transcript-panel {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 20px;
    background: rgba(0, 15, 30, 0.85);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.transcript-panel::-webkit-scrollbar {
    width: 4px;
}

.transcript-panel::-webkit-scrollbar-track {
    background: rgba(0, 212, 255, 0.05);
}

.transcript-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 2px;
}

.transcript-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    color: var(--color-primary);
    letter-spacing: 3px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.transcript-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    padding: 20px 0;
}

.transcript-entry {
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(0, 212, 255, 0.03);
    border-left: 3px solid;
    border-radius: 0 8px 8px 0;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}

.transcript-entry.user {
    border-left-color: var(--color-secondary);
    background: rgba(0, 255, 136, 0.03);
}

.transcript-entry.assistant {
    border-left-color: var(--color-primary);
}

.transcript-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 6px;
    opacity: 0.7;
}

.transcript-entry.user .transcript-label {
    color: var(--color-secondary);
}

.transcript-entry.assistant .transcript-label {
    color: var(--color-primary);
}

.transcript-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
}

/* Стриминг текста */
.transcript-entry.streaming .transcript-text {
    color: rgba(255, 255, 255, 0.95);
}

.transcript-text .cursor {
    color: var(--color-primary);
    animation: blink-cursor 0.8s ease-in-out infinite;
    font-weight: normal;
}

.transcript-text .cursor.user-cursor {
    color: var(--color-secondary);
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Индикатор прослушивания */
.listening-indicator {
    color: var(--color-secondary);
    animation: listening-pulse 1.2s ease-in-out infinite;
    letter-spacing: 3px;
}

@keyframes listening-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.transcript-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.25);
    text-align: right;
    margin-top: 6px;
}

/* Подсказка клавиатуры */
.keyboard-hint {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.2);
    z-index: 100;
}

.keyboard-hint kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Rajdhani', monospace;
    margin-right: 5px;
}

/* Состояния ядра */
.listening .core {
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.5), 0 0 80px rgba(0, 255, 136, 0.2);
    animation: core-listening 1.5s ease-in-out infinite;
}

@keyframes core-listening {
    0%, 100% { box-shadow: 0 0 40px rgba(0, 255, 136, 0.5); }
    50% { box-shadow: 0 0 60px rgba(0, 255, 136, 0.7), 0 0 100px rgba(0, 255, 136, 0.3); }
}

.speaking .core {
    box-shadow: 0 0 50px rgba(0, 212, 255, 0.7);
    animation: core-speaking 0.6s ease-in-out infinite;
}

@keyframes core-speaking {
    0%, 100% { box-shadow: 0 0 50px rgba(0, 212, 255, 0.7); }
    50% { box-shadow: 0 0 80px rgba(0, 212, 255, 0.9), 0 0 120px rgba(0, 212, 255, 0.4); }
}

.processing .core {
    box-shadow: 0 0 40px rgba(255, 170, 0, 0.5);
    animation: core-processing 1s ease-in-out infinite;
}

@keyframes core-processing {
    0%, 100% { box-shadow: 0 0 40px rgba(255, 170, 0, 0.5); }
    50% { box-shadow: 0 0 60px rgba(255, 170, 0, 0.7), 0 0 90px rgba(255, 170, 0, 0.3); }
}

/* Адаптивность */
@media (max-width: 1200px) {
    .data-stream { display: none; }
    .transcript-panel { width: 280px; }
}

@media (max-width: 900px) {
    .transcript-panel {
        position: fixed;
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 120px;
        transform: none;
        width: auto;
        max-height: 30vh;
    }
    
    .core-interface {
        width: 350px;
        height: 350px;
    }
    
    .ring-1 { width: 280px; height: 280px; }
    .ring-2 { width: 240px; height: 240px; }
    .ring-3 { width: 200px; height: 200px; }
    .ring-4 { width: 170px; height: 170px; }
    
    .title { font-size: 1.8rem; letter-spacing: 8px; }
    .subtitle { font-size: 0.75rem; top: 80px; }
}

/* Уменьшение анимаций для экономии батареи */
@media (prefers-reduced-motion: reduce) {
    .ring, .particle, .wave, .core::before {
        animation: none;
    }
    
    .scanlines {
        display: none;
    }
}
