/* ========================= */
/* RESET */
/* ========================= */

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

/* ========================= */
/* ROOT */
/* ========================= */

:root {

    --bg: #081018;
    --card: #0f1722;
    --card-2: #111c29;

    --border: rgba(255, 255, 255, 0.05);

    --text: #f5f7fa;
    --text-soft: #8fa3b8;

    --primary: #00c2ff;
    --primary-soft: rgba(0, 194, 255, 0.15);
    --surface: rgba(255, 255, 255, 0.03);

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);

    --green: #2ecc71;
    --yellow: #f1c40f;
    --red: #ff5c5c;

    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;

    --transition: 0.25s ease;
}

/* ========================= */
/* BODY */
/* ========================= */

body {
    background:
        radial-gradient(circle at top left, rgba(0, 194, 255, 0.08), transparent 30%),
        radial-gradient(circle at top right, rgba(0, 100, 255, 0.06), transparent 25%),
        var(--bg);

    color: var(--text);

    font-family:
        Inter,
        Arial,
        sans-serif;

    min-height: 100vh;

    padding: 24px;
}

/* ========================= */
/* APP LAYOUT */
/* ========================= */

.app-layout {
    display: flex;
    gap: 24px;
}

/* ========================= */
/* SIDEBAR */
/* ========================= */

.sidebar {

    width: 68px;
    min-height: calc(100vh - 48px);

    background: rgba(15, 23, 34, 0.8);

    border: 1px solid var(--border);

    border-radius: 28px;

    backdrop-filter: blur(20px);

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 20px 0;

    position: sticky;
    top: 24px;
}

.sidebar-logo {

    width: 46px;
    height: 46px;

    border-radius: 18px;

    background: var(--primary-soft);

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--primary);

    font-size: 20px;

    margin-bottom: 40px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nav-item {

    width: 52px;
    height: 52px;

    border: none;

    border-radius: 18px;

    background: transparent;

    color: var(--text-soft);

    cursor: pointer;

    transition: var(--transition);

    font-size: 18px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ========================= */
/* MAIN CONTENT */
/* ========================= */

.main-content {
    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========================= */
/* TOP HEADER */
/* ========================= */

.top-header {

    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;
}

.header-left h1 {

    font-size: 30px;
    font-weight: 700;

    margin-bottom: 8px;
}

.header-left p {

    color: var(--text-soft);

    font-size: 15px;
}

.header-right {

    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.header-status {

    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 16px;

    padding: 14px 18px;

    color: var(--text-soft);

    font-size: 14px;
}

/* ========================= */
/* HERO METRICS */
/* ========================= */

.hero-metrics {

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));

    gap: 20px;
}

.metric-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border: 1px solid rgba(255, 255, 255, 0.05);

    border-radius: var(--radius-lg);

    padding: 20px;

    transition: var(--transition);

    position: relative;

    overflow: hidden;

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        var(--shadow);
}

.metric-card::before {

    content: "";

    position: absolute;

    top: -60px;
    right: -60px;

    width: 140px;
    height: 140px;

    background:
        radial-gradient(circle,
            rgba(0, 194, 255, 0.12),
            transparent 70%);

    pointer-events: none;
}

.metric-card:hover {
    transform: translateY(-4px);
}

.metric-card h3 {

    color: var(--text-soft);

    font-size: 15px;
    font-weight: 500;

    margin-bottom: 16px;
}

.metric-card h2 {

    font-size: 24px;
    margin-bottom: 12px;
}

.metric-card p {
    color: var(--primary);
    font-size: 14px;
}

/* ========================= */
/* MAIN ANALYTICS */
/* ========================= */

.main-analytics {

    display: grid;

    grid-template-columns:
        2fr 1fr;

    gap: 20px;
}

.analytics-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border: 1px solid rgba(255, 255, 255, 0.05);

    border-radius: var(--radius-lg);

    padding: 24px;

    position: relative;

    overflow: hidden;

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        var(--shadow);
}

