/* ===================================================================
   gur.al — Network Operations Dashboard
   Single-viewport NOC interface · cool-gray palette · Space Grotesk
   Hex palette: #0F1115 #1A1D23 #2D3139 #3A3F47 #6B7280 #9CA3AF #E5E7EB
                #3B82F6 #10B981 #252830 #4B5563
   Fonts: Space Grotesk (Inter as fallback), Space Mono
   =================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
}

body {
    font-family: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
    background: #0F1115;
    color: #9CA3AF;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;

    display: grid;
    grid-template-rows: 48px 1fr 32px;
    grid-template-columns: 3fr 6fr 3fr;
    grid-template-areas:
        "top top top"
        "left center right"
        "bottom bottom bottom";
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ===================================================================
   TOP BAR
   =================================================================== */

.top-bar {
    grid-area: top;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #2D3139;
    background: #0F1115;
    position: relative;
}

.top-bar::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 64px;
    height: 1px;
    background: #3B82F6;
    opacity: 0.6;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wordmark-glyph {
    color: #3B82F6;
    font-size: 14px;
    line-height: 1;
    font-weight: 700;
    transform: translateY(-1px);
}

.wordmark-text {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    color: #E5E7EB;
}

.wordmark-divider {
    width: 1px;
    height: 14px;
    background: #2D3139;
}

.wordmark-meta {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6B7280;
    font-weight: 500;
}

.top-bar-meta {
    display: flex;
    align-items: center;
    gap: 24px;
}

.region-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9CA3AF;
    font-weight: 500;
}

.region-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    animation: status-pulse 2.4s ease-in-out infinite;
}

.region-label {
    color: #9CA3AF;
}

.uptime-counter {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding-left: 24px;
    border-left: 1px solid #2D3139;
}

.uptime-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6B7280;
    font-weight: 500;
}

.uptime-value {
    font-family: "Space Mono", "Space Grotesk", monospace;
    font-size: 12px;
    color: #E5E7EB;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

/* ===================================================================
   PANELS — shared
   =================================================================== */

.panel {
    background: #0F1115;
    display: flex;
    flex-direction: column;
    border-color: #2D3139;
    border-style: solid;
    overflow: hidden;
    min-height: 0;
}

.panel-left {
    grid-area: left;
    border-right: 1px solid #2D3139;
}

.panel-center {
    grid-area: center;
    border-right: 1px solid #2D3139;
    background: #0F1115;
}

.panel-right {
    grid-area: right;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #2D3139;
    flex-shrink: 0;
    background: #0F1115;
}

.panel-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9CA3AF;
    font-weight: 700;
}

.panel-meta {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6B7280;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.panel-footer {
    border-top: 1px solid #2D3139;
    padding: 10px 18px;
    flex-shrink: 0;
    background: #0F1115;
}

.panel-footer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6B7280;
}

.legend-label {
    color: #6B7280;
    font-weight: 500;
}

.legend-swatch {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
}

.legend-idle {
    background: #4B5563;
}

.legend-active {
    background: #9CA3AF;
}

.legend-edge {
    background: #3B82F6;
}

/* ===================================================================
   LEFT PANEL — NETWORK TOPOLOGY
   =================================================================== */

