/**
 * RAGNAROK OODA Loop Visualization Styles v2
 * Includes: Interactive Animation + Comparative View
 */

/* =====================================================================
   RAGNAROK SECTION LAYOUT (index.html integration)
   ===================================================================== */

#ragnarok-section {
    min-height: 600px;
}

.ragnarok-section-header {
    padding: 24px 24px 0;
}

.ragnarok-section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent, #00ff88);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.ragnarok-section-title svg { stroke: var(--accent, #00ff88); }

.ragnarok-section-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 32px;
}

/* =====================================================================
   CONTAINER
   ===================================================================== */

.ragnarok-container {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
}

.ragnarok-container[data-mode="compare"] {
    max-width: 1100px;
}

.ragnarok-empty {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 16px;
}

/* =====================================================================
   CONTROLS (tab view)
   ===================================================================== */

.ragnarok-controls {
    margin-bottom: 24px;
}

.ragnarok-mode-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px;
    width: fit-content;
    margin-bottom: 16px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover { color: #fff; }

.mode-btn.active {
    background: var(--accent, #00ff88);
    color: #000;
}

.ragnarok-selectors {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.selector-group {
    flex: 1;
    min-width: 200px;
}

.selector-group label {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.selector-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.selector-group select:focus {
    outline: none;
    border-color: var(--accent, #00ff88);
}

/* =====================================================================
   ANIMATED OODA LOOP
   ===================================================================== */

.ragnarok-animated {
    margin-bottom: 32px;
}

.animated-loop-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    margin-bottom: 20px;
}

.loop-ring {
    position: relative;
    width: 260px;
    height: 260px;
}

.loop-segment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: 0 100%;
    overflow: hidden;
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.loop-segment.active {
    opacity: 1;
}

.loop-segment.completed {
    opacity: 0.6;
}

.segment-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 0deg,
        var(--color) 0%,
        var(--color) var(--pct),
        transparent var(--pct),
        transparent 100%
    );
    transform: rotate(calc(var(--angle) - 90deg));
    border-radius: 50%;
    opacity: 0.3;
}

.loop-segment.active .segment-fill {
    opacity: 0.7;
    animation: segment-pulse 1s ease-in-out infinite;
}

@keyframes segment-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.9; }
}

.segment-label {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    white-space: nowrap;
}

