/**
 * Cognitive Studio X-Ray Toggle
 * 334-Project Iterations-1: Toggle between resolved and unresolved variable display
 */

/* Toggle Container */
.xray-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    user-select: none;
}

/* Labels */
.xray-label {
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.xray-label.unresolved {
    color: rgba(255, 255, 255, 0.4);
}

.xray-label.resolved {
    color: rgba(255, 255, 255, 0.4);
}

.xray-label.active {
    color: #fff;
}

/* The Toggle Switch */
.xray-toggle {
    position: relative;
    width: 56px;
    height: 28px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 14px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.xray-toggle:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 10px rgba(0, 212, 255, 0.2);
}

/* The sliding emoji button */
.xray-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #2a2a4a 0%, #1a1a3a 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Resolved state (slider on right) */
.xray-toggle.resolved .xray-toggle-slider {
    left: calc(100% - 24px);
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* Emoji states */
.xray-toggle .xray-emoji {
    transition: all 0.3s ease;
}

.xray-toggle.resolved .xray-emoji {
    filter: drop-shadow(0 0 3px rgba(0, 212, 255, 0.8));
}

.xray-toggle:not(.resolved) .xray-emoji {
    opacity: 0.6;
    filter: grayscale(50%);
}

/* Glow effect for resolved mode */
.xray-toggle.resolved {
    background: linear-gradient(135deg, #0a2a3a 0%, #0a1a2e 100%);
    border-color: rgba(0, 212, 255, 0.4);
}

/* Tooltip */
.xray-toggle-container[title] {
    position: relative;
}

.xray-toggle-container::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.xray-toggle-container:hover::after {
    opacity: 1;
}

/* Compact version for tighter spaces */
.xray-toggle-container.compact {
    padding: 2px 8px;
    gap: 6px;
}

.xray-toggle-container.compact .xray-toggle {
    width: 44px;
    height: 22px;
    border-radius: 11px;
}

.xray-toggle-container.compact .xray-toggle-slider {
    width: 18px;
    height: 18px;
    font-size: 11px;
}

.xray-toggle-container.compact .xray-toggle.resolved .xray-toggle-slider {
    left: calc(100% - 20px);
}

.xray-toggle-container.compact .xray-label {
    font-size: 10px;
}

/* Panel header specific styles */
#xrayToggleContainer {
    display: inline-flex;
    margin-right: 8px;
}

#xrayToggleContainer .xray-toggle-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
}

/* Animation for mode change */
@keyframes xrayPulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(0, 212, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
}

.xray-toggle.just-toggled {
    animation: xrayPulse 0.5s ease-out;
}

/* Indicator for resolved blocks */
.intent-block-instance.xray-resolved {
    position: relative;
}

.intent-block-instance.xray-resolved::after {
    content: '🩻';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    opacity: 0.4;
}

/* Variable display styles for resolved mode */
.resolved-value {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 3px;
    padding: 1px 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
    color: #00d4ff;
}

.resolved-value.array {
    color: #ffd93d;
    border-color: rgba(255, 217, 61, 0.3);
    background: rgba(255, 217, 61, 0.1);
}

.resolved-value.number {
    color: #5cb85c;
    border-color: rgba(92, 184, 92, 0.3);
    background: rgba(92, 184, 92, 0.1);
}

.resolved-value.string {
    color: #f0ad4e;
    border-color: rgba(240, 173, 78, 0.3);
    background: rgba(240, 173, 78, 0.1);
}

/* Original variable syntax (unresolved mode) */
.original-variable {
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 3px;
    padding: 1px 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
    color: #9b59b6;
}

/* X-Ray update animation */
@keyframes xrayUpdatePulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.6);
        background-color: rgba(0, 212, 255, 0.1);
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.3);
        background-color: rgba(0, 212, 255, 0.15);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0);
        background-color: transparent;
    }
}

.xray-updated {
    animation: xrayUpdatePulse 0.6s ease-out;
}

/* Show iteration number when in X-Ray + iteration mode */
.intent-block-instance[data-iteration-index] {
    position: relative;
}

.intent-block-instance[data-iteration-index]::after {
    content: '[' attr(data-iteration-index) ']';
    position: absolute;
    top: 4px;
    right: 32px;
    font-size: 10px;
    color: #00d4ff;
    opacity: 0.8;
    font-weight: 600;
    background: rgba(0, 212, 255, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ================================================================
   A-343: Observatory Events Panel X-Ray Styles
   ================================================================ */

/* X-Ray header - positions toggle in top right */
.obs-xray-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    height: 36px;
    overflow: visible;
}

/* Override default toggle container styles for observatory */
.obs-xray-header .xray-toggle-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 2px 8px !important;
    margin: 0;
}

/* Hide default tooltip completely, use title attribute instead */
.obs-xray-header .xray-toggle-container::after {
    display: none !important;
    content: none !important;
}

/* Disabled state for toggle */
.obs-xray-header .xray-toggle-container.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.xray-toggle-container.disabled .xray-toggle {
    cursor: not-allowed;
}

.xray-toggle-container.disabled .xray-toggle {
    cursor: not-allowed;
}

/* X-Ray resolved value - Option D style (underline + tooltip) */
.xray-resolved-value {
    position: relative;
    text-decoration: underline;
    text-decoration-color: rgba(0, 212, 255, 0.6);
    text-decoration-style: wavy;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    cursor: help;
    transition: all 0.2s ease;
}

.xray-resolved-value:hover {
    background: rgba(0, 212, 255, 0.15);
    text-decoration-color: rgba(0, 212, 255, 1);
}

/* Tooltip showing original variable */
.xray-resolved-value::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #9b59b6;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
    border: 1px solid rgba(138, 43, 226, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
}

.xray-resolved-value:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

/* Type-specific underline colors */
.xray-resolved-value.string {
    text-decoration-color: rgba(240, 173, 78, 0.6);
}

.xray-resolved-value.string:hover {
    background: rgba(240, 173, 78, 0.15);
    text-decoration-color: rgba(240, 173, 78, 1);
}

.xray-resolved-value.number {
    text-decoration-color: rgba(92, 184, 92, 0.6);
}

.xray-resolved-value.number:hover {
    background: rgba(92, 184, 92, 0.15);
    text-decoration-color: rgba(92, 184, 92, 1);
}

.xray-resolved-value.array {
    text-decoration-color: rgba(255, 217, 61, 0.6);
}

.xray-resolved-value.array:hover {
    background: rgba(255, 217, 61, 0.15);
    text-decoration-color: rgba(255, 217, 61, 1);
}

/* X-Ray mode indicator on section headers */
.xray-mode-indicator {
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.7;
    animation: xrayPulse 2s ease-in-out infinite;
}

/* Content container when X-Ray is active */
.obs-comment-content.xray-active {
    border-left: 2px solid rgba(0, 212, 255, 0.3);
    padding-left: 12px;
}

/* Pending state indicator */
.xray-toggle.disabled.pending .xray-toggle-slider {
    animation: xrayPending 1.5s ease-in-out infinite;
}

@keyframes xrayPending {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}