.topology-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(to right, rgba(45, 49, 57, 0.45) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(to bottom, rgba(45, 49, 57, 0.45) 1px, transparent 1px) 0 0 / 32px 32px,
        radial-gradient(ellipse at center, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
    padding: 14px;
    min-height: 0;
}

.topology-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.topology-svg .edge {
    stroke: #2D3139;
    stroke-width: 1;
    fill: none;
}

.topology-svg .edge-active {
    stroke: #3B82F6;
    stroke-width: 1.2;
    opacity: 0.6;
}

.topology-svg .node {
    fill: #6B7280;
    stroke: #2D3139;
    stroke-width: 0.5;
    transform-origin: center;
    transform-box: fill-box;
    animation: node-breathe 4s ease-in-out infinite;
}

.topology-svg .node:nth-child(2n) {
    fill: #4B5563;
    animation-duration: 5s;
}

.topology-svg .node:nth-child(3n) {
    animation-delay: -1.3s;
    animation-duration: 4.6s;
}

.topology-svg .node:nth-child(5n) {
    animation-delay: -2.7s;
    animation-duration: 5.4s;
}

.topology-svg .node:nth-child(7n) {
    animation-delay: -3.4s;
    animation-duration: 3.6s;
}

.topology-svg .node.pulse {
    animation: node-pulse 1.5s ease-out forwards;
}

.topology-svg .pulse-ring {
    fill: none;
    stroke: #3B82F6;
    stroke-width: 1;
    opacity: 0;
    transform-origin: center;
    transform-box: fill-box;
}

.topology-svg .pulse-ring.firing {
    animation: ring-expand 1.5s ease-out forwards;
}

@keyframes node-breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

@keyframes node-pulse {
    0% {
        fill: #6B7280;
        r: 3;
    }
    25% {
        fill: #3B82F6;
        r: 5;
        opacity: 1;
    }
    100% {
        fill: #6B7280;
        r: 3;
        opacity: 1;
    }
}

@keyframes ring-expand {
    0% {
        opacity: 0.7;
        r: 4;
        stroke-width: 1.4;
    }
    100% {
        opacity: 0;
        r: 22;
        stroke-width: 0.6;
    }
}

@keyframes status-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12); }
    50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.04); }
}

/* ===================================================================
   CENTER PANEL — METRIC CARDS
   =================================================================== */

.metrics-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0;
    min-height: 0;
}

.metric-card {
    position: relative;
    background: #1A1D23;
    border-right: 1px solid #2D3139;
    border-bottom: 1px solid #2D3139;
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: default;
    transition:
        background 200ms ease-out,
        border-color 200ms ease-out,
        transform 200ms ease-out;
    transform-origin: center;
    will-change: transform;
}

.metric-card:nth-child(3n) {
    border-right: none;
}

.metric-card:nth-child(n+4) {
    border-bottom: none;
}

.metric-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 1px;
    background: #2D3139;
    transition: background 200ms ease-out, width 220ms ease-out;
}

.metric-card:hover {
    background: #252830;
    border-color: #3B82F6;
    transform: scale(1.03);
    z-index: 2;
    box-shadow: 0 0 0 1px #3B82F6;
}

.metric-card:hover::before {
    background: #3B82F6;
    width: 36px;
}

.metric-card:hover .metric-label {
    color: #E5E7EB;
}

.metric-card:hover .metric-icon {
    color: #3B82F6;
}

.metric-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-icon {
    color: #6B7280;
    display: inline-flex;
    transition: color 200ms ease-out;
}

.metric-icon svg {
    display: block;
}

.metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9CA3AF;
    font-weight: 700;
    transition: color 200ms ease-out;
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
}

.metric-value {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 300;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    color: #E5E7EB;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.metric-unit {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 400;
    font-size: 12px;
    color: #6B7280;
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.metric-spark {
    margin-top: auto;
    padding-top: 4px;
    height: 36px;
    display: flex;
    align-items: flex-end;
}

.metric-spark svg {
    display: block;
    width: 100%;
    height: 32px;
}

.spark-line {
    fill: none;
    stroke: #3B82F6;
    stroke-width: 1.5;
    stroke-linecap: square;
    stroke-linejoin: miter;
    opacity: 0.85;
}

.spark-fill {
    fill: rgba(59, 130, 246, 0.10);
    stroke: none;
}

.metric-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
}

.metric-delta-good {
    color: #10B981;
}

.metric-delta-flat {
    color: #6B7280;
}

.metric-foot-label {
    color: #6B7280;
}

/* ===================================================================
   RIGHT PANEL — EVENT LOG
   =================================================================== */

.log-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    animation: log-pulse 1.6s ease-in-out infinite;
}

@keyframes log-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.log-status-text {
    color: #9CA3AF;
}

.event-log {
    flex: 1;
    list-style: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    margin: 0;
    scroll-behavior: smooth;
    min-height: 0;
}

.event-log::-webkit-scrollbar {
    width: 6px;
}

.event-log::-webkit-scrollbar-track {
    background: #0F1115;
}