.segment-icon { font-size: 16px; display: block; }
.segment-name { font-size: 10px; color: rgba(255,255,255,0.7); display: block; }
.segment-time { font-size: 11px; font-weight: 700; color: #fff; font-family: 'JetBrains Mono', monospace; display: block; }

.loop-center {
    text-align: center;
    min-width: 120px;
}

.loop-total-time {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent, #00ff88);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    line-height: 1;
    transition: color 0.3s;
}

.loop-total-label {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.loop-play-btn {
    margin-top: 16px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.2), rgba(0, 200, 100, 0.1));
    border: 1px solid var(--accent, #00ff88);
    color: var(--accent, #00ff88);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.loop-play-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.3), rgba(0, 200, 100, 0.2));
    transform: translateY(-1px);
}

/* Progress Bar */
.animated-progress-bar {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px 20px;
}

.progress-track {
    position: relative;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00bcd4, #ff9800, #e91e63, #4caf50);
    background-size: 400% 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-phases {
    position: relative;
    height: 20px;
}

.phase-marker {
    position: absolute;
    transform: translateX(-50%);
    font-size: 9px;
    color: rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.3);
    padding: 2px 4px;
    border-radius: 2px;
}

.elapsed-display {
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    font-family: 'JetBrains Mono', monospace;
}

.elapsed-display span {
    color: var(--accent, #00ff88);
    font-weight: 700;
}

/* Phase Indicator */
.phase-indicator {
    text-align: center;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    margin-top: 12px;
}

.phase-indicator-text {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
}

/* =====================================================================
   SUMMARY STATS
   ===================================================================== */

.ragnarok-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.summary-stat {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.summary-stat.warning .stat-value { color: #ff9800; }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent, #00ff88);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* =====================================================================
   TIMELINE
   ===================================================================== */

.ragnarok-timeline {
    position: relative;
    padding-left: 40px;
}

.timeline-stage {
    position: relative;
    padding-bottom: 32px;
}

.timeline-stage:last-child { padding-bottom: 0; }

.stage-connector {
    position: absolute;
    left: -40px;
    top: 0;
}

.connector-line {
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent, #00ff88), rgba(255, 255, 255, 0.2));
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.stage-node {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent, #00ff88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
    transition: all 0.3s ease;
}

.stage-node.active {
    animation: node-pulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.7);
}

.stage-node.completed {
    background: rgba(0, 255, 136, 0.5);
}

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

.stage-icon { font-size: 18px; }
.stage-time { font-size: 9px; font-weight: 700; color: #000; font-family: 'JetBrains Mono', monospace; }

.stage-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
    margin-left: 8px;
}

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stage-name { font-size: 18px; font-weight: 600; color: #fff; }

.stage-phase {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent, #00ff88);
    background: rgba(0, 255, 136, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.stage-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin-bottom: 16px;
}

.stage-actors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.actor-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.actor-icon { font-size: 14px; }

.stage-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.metric-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-key {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

/* =====================================================================
   BOTTLENECK ANALYSIS
   ===================================================================== */

.ragnarok-bottlenecks {
    margin-top: 32px;
    background: rgba(255, 152, 0, 0.05);
    border: 1px solid rgba(255, 152, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
}

.bottleneck-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #ff9800;
    margin-bottom: 16px;
}

.bottleneck-header svg { stroke: #ff9800; }

.bottleneck-list { display: flex; flex-direction: column; gap: 12px; }

.bottleneck-item {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #ff9800;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
}

.bottleneck-item.severity-critical { border-left-color: #f44336; background: rgba(244, 67, 54, 0.1); }
.bottleneck-item.severity-high { border-left-color: #ff9800; background: rgba(255, 152, 0, 0.08); }
.bottleneck-item.severity-medium { border-left-color: #ffc107; background: rgba(255, 193, 7, 0.08); }

.bottleneck-phase { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

.phase-badge {
    font-size: 10px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.bottleneck-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'JetBrains Mono', monospace;
}

.bottleneck-issue { font-size: 13px; color: rgba(255, 255, 255, 0.9); margin-bottom: 6px; }

.bottleneck-recommendation { font-size: 12px; color: rgba(255, 255, 255, 0.6); }
.bottleneck-recommendation strong { color: var(--accent, #00ff88); }

/* =====================================================================
   COMPARATIVE VIEW
   ===================================================================== */

.compare-header {
    text-align: center;
    margin-bottom: 32px;
}

.compare-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent, #00ff88);
}

.compare-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

.compare-scenarios {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.compare-scenario {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
}

.compare-scenario-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

.compare-scenario-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
}

.compare-stat-label { color: rgba(255, 255, 255, 0.5); }
.compare-stat-value { color: #fff; font-family: 'JetBrains Mono', monospace; font-weight: 600; }

.compare-vs {
    font-size: 20px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
}

.scenario-a { border-color: rgba(0, 188, 212, 0.3); }
.scenario-b { border-color: rgba(156, 39, 176, 0.3); }

/* Delta */
.compare-delta {
    background: rgba(0, 255, 136, 0.05);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.delta-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent, #00ff88);
    margin-bottom: 12px;
}

.delta-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.delta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.delta-phase {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

.delta-value {
    font-size: 16px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.delta-positive { color: #4caf50; }
.delta-negative { color: #f44336; }

/* Comparative timelines */
.compare-timelines {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    margin-bottom: 24px;
}

.compare-side-by-side { display: flex; flex-direction: column; gap: 8px; }

.compare-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
}

.compare-cell {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px;
}

.cell-header {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.cell-duration {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-cell.delta {
    background: transparent;
    padding: 8px;
    text-align: center;
}

.delta-badge {
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.delta-badge.delta-positive { color: #4caf50; }
.delta-badge.delta-negative { color: #f44336; }

/* =====================================================================
   INCIDENT CARD BUTTON
   ===================================================================== */

.ragnarok-btn, .ragnarok-action-btn {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.2), rgba(0, 200, 100, 0.1));
    border: 1px solid var(--accent, #00ff88);
    color: var(--accent, #00ff88);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ragnarok-btn:hover, .ragnarok-action-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.3), rgba(0, 200, 100, 0.2));
    transform: translateY(-1px);
}

/* =====================================================================
   MODAL
   ===================================================================== */

.ragnarok-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ragnarok-modal-content {
    background: #0a0a0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    max-width: 800px;
    max-width: 1100px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.ragnarok-modal-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.ragnarok-modal-close:hover { background: rgba(255, 255, 255, 0.2); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 768px) {
    .ragnarok-summary { grid-template-columns: repeat(2, 1fr); }
    .animated-loop-container { flex-direction: column; gap: 16px; }
    .loop-ring { width: 200px; height: 200px; }
    .loop-total-time { font-size: 36px; }
    .compare-scenarios { grid-template-columns: 1fr; }
    .compare-vs { display: none; }
    .compare-timelines { grid-template-columns: 1fr; }
    .ragnarok-timeline { padding-left: 30px; }
    .stage-connector { left: -30px; }
    .stage-node { width: 40px; height: 40px; }
}
