/* ============================================
   BinSoft Guides — Dashboard Components
   GPU-accelerated: transform, opacity, filter
   will-change sparingly, contain where possible
   ============================================ */

/* --- Ambient Background (CSS-only, GPU: transform + opacity) --- */
.bg-ambient {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background:
        radial-gradient(ellipse 600px 600px at 20% 30%, rgba(212,175,55,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 500px 500px at 80% 60%, rgba(173,198,255,0.04) 0%, transparent 70%),
        radial-gradient(ellipse 400px 400px at 50% 80%, rgba(215,197,255,0.03) 0%, transparent 70%);
}
.bg-ambient::before,
.bg-ambient::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    pointer-events: none;
}
.bg-ambient::before {
    width: 800px; height: 800px;
    top: -200px; left: -200px;
    background: radial-gradient(circle, rgba(212,175,55,0.04) 0%, transparent 70%);
    animation: ambient-float-1 25s ease-in-out infinite;
}
.bg-ambient::after {
    width: 600px; height: 600px;
    bottom: -150px; right: -150px;
    background: radial-gradient(circle, rgba(173,198,255,0.03) 0%, transparent 70%);
    animation: ambient-float-2 30s ease-in-out infinite;
}
@keyframes ambient-float-1 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(100px, 80px); }
    66% { transform: translate(-50px, 120px); }
}
@keyframes ambient-float-2 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-80px, -60px); }
    66% { transform: translate(60px, -100px); }
}
[data-theme="light"] .bg-ambient { display: none; }

/* --- Terminal Simulator --- */
.terminal {
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-xl);
    overflow: hidden;
    contain: layout;
}

.terminal__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface-container);
    border-bottom: 1px solid rgba(77, 70, 53, 0.15);
}

.terminal__dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    /* GPU: no animation on these, just static */
}