.event-log::-webkit-scrollbar-thumb {
    background: #2D3139;
}

.event-log::-webkit-scrollbar-thumb:hover {
    background: #3A3F47;
}

.log-entry {
    font-family: "Space Mono", "Space Grotesk", monospace;
    font-weight: 400;
    font-size: 11.5px;
    line-height: 1.5;
    color: #6B7280;
    padding: 5px 18px;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 8px;
    align-items: baseline;
    border-bottom: 1px dashed transparent;
    animation: log-fade-in 400ms ease-out forwards;
    white-space: nowrap;
    overflow: hidden;
}

.log-entry:hover {
    background: #1A1D23;
}

.log-entry-time {
    color: #4B5563;
    font-variant-numeric: tabular-nums;
    font-size: 11px;
}

.log-entry-tag {
    color: #9CA3AF;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 4px;
    border: 1px solid #2D3139;
    line-height: 1.2;
    transform: translateY(-1px);
}

.log-entry.is-info .log-entry-tag {
    color: #9CA3AF;
}

.log-entry.is-route .log-entry-tag {
    color: #3B82F6;
    border-color: rgba(59, 130, 246, 0.4);
}

.log-entry.is-tls .log-entry-tag {
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.4);
}

.log-entry.is-warn .log-entry-tag {
    color: #E5E7EB;
}

.log-entry-text {
    color: #9CA3AF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-entry-text .lemma {
    color: #E5E7EB;
}

.log-entry-text .arrow {
    color: #4B5563;
    margin: 0 4px;
}

@keyframes log-fade-in {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-footer {
    justify-content: flex-start;
}

.footer-mini-label {
    color: #6B7280;
    font-weight: 500;
}

.footer-mini-value {
    color: #9CA3AF;
    font-family: "Space Mono", monospace;
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
}

.footer-mini-divider {
    width: 1px;
    height: 10px;
    background: #2D3139;
}

/* ===================================================================
   BOTTOM BAR
   =================================================================== */

.bottom-bar {
    grid-area: bottom;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-top: 1px solid #2D3139;
    background: #0F1115;
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 28px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot-ok {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    animation: status-pulse 2.4s ease-in-out infinite;
}

.status-item:nth-child(2) .status-dot-ok {
    animation-delay: -0.6s;
}

.status-item:nth-child(3) .status-dot-ok {
    animation-delay: -1.2s;
}

.status-label {
    color: #6B7280;
}

.status-value {
    color: #9CA3AF;
    font-weight: 500;
}

.bottom-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
    color: #6B7280;
}

.bottom-meta-build {
    color: #9CA3AF;
    font-family: "Space Mono", monospace;
    font-size: 10.5px;
}

.bottom-meta-divider {
    width: 1px;
    height: 10px;
    background: #2D3139;
}

.bottom-meta-copy {
    color: #6B7280;
}

/* ===================================================================
   RESPONSIVE — collapse to vertical stack below 1024px
   =================================================================== */

@media (max-width: 1023px) {
    body {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .top-bar,
    .bottom-bar {
        flex-shrink: 0;
        height: auto;
        min-height: 48px;
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .bottom-bar {
        min-height: 48px;
    }

    .panel-left,
    .panel-center,
    .panel-right {
        border-right: none;
        border-bottom: 1px solid #2D3139;
        min-height: 60vh;
    }

    .topology-container {
        min-height: 320px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, minmax(160px, auto));
    }

    .metric-card:nth-child(3n) {
        border-right: 1px solid #2D3139;
    }

    .metric-card:nth-child(2n) {
        border-right: none;
    }

    .metric-card:nth-child(n+4) {
        border-bottom: 1px solid #2D3139;
    }

    .metric-card:nth-child(n+5) {
        border-bottom: none;
    }

    .status-indicators {
        gap: 14px;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, minmax(140px, auto));
    }

    .metric-card {
        border-right: none !important;
        border-bottom: 1px solid #2D3139 !important;
    }

    .metric-card:last-child {
        border-bottom: none !important;
    }

    .top-bar-meta {
        gap: 12px;
    }

    .uptime-counter {
        padding-left: 12px;
    }
}
