/* supplychain.watch - Dreamy Dopamine Supply Chain Monitoring */
/* Colors: #1a1a2e (deep base), #4a90d9 (primary blue), #f5f0e8 (warm off-white), #e8b84b (accent gold), #6c757d (muted gray) */
/* Font: Inter */

:root {
    --color-base: #1a1a2e;
    --color-primary: #4a90d9;
    --color-offwhite: #f5f0e8;
    --color-accent: #e8b84b;
    --color-muted: #6c757d;
    --color-critical: #e05555;
    --color-success: #4ecb71;
    --sidebar-width: 260px;
    --frost-bg: rgba(245, 240, 232, 0.12);
    --frost-border: rgba(245, 240, 232, 0.08);
    --frost-blur: 16px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-base);
    color: var(--color-offwhite);
    display: flex;
    position: relative;
}

/* Noise overlay */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.98) 0%, rgba(26, 26, 46, 0.95) 100%);
    border-right: 1px solid rgba(74, 144, 217, 0.12);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, var(--color-primary), var(--color-accent), transparent);
    opacity: 0.3;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(245, 240, 232, 0.06);
}

.brand-icon {
    flex-shrink: 0;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--color-offwhite);
}

.brand-dot {
    color: var(--color-accent);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(74, 144, 217, 0.08);
    color: var(--color-offwhite);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.15), rgba(232, 184, 75, 0.08));
    color: var(--color-offwhite);
    box-shadow: 0 0 20px rgba(74, 144, 217, 0.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.alert-badge {
    margin-left: auto;
    background: var(--color-critical);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    line-height: 1.3;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(245, 240, 232, 0.06);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    flex-shrink: 0;
}

.status-dot.pulse {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(78, 203, 113, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(78, 203, 113, 0); }
}

.status-text {
    font-size: 12px;
    color: var(--color-muted);
    font-weight: 400;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: radial-gradient(ellipse at 20% 0%, rgba(74, 144, 217, 0.06) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 100%, rgba(232, 184, 75, 0.04) 0%, transparent 60%),
                var(--color-base);
    padding: 0 28px 28px;
}

/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin: 0 -28px;
    padding-left: 28px;
    padding-right: 28px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--color-offwhite), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.last-updated {
    font-size: 13px;
    color: var(--color-muted);
}

.refresh-btn {
    background: rgba(74, 144, 217, 0.1);
    border: 1px solid rgba(74, 144, 217, 0.2);
    color: var(--color-primary);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(74, 144, 217, 0.2);
    transform: rotate(45deg);
}

.refresh-btn.spinning svg {
    animation: spin 0.6s ease-in-out;
}

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

/* ===== FROST PANEL ===== */
.frost-panel {
    background: var(--frost-bg);
    backdrop-filter: blur(var(--frost-blur));
    -webkit-backdrop-filter: blur(var(--frost-blur));
    border: 1px solid var(--frost-border);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== HOVER LIFT ===== */
.hover-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 30px rgba(74, 144, 217, 0.08);
}

/* ===== KPI ROW ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.kpi-card {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kpi-card:hover::before {
    opacity: 1;
}

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

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
}

.kpi-trend {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

.kpi-trend.up {
    color: var(--color-success);
    background: rgba(78, 203, 113, 0.1);
}

.kpi-trend.down {
    color: var(--color-primary);
    background: rgba(74, 144, 217, 0.1);
}

.kpi-trend.neutral {
    color: var(--color-muted);
    background: rgba(108, 117, 125, 0.1);
}

.kpi-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--color-offwhite);
    line-height: 1.1;
    margin-bottom: 12px;
}

.kpi-sparkline {
    height: 32px;
    margin-bottom: 8px;
}

.kpi-sparkline svg {
    width: 100%;
    height: 100%;
}

.kpi-footer {
    font-size: 12px;
    color: var(--color-muted);
}

/* ===== FLOW SECTION ===== */
.flow-section {
    margin-bottom: 20px;
}

.flow-panel {
    padding: 24px;
}

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

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-offwhite);
}

.panel-actions {
    display: flex;
    gap: 4px;
    background: rgba(26, 26, 46, 0.5);
    padding: 3px;
    border-radius: 10px;
}

