/* ============================================
   Giga Manager - Design System
   Dark theme for network monitoring
   ============================================ */

/* --- Design Tokens --- */
:root {
    /* Background */
    --bg-primary: #0f1117;
    --bg-secondary: #161920;
    --bg-card: #1c1f28;
    --bg-card-hover: #22262f;
    --bg-input: #1c1f28;
    --bg-header: #161920;
    --bg-sidebar: #12141b;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --bg-tooltip: #2a2e38;

    /* Accent */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-border: rgba(59, 130, 246, 0.3);

    /* Text */
    --text-primary: #e4e6eb;
    --text-secondary: #8b8fa3;
    --text-muted: #5c5f6e;
    --text-inverse: #0f1117;

    /* Status */
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.12);
    --green-border: rgba(34, 197, 94, 0.3);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.12);
    --red-border: rgba(239, 68, 68, 0.3);
    --yellow: #eab308;
    --yellow-soft: rgba(234, 179, 8, 0.12);
    --yellow-border: rgba(234, 179, 8, 0.3);
    --orange: #f97316;
    --orange-soft: rgba(249, 115, 22, 0.12);

    /* Borders */
    --border: #2a2d38;
    --border-light: #1f222b;
    --border-focus: var(--accent);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;

    /* Transition */
    --transition: 150ms ease;
    --transition-slow: 250ms ease;
}

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

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

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- Layout: Sidebar + Main --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.sidebar-brand .brand-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-brand .brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) var(--space-sm);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 var(--space-md);
    margin-bottom: var(--space-sm);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link.active svg,
.nav-link:hover svg {
    opacity: 1;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-sm);
    border-radius: var(--radius-md);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px var(--space-md);
    margin-top: var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
}

.sidebar-logout:hover {
    color: var(--red);
    background: var(--red-soft);
}

.sidebar-logout svg {
    width: 16px;
    height: 16px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.page-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-body {
    padding: var(--space-xl);
}

/* --- Mobile Toggle --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    z-index: 99;
    align-items: center;
    padding: 0 var(--space-md);
    gap: var(--space-md);
}

.mobile-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
}

.mobile-toggle:hover {
    background: var(--bg-card);
}

.mobile-toggle svg {
    width: 22px;
    height: 22px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 99;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border);
    background: var(--bg-card-hover);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.card-body p strong {
    color: var(--text-primary);
    font-weight: 500;
}

.card-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    flex-wrap: wrap;
}

/* --- Stat Cards (counters) --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--space-sm);
}

.stat-accent .stat-value { color: var(--accent); }
.stat-green .stat-value { color: var(--green); }
.stat-red .stat-value { color: var(--red); }
.stat-yellow .stat-value { color: var(--yellow); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

.btn-success {
    background: var(--green);
    color: white;
    border-color: var(--green);
}
.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

.btn-danger {
    background: var(--red);
    color: white;
    border-color: var(--red);
}
.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.btn-warning {
    background: var(--yellow);
    color: var(--text-inverse);
    border-color: var(--yellow);
}
.btn-warning:hover {
    background: #ca8a04;
    border-color: #ca8a04;
    color: var(--text-inverse);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-outline-accent {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent-border);
}
.btn-outline-accent:hover {
    background: var(--accent-soft);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-green {
    background: var(--green-soft);
    color: var(--green);
}

.badge-red {
    background: var(--red-soft);
    color: var(--red);
}

.badge-yellow {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.badge-orange {
    background: var(--orange-soft);
    color: var(--orange);
}

.badge-muted {
    background: rgba(91, 95, 110, 0.15);
    color: var(--text-secondary);
}

/* --- Status Dot --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

.dot-online { background: var(--green); box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.dot-offline { background: var(--red); }

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.table thead th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    padding: 10px var(--space-md);
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 10px var(--space-md);
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

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

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

.table tbody tr.offline-row {
    opacity: 0.55;
}

.table .text-center { text-align: center; }
.table .text-left { text-align: left; }

/* --- Signal Values --- */
.val-good { color: var(--green); }
.val-warn { color: var(--yellow); }
.val-bad { color: var(--red); }

.signal-link {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.signal-link:hover {
    text-decoration: underline solid;
}

/* --- Forms --- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Modals --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: var(--space-md);
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--accent-border);
    color: var(--accent);
}

.filter-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.search-box {
    margin-left: auto;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    width: 260px;
    max-width: 100%;
    transition: border-color var(--transition);
}

.search-box::placeholder {
    color: var(--text-muted);
}

.search-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --- PON Sections --- */
.pon-section {
    margin-bottom: var(--space-lg);
}

.pon-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
    border-bottom: 2px solid var(--accent);
    cursor: pointer;
    user-select: none;
}

.pon-header h3 {
    color: var(--accent);
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.pon-badge {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

/* --- Loading --- */
.loading-overlay {
    text-align: center;
    padding: 80px var(--space-lg);
    color: var(--text-muted);
}

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-md);
}

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

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px var(--space-lg);
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: var(--space-sm);
}

