/* ═══════════════════════════════════════════════════════════════
   WCM System — Design System
   Dark theme · Glassmorphism · Neon Accents · Responsive
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
    /* Background */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);

    /* Text */
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent — Neon Green */
    --accent: #39FF14;
    --accent-dim: rgba(57, 255, 20, 0.15);
    --accent-glow: rgba(57, 255, 20, 0.3);

    /* Status */
    --status-online: #39FF14;
    --status-offline: #555;
    --status-unknown: #374151;

    /* Semantic */
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --success: #10b981;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(57, 255, 20, 0.1);

    /* Layout */
    --nav-height: 64px;
    --container-max: 1400px;
    --radius: 12px;
    --radius-sm: 8px;

    /* Transitions */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle gradient background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(57, 255, 20, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ── Navigation ────────────────────────────────────────────────── */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.navbar-brand .icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #00d4ff);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.navbar-brand h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

.navbar-links {
    display: flex;
    gap: 0.5rem;
}

.navbar-links a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.navbar-links a:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.navbar-links a.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.navbar-links a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
    padding-top: calc(var(--nav-height) + 1.5rem);
    padding-left: 2rem;
    padding-right: 2rem;
    padding-bottom: 3rem;
    max-width: var(--container-max);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ── Page Header ───────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── KPI Cards ─────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.kpi-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

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

.kpi-card .kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.kpi-card .kpi-icon.green {
    background: rgba(57, 255, 20, 0.1);
    color: var(--accent);
}

.kpi-card .kpi-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.kpi-card .kpi-icon.amber {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.kpi-card .kpi-value .unit {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.kpi-card .kpi-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

/* ── Chart Sections ────────────────────────────────────────────── */
.chart-section {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.chart-section:hover {
    border-color: var(--border-hover);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.chart-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-header h3 .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Time range filter buttons */
.time-filters {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0.2rem;
}

.time-filters button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.time-filters button:hover {
    color: var(--text-primary);
}

.time-filters button.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.chart-container {
    position: relative;
    width: 100%;
    min-height: 200px;
}

.chart-container canvas {
    width: 100% !important;
}

/* ── Config Page — Device Lists ────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    margin-left: 0.5rem;
}

/* ── Device Table ──────────────────────────────────────────────── */
.device-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.device-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.device-table td {
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.device-table tbody tr {
    transition: var(--transition);
}

.device-table tbody tr:hover {
    background: var(--bg-glass);
}

.device-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status badge */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online::before {
    background: var(--status-online);
    box-shadow: 0 0 6px var(--accent-glow);
}

.status-dot.offline::before {
    background: var(--status-offline);
}

.status-dot.unknown::before {
    background: var(--status-unknown);
}

/* Color swatch in table */
.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--border);
    display: inline-block;
    vertical-align: middle;
    cursor: pointer;
    transition: var(--transition);
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: var(--text-secondary);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #0a0e17;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #4aff28;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.modal h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ── Form Elements ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input[type="text"],
.form-group input[type="color"],
.form-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input[type="color"] {
    height: 44px;
    padding: 0.25rem;
    cursor: pointer;
}

/* ── Scan Results ──────────────────────────────────────────────── */
.scan-section {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scan-results {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
}

.scan-results::-webkit-scrollbar {
    width: 6px;
}

.scan-results::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Loading Spinner ───────────────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

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

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
}

/* ── Toast Notifications ───────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 1rem);
    right: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideInRight 0.3s ease;
    min-width: 260px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }

    .navbar-brand h1 {
        font-size: 0.95rem;
    }

    .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.5rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .device-table {
        display: block;
        overflow-x: auto;
    }

    .modal {
        width: 95%;
        padding: 1.5rem;
    }
}

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

    .navbar-links a {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .page-header h2 {
        font-size: 1.3rem;
    }
}