/* =================================================================
   THE ORACLE TERMINAL - AI-Powered Market Sentiment & Scanner
   ================================================================= */

/* --- LAYOUT & POSITIONING --- */
#oracle-terminal-widget {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 380px;
    background: var(--color-surface-80);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    z-index: 9000;
    font-family: 'Inter', system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

/* --- HEADER & HANDLES --- */
.oracle-header-handle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--color-border);
    cursor: grab;
    user-select: none;
    pointer-events: auto !important;
    z-index: 100 !important;
}

.oracle-header-handle:active {
    cursor: grabbing;
}

.oracle-header-handle>* {
    pointer-events: none;
}

/* Re-enable pointer events for the close button inside the handle */
.oracle-header-handle>#oracle-minimize-btn {
    pointer-events: auto !important;
}

.oracle-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--color-accent-cyan);
    text-transform: uppercase;
}

.oracle-status-dot {
    width: 8px;
    height: 8px;
    background: var(--color-positive);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-positive), 0 0 20px var(--color-positive);
    animation: oracle-pulse 2s infinite;
}

/* .oracle-minimize-btn — consolidated into universal close button rule in style.css */
.oracle-minimize-btn {
    pointer-events: auto !important;
}

/* --- MAIN BODY --- */
.oracle-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- UNIVERSAL TICKER (DEFAULT/DESKTOP) --- */
#oracle-network-pulse {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(0, 242, 254, 0.1);
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    white-space: nowrap;
    overflow: hidden;
    padding: 5px 0;
    font-family: 'Space Mono', monospace;
    position: relative;
    /* Fade edges */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 6%, black 94%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 6%, black 94%, transparent 100%);
}

/* Pause on hover */
#oracle-network-pulse:hover .oracle-ticker-track {
    animation-play-state: paused;
}

.oracle-ticker-track {
    display: inline-block;
    animation: oracle-marquee 40s linear infinite;
    padding: 0 20px;
}

/* Ticker text classes */
.pt-tag {
    color: rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5px;
}
.pt-chain {
    font-weight: 700;
    letter-spacing: 1px;
}
.pt-val {
    color: var(--color-accent-cyan);
    font-weight: 700;
}
.pt-label {
    color: rgba(255, 255, 255, 0.25);
}
.pt-sep {
    color: rgba(255, 255, 255, 0.12);
    margin: 0 6px;
}

/* HIDE MOBILE HEADER BY DEFAULT (DESKTOP) */
.mobile-widget-header {
    display: none !important;
}

/* === THE VISUAL CORE (Pulsing Orb) === */
.oracle-core-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.oracle-core {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inner Glowing Sphere */
.oracle-core-inner {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
            var(--color-accent-cyan) 0%,
            rgba(45, 212, 191, 0.4) 100%);
    box-shadow:
        0 0 40px rgba(45, 212, 191, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: oracle-core-pulse 3s ease-in-out infinite;
}

.oracle-core-glow {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle,
            rgba(0, 242, 254, 0.2) 0%,
            transparent 70%);
    animation: oracle-glow-breathe 4s ease-in-out infinite;
}

/* Energy Rings */
.oracle-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 242, 254, 0.3);
    animation: oracle-ring-spin 10s linear infinite;
}

.oracle-ring-1 {
    width: 80px;
    height: 80px;
    border-style: dashed;
    animation-duration: 8s;
}

.oracle-ring-2 {
    width: 100px;
    height: 100px;
    border-color: rgba(0, 242, 254, 0.2);
    animation-duration: 12s;
    animation-direction: reverse;
}

.oracle-ring-3 {
    width: 116px;
    height: 116px;
    border-color: rgba(0, 242, 254, 0.1);
    border-style: dotted;
    animation-duration: 15s;
}

/* Sentiment Display */
.oracle-sentiment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.oracle-sentiment-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--color-text-dim);
    text-transform: uppercase;
}

.oracle-sentiment-value {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--color-accent-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
    animation: oracle-text-glow 2s ease-in-out infinite;
}

.oracle-sentiment-score {
    font-family: 'Space Mono', monospace;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* === STATE COLORS === */
/* Bullish / Greed */
.oracle-core.oracle-bullish .oracle-core-inner {
    background: radial-gradient(circle at 30% 30%,
            rgba(0, 230, 118, 0.9) 0%,
            rgba(0, 180, 90, 0.7) 40%,
            rgba(0, 100, 60, 0.4) 70%,
            rgba(0, 50, 30, 0.2) 100%);
    box-shadow:
        0 0 30px rgba(0, 230, 118, 0.6),
        0 0 60px rgba(0, 230, 118, 0.4),
        0 0 90px rgba(0, 230, 118, 0.2);
}

.oracle-core.oracle-bullish .oracle-core-glow {
    background: radial-gradient(circle,
            rgba(0, 230, 118, 0.3) 0%,
            transparent 70%);
}

.oracle-core.oracle-bullish .oracle-ring {
    border-color: rgba(0, 230, 118, 0.3);
}

.oracle-bullish .oracle-sentiment-value {
    color: var(--color-positive);
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.5);
}

