/* ============================================================
   PowerOrchestrator - Custom Styles
   Beyond Bootstrap / inline styles
   ============================================================ */

/* ----- Stage Flow Visualization (horizontal pipeline) ----- */

.stage-flow {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 1.5rem 0;
}

.stage-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 120px;
}

.stage-node-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border: 3px solid;
    transition: all 0.3s;
}

.stage-node-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stage-connector {
    flex: 1;
    height: 3px;
    min-width: 40px;
    background: var(--border-color);
    position: relative;
}

.stage-connector.completed {
    background: #22c55e;
}

.stage-connector.active {
    background: linear-gradient(90deg, #22c55e, #6366f1);
    animation: pulse-line 1.5s infinite;
}

/* Stage node color modifiers */

.stage-node.completed .stage-node-circle {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.stage-node.running .stage-node-circle {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    animation: pulse-glow 1.5s infinite;
}

.stage-node.retrying .stage-node-circle {
    border-color: #eab308;
    color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.stage-node.failed .stage-node-circle {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.stage-node.pending .stage-node-circle {
    border-color: var(--border-color);
    color: var(--text-muted);
}

.stage-node.skipped .stage-node-circle {
    border-color: var(--border-color);
    color: var(--text-muted);
    opacity: 0.5;
}

/* ----- Audit Timeline (vertical) ----- */

.audit-timeline {
    position: relative;
    padding-left: 2rem;
}

.audit-timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-event {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -1.625rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-card, #1e1e2e);
}

.timeline-event.event-started::before {
    border-color: #3b82f6;
    background: #3b82f6;
}

.timeline-event.event-completed::before {
    border-color: #22c55e;
    background: #22c55e;
}

.timeline-event.event-failed::before {
    border-color: #ef4444;
    background: #ef4444;
}

/* ----- JSON Viewer ----- */

.json-viewer {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    overflow: auto;
    max-height: 400px;
    padding: 1rem;
    white-space: pre-wrap;
}

.json-key {
    color: #93c5fd;
}

.json-string {
    color: #86efac;
}

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #c084fc;
}

.json-null {
    color: #94a3b8;
}

/* ----- Pipeline Status Badges ----- */

.badge-CREATED {
    background: #6366f1;
}

.badge-VALIDATED {
    background: #8b5cf6;
}

.badge-RUNNING {
    background: #3b82f6;
}

.badge-WAITING_DEPENDENCY {
    background: #f59e0b;
}

.badge-WAITING_APPROVAL {
    background: #f97316;
}

.badge-STAGE_FAILED {
    background: #ef4444;
}

.badge-RETRYING {
    background: #eab308;
}

.badge-COMPLETED {
    background: #22c55e;
}

.badge-FAILED {
    background: #ef4444;
}

.badge-COMPENSATED {
    background: #8b5cf6;
}

.badge-ARCHIVED {
    background: #64748b;
}

.badge-PENDING {
    background: #64748b;
}

.badge-POLLING {
    background: #3b82f6;
}

.badge-SKIPPED {
    background: #475569;
}

/* ----- Health Indicators ----- */

.health-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.health-up {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.health-degraded {
    background: #eab308;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.5);
}

.health-unreachable {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* ----- Animations ----- */

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(59, 130, 246, 0.2);
    }
}

@keyframes pulse-line {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

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

/* ----- Accordion overrides (dark theme) ----- */

.accordion-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.accordion-button {
    background-color: var(--bg-dark);
    color: var(--text-primary, #e2e8f0);
    box-shadow: none;
}

.accordion-button:not(.collapsed) {
    background-color: var(--bg-card);
    color: var(--text-primary, #e2e8f0);
    box-shadow: none;
}

.accordion-button::after {
    filter: invert(1);
}

/* ----- Misc ----- */

.font-monospace {
    font-family: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

.cursor-pointer {
    cursor: pointer;
}

/* ============================================================
   PLANNING RESULTS DASHBOARD
   ============================================================ */

/* ----- Score Summary ----- */

.results-score-card .card-header {
    border-bottom: 2px solid #6366f1;
}

.results-metric {
    text-align: center;
    padding: 1rem;
    border-radius: 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.results-metric-icon {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.results-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.results-metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.results-score-feasible {
    border-color: #22c55e !important;
}

.results-score-feasible .results-metric-icon,
.results-score-feasible .results-metric-value {
    color: #22c55e;
}

.results-score-infeasible {
    border-color: #ef4444 !important;
}

.results-score-infeasible .results-metric-icon,
.results-score-infeasible .results-metric-value {
    color: #ef4444;
}

/* ----- Common Results Table ----- */

.results-table {
    font-size: 0.875rem;
}

.results-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem;
    white-space: nowrap;
}

.results-table tbody td {
    padding: 0.625rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.results-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* ----- Series Badge ----- */

.results-series-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ----- Mini Bars (forecast sparkline) ----- */

.results-mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 32px;
}

.results-mini-bar {
    width: 6px;
    background: linear-gradient(to top, #3b82f6, #93c5fd);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    transition: height 0.3s ease;
}

.results-mini-bar:hover {
    background: linear-gradient(to top, #6366f1, #c4b5fd);
}

/* ----- Pills (key-value badges) ----- */

.results-pill {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(99, 102, 241, 0.3);
    margin: 0.1rem;
    white-space: nowrap;
}

.results-pill-success {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
    margin: 0.1rem;
    white-space: nowrap;
}

.results-pill-muted {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
    margin: 0.1rem;
    white-space: nowrap;
}

/* ----- Priority Badge ----- */

.results-priority-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ----- Planning Assignment Table ----- */

.results-planning-table tbody td {
    padding: 0.375rem 0.5rem;
}

.results-entity-cell {
    min-width: 140px;
}

.results-entity-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #e2e8f0;
}

.results-entity-id {
    font-size: 0.7rem;
}

.results-entity-id code {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.results-assignment-cell {
    padding: 0.5rem 0.625rem;
    border-radius: 0.375rem;
    min-width: 120px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.results-assignment-cell:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.results-assignment-value {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.3;
}

.results-assignment-id {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ----- Legend ----- */

.results-legend {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.results-legend-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.results-legend-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 0.25rem;
}

.results-legend-item {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ----- AI Content (validation & briefing) ----- */

.results-ai-content {
    line-height: 1.7;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.results-ai-content h3,
.results-ai-content h4,
.results-ai-content h5 {
    color: #e2e8f0;
    font-weight: 600;
}

.results-ai-content strong {
    color: #f1f5f9;
}

.results-ai-content ul.results-list {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.results-ai-content li {
    margin-bottom: 0.25rem;
}

.results-ai-content code {
    background: rgba(99, 102, 241, 0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    color: #c4b5fd;
    font-size: 0.85em;
}

/* ----- Results Dashboard Section Separator ----- */

.results-dashboard > .card {
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.results-dashboard > .card > .card-header {
    background: var(--bg-card);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

/* ----- Key-Value Display (business-readable metadata) ----- */

.results-kv {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    height: 100%;
}

.results-kv-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.results-kv-value {
    font-size: 0.875rem;
    color: #e2e8f0;
    font-weight: 500;
    word-break: break-word;
}

.results-kv-value code {
    font-size: 0.8rem;
    color: #93c5fd;
}

/* ----- AI Bullet Points ----- */

.results-bullet {
    padding: 0.25rem 0 0.25rem 0.5rem;
    border-left: 2px solid var(--border-color);
    margin: 0.25rem 0;
    color: #cbd5e1;
    font-size: 0.9rem;
}

.results-bullet .bi-dot {
    color: #6366f1;
    font-size: 1.2rem;
    vertical-align: middle;
}

/* ----- Responsive ----- */

@media (max-width: 768px) {
    .results-assignment-cell {
        min-width: 90px;
    }
    .results-legend {
        flex-direction: column;
    }
    .results-metric-value {
        font-size: 1.25rem;
    }
}