.panel-btn {
    background: none;
    border: none;
    color: var(--color-muted);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-btn:hover {
    color: var(--color-offwhite);
}

.panel-btn.active {
    background: rgba(74, 144, 217, 0.2);
    color: var(--color-primary);
}

.flow-canvas {
    height: 300px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(26, 26, 46, 0.3);
}

/* ===== BOTTOM GRID ===== */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.alerts-panel,
.activity-panel {
    padding: 24px;
}

.badge-count {
    background: var(--color-critical);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
}

.view-all-link {
    font-size: 13px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.view-all-link:hover {
    opacity: 0.7;
}

/* ===== ALERT ITEMS ===== */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(26, 26, 46, 0.4);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.alert-item:hover {
    background: rgba(26, 26, 46, 0.6);
}

.alert-warning {
    border-color: rgba(232, 184, 75, 0.15);
}

.alert-critical {
    border-color: rgba(224, 85, 85, 0.15);
}

.alert-info {
    border-color: rgba(74, 144, 217, 0.15);
}

.alert-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-offwhite);
    margin-bottom: 4px;
}

.alert-desc {
    font-size: 12px;
    color: var(--color-muted);
    margin-bottom: 4px;
    line-height: 1.4;
}

.alert-time {
    font-size: 11px;
    color: rgba(108, 117, 125, 0.7);
}

/* ===== ACTIVITY LIST ===== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.activity-item:hover {
    background: rgba(26, 26, 46, 0.4);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.activity-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.activity-text {
    font-size: 13px;
    color: var(--color-offwhite);
    line-height: 1.4;
}

.activity-text strong {
    color: var(--color-primary);
    font-weight: 600;
}

.activity-time {
    font-size: 11px;
    color: rgba(108, 117, 125, 0.7);
}

/* ===== SVG FLOW NODES ===== */
.flow-node {
    cursor: pointer;
}

.flow-node circle {
    transition: all 0.3s ease;
}

.flow-node:hover circle {
    filter: brightness(1.3);
}

.flow-node text {
    font-family: 'Inter', sans-serif;
    fill: var(--color-offwhite);
}

.flow-connection {
    stroke-dasharray: 6 3;
    animation: flowDash 20s linear infinite;
}

@keyframes flowDash {
    to { stroke-dashoffset: -100; }
}

/* ===== SPARKLINE ===== */
.sparkline-path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-area {
    opacity: 0.1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 0 16px 16px;
    }
}

@media (max-width: 600px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 26px;
    }

    .page-title {
        font-size: 18px;
    }

    .top-bar {
        padding-left: 16px;
        padding-right: 16px;
        margin: 0 -16px;
    }
}

/* ===== KPI CARD DOPAMINE ACCENTS ===== */
.kpi-card[data-metric="shipments"] .kpi-value {
    background: linear-gradient(135deg, var(--color-primary), #6cb3f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-card[data-metric="ontime"] .kpi-value {
    background: linear-gradient(135deg, var(--color-accent), #f0d078);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-card[data-metric="suppliers"] .kpi-value {
    background: linear-gradient(135deg, var(--color-success), #8de8a4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-card[data-metric="risk"] .kpi-value {
    background: linear-gradient(135deg, #e05555, #f09090);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== GRADIENT HALO EFFECTS ===== */
.kpi-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-primary), transparent);
    opacity: 0.04;
    pointer-events: none;
}

.kpi-card[data-metric="ontime"]::after {
    background: radial-gradient(circle, var(--color-accent), transparent);
}

.kpi-card[data-metric="suppliers"]::after {
    background: radial-gradient(circle, var(--color-success), transparent);
}

.kpi-card[data-metric="risk"]::after {
    background: radial-gradient(circle, var(--color-critical), transparent);
}

/* ===== SCROLLBAR ===== */
.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: rgba(108, 117, 125, 0.3);
    border-radius: 3px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 117, 125, 0.5);
}

/* ===== ENTRY ANIMATIONS ===== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card {
    animation: fadeSlideUp 0.5s ease-out both;
}

.kpi-card:nth-child(1) { animation-delay: 0.1s; }
.kpi-card:nth-child(2) { animation-delay: 0.2s; }
.kpi-card:nth-child(3) { animation-delay: 0.3s; }
.kpi-card:nth-child(4) { animation-delay: 0.4s; }

.flow-panel {
    animation: fadeSlideUp 0.5s ease-out 0.3s both;
}

.alerts-panel {
    animation: fadeSlideUp 0.5s ease-out 0.5s both;
}

.activity-panel {
    animation: fadeSlideUp 0.5s ease-out 0.6s both;
}