/* --- Flash Messages --- */
.flash-msg {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.flash-danger {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid var(--red-border);
}

.flash-warning {
    background: var(--yellow-soft);
    color: var(--yellow);
    border: 1px solid var(--yellow-border);
}

.flash-success {
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.flash-info {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

/* --- Chart Modal --- */
.chart-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: var(--space-md);
}

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

.chart-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    width: 720px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.chart-modal h3 {
    color: var(--text-primary);
    margin-top: 0;
    font-size: 16px;
}

.chart-modal .close-btn {
    float: right;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.chart-modal .close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* --- Info Grid (SNMP) --- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md);
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.info-card h4 {
    margin: 0 0 var(--space-sm) 0;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-card .value {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

/* --- Section Title --- */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--border);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: 56px;
    }

    .page-header {
        padding: var(--space-md);
        flex-direction: column;
        align-items: flex-start;
    }

    .page-body {
        padding: var(--space-md);
    }

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

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        margin-left: 0;
        width: 100%;
    }

    .modal {
        max-width: 100%;
        margin: var(--space-md);
    }
}

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

/* --- Utility --- */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.font-bold { font-weight: 600; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none; }

/* --- Raw Output --- */
.raw-output {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
}

/* --- Details/Summary --- */
details {
    margin-top: var(--space-lg);
}

details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    padding: var(--space-sm) 0;
}

details summary:hover {
    color: var(--text-primary);
}

/* ============================================
   MAP - Network Map Editor & List
   ============================================ */

/* Map List Page */
.map-folders-section {
  margin-bottom: 16px;
}

.map-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}

.map-folder-header svg {
  transition: transform 150ms ease;
  flex-shrink: 0;
}

.map-folder-header.collapsed svg:first-child {
  transform: rotate(-90deg);
}

.map-folder-content {
  display: flex;
  gap: 12px;
  padding-left: 22px;
  flex-wrap: wrap;
  overflow: hidden;
  transition: max-height 300ms ease;
}

.map-folder-content.collapsed {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
}

.map-card {
  width: 260px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.map-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.map-card-preview {
  height: 110px;
  background: #0a0c10;
  position: relative;
  overflow: hidden;
}

.map-card-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 12px 12px;
}

.map-card-info {
  padding: 12px;
}

.map-card-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-card-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 10px;
}

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

.map-status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
}

.map-status-badge.online {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.map-status-badge.offline {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.map-card-create {
  width: 260px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  cursor: pointer;
  transition: border-color 150ms ease;
  color: #64748b;
  font-size: 12px;
  gap: 8px;
}

.map-card-create:hover {
  border-color: rgba(59, 130, 246, 0.3);
  color: #94a3b8;
}

/* Map card 3-dot menu */
.map-card-menu {
  position: relative;
}

.map-card-menu-btn {
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: #64748b;
  transition: background 150ms;
}

.map-card-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.map-card-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #1a1d25;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  min-width: 160px;
  padding: 4px;
  z-index: 100;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.map-card-dropdown.active {
  display: block;
}

.map-card-dropdown a,
.map-card-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  color: #e2e8f0;
  font-size: 12px;
  text-align: left;
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}

.map-card-dropdown a:hover,
.map-card-dropdown button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.map-card-dropdown .danger {
  color: #ef4444;
}

/* Map Editor overrides */
.map-editor-page .main-content {
  padding: 0;
  overflow: hidden;
}

.map-editor-page footer {
  display: none;
}

/* Cytoscape node glow for offline devices */
.cy-node-offline {
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.15);
}

/* Edge pulse animation for high utilization */
@keyframes edgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Responsive: Map list */
@media (max-width: 768px) {
  .map-card {
    width: 100%;
  }

  .map-folder-content {
    padding-left: 12px;
  }

  .map-card-create {
    width: 100%;
    min-height: 120px;
  }
}

/* Responsive: Map editor */
@media (max-width: 768px) {
  .editor-sidebar {
    display: none;
  }

  .editor-properties {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-height: 50vh;
    z-index: 50;
    border-radius: 12px 12px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
}