.analytics-card::before {

    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(120deg,
            transparent,
            rgba(255, 255, 255, 0.015),
            transparent);

    pointer-events: none;
}

.large-card {
    min-height: 390px;
}

/* ========================= */
/* CARD HEADER */
/* ========================= */

.card-header {

    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 18px;
}

/* ========================= */
/* DEVICE GRID */
/* ========================= */

.device-grid {

    display: flex;
    flex-direction: column;

    gap: 18px;

    margin-top: 20px;
}

.device-item {

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 20px 22px;

    border-radius: 18px;

    background: var(--surface);

    border:
        1px solid var(--border);

    transition:
        0.3s ease;
}

.device-item:hover {

    transform: translateY(-2px);

    border-color:
        rgba(0, 200, 255, 0.18);
}

.device-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.device-dot {

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #00ff99;

    box-shadow:
        0 0 10px #00ff99,
        0 0 20px #00ff99;
}

.device-item.off {
    opacity: 0.45;
}

.device-item.off .device-dot {

    background: #334155;

    box-shadow: none;
}

/* ========================= */
/* FEED */
/* ========================= */

.feed-card,
.tools-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border: 1px solid rgba(255, 255, 255, 0.05);

    border-radius: var(--radius-lg);

    padding: 24px;

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        var(--shadow);
}

.feed-list {

    display: flex;
    flex-direction: column;

    gap: 14px;
}

.feed-item {

    background: var(--card-2);

    border-radius: 16px;

    padding: 16px;

    color: var(--text-soft);

    border-left: 3px solid var(--primary);

    animation: fadeSlide 0.4s ease;
}

/* ========================= */
/* DATASET TOOLS */
/* ========================= */

.tools-card p {
    color: var(--text-soft);
}

/* ========================= */
/* RESPONSIVE */
/* ========================= */

@media (max-width: 1100px) {

    .main-analytics {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {

    body {
        padding: 16px;
    }

    .app-layout {
        flex-direction: column;
    }

    .sidebar {

        width: 100%;
        min-height: auto;

        flex-direction: row;

        justify-content: space-between;

        padding: 14px 20px;
    }

    .sidebar-menu {
        flex-direction: row;
    }

    .top-header {
        flex-direction: column;
    }

    .header-left h1 {
        font-size: 30px;
    }
}

canvas {
    width: 100% !important;
}

.large-card {
    height: 390px;
}

#mainChart {
    height: 300px !important;
}

.large-card canvas {
    margin-top: 10px;
}

/* ========================= */
/* DEVICE STATUS PULSE */
/* ========================= */

.device-item {

    position: relative;

    overflow: hidden;
}

.device-item::before {

    content: "";

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #00ff9d;

    position: absolute;

    left: 18px;
    top: 50%;

    transform: translateY(-50%);

    box-shadow:
        0 0 10px #00ff9d,
        0 0 20px #00ff9d;

    animation: pulse 2s infinite;
}

.device-item span {
    margin-left: 20px;
}

@keyframes pulse {

    0% {
        opacity: 0.4;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.3);
    }

    100% {
        opacity: 0.4;
        transform: translateY(-50%) scale(1);
    }
}

/* ========================= */
/* ENVIRONMENT SECTION */
/* ========================= */

.environment-section {

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));

    gap: 20px;
}

.env-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border: 1px solid rgba(255, 255, 255, 0.05);

    border-radius: var(--radius-lg);

    padding: 22px;

    display: flex;
    align-items: center;

    gap: 18px;

    transition: var(--transition);

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        var(--shadow);
}

.env-card:hover {
    transform: translateY(-4px);
}

.env-icon {

    width: 58px;
    height: 58px;

    border-radius: 18px;

    background:
        rgba(0, 194, 255, 0.12);

    color: var(--primary);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 22px;

    flex-shrink: 0;
}

.env-info span {

    color: var(--text-soft);

    font-size: 14px;
}