.terminal__dot--red { background: #ff5f57; }
.terminal__dot--yellow { background: #febc2e; }
.terminal__dot--green { background: #28c840; }

.terminal__title {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--on-surface-variant);
    margin-left: 0.5rem;
}

.terminal__body {
    padding: 1rem 1.25rem;
    height: 320px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.8;
    /* Hide scrollbar */
    scrollbar-width: none;
}
.terminal__body::-webkit-scrollbar { display: none; }

/* Terminal lines — GPU animated entrance */
.term-line {
    will-change: transform, opacity;
    contain: content;
}

.term-cmd { color: var(--primary); font-weight: 600; }
.term-out { color: var(--on-surface-variant); }
.term-success { color: var(--success); font-weight: 600; }
.term-agent { color: var(--secondary); }

/* --- Activity Feed --- */
.activity-feed {
    background: var(--surface-container-low);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    contain: layout;
}

.feed-entry {
    display: grid;
    grid-template-columns: 8px 110px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid rgba(77, 70, 53, 0.08);
    font-size: 0.8125rem;
    will-change: transform, opacity;
    contain: content;
}

.feed-entry:last-child { border-bottom: none; }

.feed-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.feed-agent {
    font-family: var(--font-label);
    font-weight: 700;
    font-size: 0.75rem;
    white-space: nowrap;
}

.feed-msg {
    color: var(--on-surface-variant);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-time {
    font-size: 0.6875rem;
    color: rgba(218, 226, 253, 0.3);
    white-space: nowrap;
    font-family: var(--font-mono);
}

/* --- Orchestration Diagram --- */
.orch-container {
    position: relative;
    padding: 2rem 0;
}

.orch-grid {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.orch-node {
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1rem;
    text-align: center;
    min-width: 120px;
    /* GPU: start invisible, animate with transform */
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.5s ease;
    contain: content;
}

.orch-node--lider {
    background: var(--surface-container-high);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.15);
}

.orch-node__icon {
    font-size: 1.5rem;
    margin-bottom: 0.375rem;
}

.orch-node__name {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.orch-status {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--on-surface-variant);
    transition: opacity 0.3s ease, color 0.3s ease;
}

/* Connection lines (CSS, GPU-friendly) */
.orch-lines {
    position: absolute;
    top: 50%; left: 50%;
    width: 80%; height: 2px;
    transform: translate(-50%, -50%);
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.15), transparent);
    z-index: -1;
}

/* --- Progress Bars (GPU: scaleX) --- */
.progress-section {
    contain: layout;
}

.progress-item {
    margin-bottom: 1.25rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.progress-label__name {
    font-weight: 600;
    color: var(--on-surface);
}

.progress-label__value {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--primary);
}

.progress-track {
    height: 6px;
    background: var(--surface-container);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.progress-fill--gold { background: linear-gradient(90deg, var(--primary-container), var(--primary)); }
.progress-fill--blue { background: linear-gradient(90deg, #1d4ed8, var(--secondary)); }
.progress-fill--green { background: linear-gradient(90deg, #16a34a, var(--success)); }
.progress-fill--purple { background: linear-gradient(90deg, #7c3aed, var(--tertiary)); }
.progress-fill--red { background: linear-gradient(90deg, #dc2626, var(--error)); }

/* --- Server Status --- */
.status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(77, 70, 53, 0.08);
}

.status-row:last-child { border-bottom: none; }

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    /* GPU pulse */
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.status-dot--ok { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.status-dot--warn { background: #eab308; box-shadow: 0 0 8px rgba(234, 179, 8, 0.4); }

.status-name {
    font-weight: 600;
    font-size: 0.875rem;
    min-width: 160px;
}

.status-detail {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--on-surface-variant);
}

/* --- Dashboard Grid Layout --- */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.dash-card {
    background: var(--surface-container-low);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    border: 1px solid rgba(77, 70, 53, 0.1);
}

.dash-card__title {
    font-family: var(--font-label);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--on-surface-variant);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dash-card__title .material-symbols-outlined {
    font-size: 16px;
    color: var(--primary);
}

/* --- Stat Counters --- */
.stats-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 1.5rem 2rem;
    background: var(--surface-container-low);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(77, 70, 53, 0.1);
    min-width: 140px;
}

.stat-number {
    font-family: var(--font-headline);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-family: var(--font-label);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--on-surface-variant);
}

/* --- Git Graph Timeline (poziomy) --- */
.git-graph {
    position: relative;
    height: 170px;
    padding: 10px 0;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: var(--radius-xl);
    background: var(--surface-container-lowest);
    border: 1px solid rgba(77, 70, 53, 0.15);
    scrollbar-width: thin;
    scrollbar-color: var(--surface-container-high) transparent;
}
.git-graph::-webkit-scrollbar { height: 4px; }
.git-graph::-webkit-scrollbar-track { background: transparent; }
.git-graph::-webkit-scrollbar-thumb { background: var(--surface-container-high); border-radius: 4px; }

/* Glowna linia (main branch) */
.git-graph__main {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--primary) 5%, var(--primary) 95%, transparent 100%);
    transform: translateY(-50%);
    z-index: 1;
}

/* Commit node na main */
.git-graph__commit {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    will-change: transform, opacity;
}

.git-graph__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--surface-container-lowest);
    z-index: 3;
}

.git-graph__dot--filled {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.git-graph__dot--agent {
    width: 10px;
    height: 10px;
    border-width: 2px;
}

/* Branch line (od main do agenta) */
.git-graph__branch {
    position: absolute;
    z-index: 2;
    will-change: transform, opacity;
}

.git-graph__branch-line {
    position: absolute;
    border-radius: 4px;
}

/* Label pod commitem */
.git-graph__label {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 4;
    will-change: transform, opacity;
}

/* Agent badge na branchu */
.git-graph__agent {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-label);
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    will-change: transform, opacity;
}

/* Merge indicator */
.git-graph__merge {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.5rem;
    font-family: var(--font-mono);
    color: var(--success);
    z-index: 4;
    white-space: nowrap;
}

/* --- CSS Animations (GPU-native, zero JS) --- */

/* Terminal linie — fade in staggered */
.term-anim {
    opacity: 0;
    transform: translateY(8px);
    animation: term-fade-in 0.4s ease forwards;
}
@keyframes term-fade-in {
    to { opacity: 1; transform: translateY(0); }
}

/* Activity feed wejście */
.feed-enter {
    animation: feed-slide-in 0.4s ease forwards;
}
@keyframes feed-slide-in {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Git graph — elementy fade in */
.git-anim {
    opacity: 0;
    animation: git-node-in 0.8s ease forwards;
}
@keyframes git-node-in {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}

/* Git graph — SVG path rysowanie */
.git-path-anim {
    animation: git-draw-path 1s ease forwards;
}
@keyframes git-draw-path {
    to { stroke-dashoffset: 0; }
}

/* --- Responsive --- */
@media (max-width: 1399px) {
    .dash-grid { grid-template-columns: 1fr; }
    .feed-entry { grid-template-columns: 8px 90px 1fr auto; }
}

@media (max-width: 767px) {
    .stats-row { gap: 0.75rem; }
    .stat-item { min-width: 100px; padding: 1rem; }
    .stat-number { font-size: 1.75rem; }
    .terminal__body { height: 240px; font-size: 0.75rem; }
    .orch-grid { gap: 0.75rem; }
    .orch-node { min-width: 90px; padding: 0.75rem; }
}