/* Bearish / Fear */
.oracle-core.oracle-bearish .oracle-core-inner {
    background: radial-gradient(circle at 30% 30%,
            rgba(255, 82, 82, 0.9) 0%,
            rgba(200, 60, 60, 0.7) 40%,
            rgba(130, 40, 40, 0.4) 70%,
            rgba(70, 20, 20, 0.2) 100%);
    box-shadow:
        0 0 30px rgba(255, 82, 82, 0.6),
        0 0 60px rgba(255, 82, 82, 0.4),
        0 0 90px rgba(255, 82, 82, 0.2);
    animation: oracle-core-pulse-fast 1.5s ease-in-out infinite;
}

.oracle-core.oracle-bearish .oracle-core-glow {
    background: radial-gradient(circle,
            rgba(255, 82, 82, 0.3) 0%,
            transparent 70%);
}

.oracle-core.oracle-bearish .oracle-ring {
    border-color: rgba(255, 82, 82, 0.3);
}

.oracle-bearish .oracle-sentiment-value {
    color: var(--color-negative);
    text-shadow: 0 0 10px rgba(255, 82, 82, 0.5);
}

/* === TERMINAL INPUT === */
.oracle-terminal {
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
}

.oracle-terminal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.oracle-terminal-prompt {
    color: var(--color-positive);
    font-family: 'Space Mono', monospace;
    font-weight: bold;
}

.oracle-terminal-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--color-text-dim);
    text-transform: uppercase;
}

.oracle-input-row {
    display: flex;
    gap: 8px;
}

.oracle-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--color-text-light);
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    outline: none;
    transition: all 0.2s;
}

.oracle-input:focus {
    border-color: var(--color-accent-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.oracle-input::placeholder {
    color: var(--color-text-dim);
    font-size: 10px;
}

.oracle-scan-btn {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.2) 0%, rgba(0, 180, 200, 0.3) 100%);
    border: 1px solid var(--color-accent-cyan);
    border-radius: 4px;
    padding: 10px 16px;
    color: var(--color-accent-cyan);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.oracle-scan-btn:hover {
    background: var(--color-accent-cyan);
    color: var(--color-base);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}

.oracle-scan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.oracle-scan-loading {
    display: inline-block;
    animation: oracle-spin 1s linear infinite;
}

/* === RESULTS PANEL === */
.oracle-results {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 242, 254, 0.15);
    border-radius: 8px;
    padding: 12px;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
}

.oracle-results-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
}

.oracle-results-hint {
    font-size: 10px;
    color: var(--color-text-dim);
    text-align: center;
    font-style: italic;
}

/* Result Items */
.oracle-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 242, 254, 0.1);
}

.oracle-result-token {
    font-weight: 800;
    font-size: 14px;
    color: #fff;
}

.oracle-result-chain {
    font-size: 10px;
    color: var(--color-text-dim);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.oracle-result-score {
    margin-left: auto;
    font-family: 'Space Mono', monospace;
    font-size: 16px;
    font-weight: 800;
}

.oracle-result-score.safe {
    color: var(--color-positive);
}

.oracle-result-score.caution {
    color: #ffa726;
}

.oracle-result-score.danger {
    color: var(--color-negative);
}

/* Security Matrix */
.oracle-security-matrix {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.oracle-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.oracle-check-icon {
    width: 16px;
    text-align: center;
}

.oracle-check-icon.pass {
    color: var(--color-positive);
}

.oracle-check-icon.fail {
    color: var(--color-negative);
}

.oracle-check-icon.warn {
    color: #ffa726;
}

.oracle-check-label {
    color: var(--color-text-dim);
}

.oracle-check-value {
    margin-left: auto;
    color: var(--color-text-light);
    font-family: 'Space Mono', monospace;
}

/* Scanning Animation */
.oracle-scanning {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
}

.oracle-scanning-text {
    font-size: 11px;
    color: var(--color-accent-cyan);
    letter-spacing: 2px;
    animation: oracle-text-glow 1s ease-in-out infinite;
}

.oracle-scanning-bar {
    width: 100%;
    height: 3px;
    background: rgba(0, 242, 254, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.oracle-scanning-progress {
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-accent-cyan), transparent);
    animation: oracle-scan-progress 1.5s ease-in-out infinite;
}

/* === MINIMIZED STATE === */
#oracle-terminal-widget.minimized {
    display: none !important;
}

#oracle-terminal-widget.minimized .oracle-body {
    display: none;
}

#oracle-terminal-widget.minimized .oracle-header-handle {
    border-bottom: none;
}

/* === ANIMATIONS === */
@keyframes oracle-pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 10px var(--color-positive), 0 0 20px var(--color-positive);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 5px var(--color-positive);
    }
}

@keyframes oracle-core-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes oracle-core-pulse-fast {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes oracle-glow-breathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

@keyframes oracle-ring-spin {
    from {
        transform: rotate(0deg);
    }

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

@keyframes oracle-text-glow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes oracle-spin {
    from {
        transform: rotate(0deg);
    }

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

@keyframes oracle-scan-progress {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

/* === LIGHT THEME SUPPORT === */
body.theme-light #oracle-terminal-widget {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(14, 116, 144, 0.3);
}

body.theme-light .oracle-result-token,
body.theme-light .oracle-sentiment-score {
    color: #1e293b;
    /* Dark Navy for Light Mode */
}