.env-info h3 {

    margin-top: 6px;

    font-size: 20px;
}

.env-info p {

    margin-top: 6px;

    color: var(--green);

    font-size: 14px;
}

@keyframes fadeSlide {

    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.device-item small {

    display: block;

    margin-top: 4px;

    font-size: 11px;

    letter-spacing: 1px;

    color: #00ff99;
}

/* ========================= */
/* CHART FILTERS */
/* ========================= */

.chart-filters {

    display: flex;

    gap: 10px;
}

.filter-btn {

    border: none;

    background:
        rgba(255, 255, 255, 0.04);

    color: var(--text-soft);

    padding: 10px 14px;

    border-radius: 12px;

    cursor: pointer;

    transition: 0.25s ease;

    font-size: 13px;
}

.filter-btn:hover {

    background:
        rgba(255, 255, 255, 0.08);

    color: white;
}

.filter-btn.active {

    background:
        rgba(0, 194, 255, 0.16);

    color: var(--primary);

    border:
        1px solid rgba(0, 194, 255, 0.25);
}

/* ========================= */
/* LIVE CONNECTION STATUS */
/* ========================= */

.live-status {

    display: flex;

    align-items: center;

    gap: 10px;

    color: #00ff99;
}

.status-dot {

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #00ff99;

    box-shadow:
        0 0 10px #00ff99,
        0 0 20px #00ff99;

    animation: pulseStatus 2s infinite;
}

@keyframes pulseStatus {

    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.25);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

/* ========================= */
/* TOAST NOTIFICATION */
/* ========================= */

#toastContainer {

    position: fixed;

    top: 24px;
    right: 24px;

    display: flex;
    flex-direction: column;

    gap: 14px;

    z-index: 9999;
}

.toast {

    min-width: 280px;

    padding: 18px 20px;

    border-radius: 18px;

    background: var(--card);

    border:
        1px solid rgba(255, 255, 255, 0.06);

    backdrop-filter: blur(16px);

    color: var(--text);

    box-shadow:
        var(--shadow);

    animation:
        toastSlide 0.4s ease;

    position: relative;

    overflow: hidden;
}

.toast::before {

    content: "";

    position: absolute;

    top: 0;
    left: 0;

    width: 4px;
    height: 100%;

    background: #00c2ff;
}

.toast-title {

    font-size: 14px;

    font-weight: 600;

    margin-bottom: 6px;
}

.toast-message {

    font-size: 13px;

    color: var(--text-soft);

    line-height: 1.5;
}

@keyframes toastSlide {

    from {
        opacity: 0;
        transform:
            translateX(40px);
    }

    to {
        opacity: 1;
        transform:
            translateX(0);
    }
}

/* ========================= */
/* AI INSIGHT */
/* ========================= */

.ai-card {

    background:
        linear-gradient(135deg,
            rgba(0, 194, 255, 0.10),
            rgba(155, 92, 255, 0.08));

    border:
        1px solid rgba(255, 255, 255, 0.06);

    border-radius: 24px;

    padding: 28px;

    position: relative;

    overflow: hidden;

    box-shadow:
        var(--shadow);
}

.ai-card::before {

    content: "";

    position: absolute;

    top: -80px;
    right: -80px;

    width: 180px;
    height: 180px;

    background:
        radial-gradient(circle,
            rgba(255, 255, 255, 0.08),
            transparent 70%);
}

.ai-badge {

    background:
        rgba(0, 255, 153, 0.14);

    color: #00ff99;

    padding: 8px 12px;

    border-radius: 999px;

    font-size: 12px;

    letter-spacing: 1px;
}

.ai-content {

    margin-top: 20px;
}

.ai-content h2 {

    font-size: 26px;

    margin-bottom: 14px;
}

.ai-content p {

    color: var(--text-soft);

    line-height: 1.7;

    max-width: 700px;
}

/* ========================= */
/* ANOMALY PANEL */
/* ========================= */

