/* bada.systems - Dashboard Analytics Dark */
/* Palette: #111827, #1f2937, #374151, #3b82f6, #10b981, #f59e0b, #ef4444, #f3f4f6, #9ca3af */

:root {
    --bg: #111827;
    --surface: #1f2937;
    --border: #374151;
    --blue: #3b82f6;
    --blue-bright: #60a5fa;
    --green: #10b981;
    --amber: #f59e0b;
    --red: #ef4444;
    --text: #f3f4f6;
    --text-sec: #9ca3af;
    --grid-line: rgba(31, 41, 55, 0.5);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================
   HEADER
   ============================ */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    z-index: 10;
}

.hb-brand {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text);
}

.hb-datetime {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-sec);
}

.hb-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--green);
    letter-spacing: 0.05em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-sec);
    display: inline-block;
}

.status-dot.online {
    background: var(--green);
    animation: pulse 2s ease-in-out infinite;
}

.dot-green-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot-amber-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); display: inline-block; }
.dot-red-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }

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

/* Animated data flow line in header */
.data-flow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: repeating-linear-gradient(90deg, transparent, transparent 8px, var(--blue) 8px, var(--blue) 16px);
    background-size: 200% 100%;
    opacity: 0.25;
    animation: flowScroll 4s linear infinite;
}

@keyframes flowScroll {
    0% { background-position: 0 0; }
    100% { background-position: -200% 0; }
}

/* ============================
   DASHBOARD GRID
   ============================ */
.dashboard {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    padding: 16px;
    flex: 1;
    overflow: hidden;
}

/* ============================
   WIDGETS
   ============================ */
.widget {
    background: var(--surface);
    border: 1px solid transparent;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.4s ease, transform 0.4s ease;
    position: relative;
    overflow: hidden;
}

/* Border draw animation */
.widget::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 0.6s ease-out;
    pointer-events: none;
    z-index: 1;
}

.widget.active {
    opacity: 1;
    transform: scale(1);
}

.widget.active::before {
    clip-path: inset(0 0 0 0);
}

.widget.bordered {
    border-color: var(--border);
}

.widget-4 { grid-column: span 4; }
.widget-6 { grid-column: span 6; }
.widget-8 { grid-column: span 8; }

.widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* Drag handle: two rows of three dots */
.drag-handle {
    display: inline-grid;
    grid-template-columns: repeat(3, 4px);
    grid-template-rows: repeat(2, 4px);
    gap: 2px;
}

.drag-handle::before,
.drag-handle::after {
    content: '';
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-sec);
    box-shadow: 6px 0 0 var(--text-sec), 12px 0 0 var(--text-sec);
}

.widget-title {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-sec);
}

.widget-meta {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-sec);
}

.widget-body {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================
   METRIC WIDGETS
   ============================ */
.metric-widget {
    position: relative;
}

.metric-row {
    display: flex;
    align-items: baseline;
}

.metric-number {
    font-weight: 700;
    font-size: 48px;
    font-variant-numeric: tabular-nums;
    color: var(--blue);
    line-height: 1;
}

.metric-unit {
    font-weight: 700;
    font-size: 48px;
    color: var(--blue);
    line-height: 1;
}

.metric-warn { color: var(--amber); }

.metric-change {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    margin-top: 4px;
}

.metric-change.positive { color: var(--green); }
.metric-change.negative { color: var(--red); }

.alert-indicators {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* ============================
   SPARKLINES
   ============================ */
.sparkline {
    width: 100%;
    height: 30px;
    margin-top: auto;
}

.spark-line {
    fill: none;
    stroke: var(--blue);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.2s ease-out;
}

.spark-line.drawn {
    stroke-dashoffset: 0;
}

.spark-green { stroke: var(--green); }

/* ============================
   BAR CHART
   ============================ */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100%;
    padding-bottom: 20px;
    position: relative;
}

.bar {
    flex: 1;
    background: var(--blue);
    border-radius: 2px 2px 0 0;
    height: 0;
    transition: height 1.5s ease-out, background 0.2s ease;
    position: relative;
    min-width: 0;
    cursor: default;
}

.bar:hover {
    background: var(--blue-bright);
}

.bar-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-sec);
}

/* ============================
   RING GAUGE
   ============================ */
.gauge-body {
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: 16px;
}

.ring-gauge {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.ring-bg-inner { stroke-width: 6; }
.ring-bg-inner2 { stroke-width: 5; }

.ring-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.5s ease-out;
}

.ring-blue { stroke: var(--blue); stroke-width: 8; }
.ring-green { stroke: var(--green); stroke-width: 6; }
.ring-amber { stroke: var(--amber); stroke-width: 5; }

.gauge-labels {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gl-item {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-sec);
}

.gl-blue::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-right: 6px; }
.gl-green::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; }
.gl-amber::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-right: 6px; }

/* ============================
   DATA TABLE
   ============================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    color: var(--text-sec);
    letter-spacing: 0.05em;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 5px 8px;
    color: var(--text);
    border-bottom: 1px solid var(--grid-line);
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg);
}

/* ============================
   EVENT LIST
   ============================ */
.event-list {
    list-style: none;
    overflow-y: auto;
}

.event-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid var(--grid-line);
    font-size: 12px;
}

.event-list li.new-event {
    animation: eventFlash 0.6s ease-out;
}

@keyframes eventFlash {
    0% { background: rgba(59, 130, 246, 0.15); }
    100% { background: transparent; }
}

.ev-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-sec);
    flex-shrink: 0;
}

.ev-msg {
    flex: 1;
    color: var(--text);
}

/* ============================
   STATUS BAR FOOTER
   ============================ */
.status-bar {
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 32px;
    padding: 0 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-sec);
    flex-shrink: 0;
}

.sb-item strong {
    color: var(--text);
    font-weight: 600;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .widget-4, .widget-6, .widget-8 { grid-column: span 1; }
    body { overflow: auto; height: auto; }
    .status-bar { flex-wrap: wrap; height: auto; padding: 0.5rem 1rem; gap: 1rem; }
}