.anomaly-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border:
        1px solid rgba(255, 255, 255, 0.06);

    border-radius: 24px;

    padding: 24px;

    box-shadow:
        var(--shadow);
}

.anomaly-live {

    background:
        rgba(255, 92, 92, 0.12);

    color: #ff5c5c;

    padding: 8px 12px;

    border-radius: 999px;

    font-size: 12px;
}

.anomaly-list {

    display: flex;

    flex-direction: column;

    gap: 16px;

    margin-top: 20px;
}

.anomaly-item {

    background:
        rgba(255, 255, 255, 0.02);

    border:
        1px solid rgba(255, 255, 255, 0.05);

    border-left:
        4px solid #ff5c5c;

    border-radius: 18px;

    padding: 18px;

    animation:
        fadeSlide 0.4s ease;
}

.anomaly-item h4 {

    font-size: 15px;

    margin-bottom: 8px;
}

.anomaly-item p {

    color: var(--text-soft);

    font-size: 13px;

    line-height: 1.6;
}

.anomaly-severity {

    display: inline-block;

    margin-top: 12px;

    padding: 6px 10px;

    border-radius: 999px;

    font-size: 11px;

    letter-spacing: 1px;

    background:
        rgba(255, 92, 92, 0.12);

    color: #ff5c5c;
}

/* ========================= */
/* LIGHT THEME */
/* ========================= */

body.light-theme {

    --bg: #eef3f8;

    --card: #ffffff;
    --card-2: #f7fafc;

    --border:
        rgba(15, 23, 42, 0.06);

    --text: #081018;

    --text-soft: #5b6b7c;

    --primary: #009dff;

    --primary-soft:
        rgba(0, 157, 255, 0.12);

    --surface:
        rgba(15, 23, 42, 0.04);

    --shadow:
        0 10px 30px rgba(15, 23, 42, 0.08);
}

/* ========================= */
/* THEME TOGGLE */
/* ========================= */

.theme-toggle {

    width: 48px;
    height: 48px;

    border: none;

    border-radius: 16px;

    background: var(--card);

    border:
        1px solid var(--border);

    color: var(--text);

    cursor: pointer;

    transition: 0.25s ease;

    font-size: 16px;
}

.theme-toggle:hover {

    transform: translateY(-2px);

    background:
        rgba(255, 255, 255, 0.04);
}

/* ========================= */
/* SYSTEM LOGS */
/* ========================= */

.logs-card {

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.01));

    border:
        1px solid rgba(255, 255, 255, 0.05);

    border-radius: 24px;

    padding: 24px;

    box-shadow:
        var(--shadow);
}

.logs-container {

    margin-top: 20px;

    display: flex;

    flex-direction: column;

    gap: 12px;

    max-height: 320px;

    overflow-y: auto;

    padding-right: 6px;
}

.logs-container::-webkit-scrollbar {

    width: 6px;
}

.logs-container::-webkit-scrollbar-thumb {

    background:
        rgba(255, 255, 255, 0.08);

    border-radius: 999px;
}

.log-item {

    font-family:
        monospace;

    font-size: 13px;

    background:
        var(--surface);

    border:
        1px solid var(--border);

    border-radius: 14px;

    padding: 14px 16px;

    color: var(--text-soft);

    animation:
        fadeSlide 0.35s ease;
}

.log-time {

    color: var(--primary);

    margin-right: 10px;
}

/* ========================= */
/* MINI CHART */
/* ========================= */

.mini-chart {

    width: 100%;

    height: 60px !important;

    margin-top: 16px;

    opacity: 0.9;
}

/* ========================= */
/* LOADING SCREEN */
/* ========================= */

.loading-screen {

    position: fixed;

    inset: 0;

    background:
        radial-gradient(circle at top,
            rgba(0, 194, 255, 0.08),
            transparent 30%),
        var(--bg);

    display: flex;

    align-items: center;
    justify-content: center;

    z-index: 999999;

    transition:
        opacity 0.8s ease,
        visibility 0.8s ease;
}

.loading-screen.hidden {

    opacity: 0;

    visibility: hidden;
}

.loading-content {

    width: 320px;

    text-align: center;
}

.loading-logo {

    width: 72px;
    height: 72px;

    border-radius: 24px;

    background:
        var(--primary-soft);

    color: var(--primary);

    display: flex;

    align-items: center;
    justify-content: center;

    font-size: 28px;

    margin: 0 auto 24px;

    animation:
        pulseLogo 2s infinite;
}

.loading-content h2 {

    margin-bottom: 12px;

    font-size: 24px;
}

.loading-content p {

    color: var(--text-soft);

    margin-bottom: 28px;
}

.loading-bar {

    width: 100%;
    height: 10px;

    border-radius: 999px;

    background:
        rgba(255, 255, 255, 0.06);

    overflow: hidden;
}

.loading-progress {

    width: 0%;

    height: 100%;

    background:
        linear-gradient(90deg,
            #00c2ff,
            #9b5cff);

    border-radius: 999px;

    transition:
        width 0.4s ease;
}

@keyframes pulseLogo {

    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

/* ========================= */
/* DATASET GENERATOR */
/* ========================= */

.dataset-controls {

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));

    gap: 20px;

    margin-top: 24px;
}

.control-group {

    display: flex;

    flex-direction: column;

    gap: 12px;
}

.control-group label {

    font-size: 14px;

    color: var(--text-soft);
}

.control-group select,
.control-group input:not([type="range"]) {

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 14px;

    padding: 14px 16px;

    color: var(--text);

    outline: none;

    transition: 0.25s ease;
}

.control-group select option {

    background: var(--card);

    color: var(--text);
}

.control-group select:focus,
.control-group input:focus {

    border-color:
        rgba(0, 194, 255, 0.35);

    box-shadow:
        0 0 0 4px rgba(0, 194, 255, 0.08);
}

/* ACTION BUTTONS */

.dataset-actions {

    display: flex;

    gap: 14px;

    margin-top: 26px;

    flex-wrap: wrap;
}

.dataset-btn {

    border: none;

    background:
        rgba(0, 194, 255, 0.14);

    color: var(--primary);

    padding: 14px 20px;

    border-radius: 14px;

    cursor: pointer;

    transition: 0.25s ease;

    font-weight: 600;
}

.dataset-btn:hover {

    transform: translateY(-2px);

    background:
        rgba(0, 194, 255, 0.22);
}

.dataset-btn.secondary {

    background:
        rgba(255, 255, 255, 0.04);

    color: var(--text-soft);
}

/* STATUS */

.dataset-status {

    margin-top: 24px;

    display: flex;

    align-items: center;

    gap: 12px;

    color: #00ff99;

    font-size: 14px;
}

.status-indicator {

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #00ff99;

    box-shadow:
        0 0 10px #00ff99,
        0 0 20px #00ff99;

    animation:
        pulseStatus 2s infinite;
}

/* ========================= */
/* RANGE SLIDER */
/* ========================= */

input[type="range"] {

    width: 100%;

    appearance: none;

    -webkit-appearance: none;

    background: transparent;

    cursor: pointer;

    margin-top: 10px;
}

/* TRACK */

input[type="range"]::-webkit-slider-runnable-track {

    height: 8px;

    border-radius: 999px;

    background: var(--surface);

    border: 1px solid var(--border);
}

/* THUMB */

input[type="range"]::-webkit-slider-thumb {

    -webkit-appearance: none;

    width: 18px;
    height: 18px;

    border-radius: 50%;

    background: var(--primary);

    border: 2px solid rgba(255,255,255,0.15);

    margin-top: -6px;

    box-shadow:
        0 0 12px rgba(0,194,255,0.45);

    transition: 0.2s ease;
}


input[type="range"]::-webkit-slider-thumb:hover {

    transform: scale(1.08);
}