/* =============================================
   NetSight AI — Dark Theme Custom CSS
   ============================================= */

:root {
    --ns-primary: #6366f1;
    --ns-primary-dark: #4f46e5;
    --ns-bg-deep: #0a0a12;
    --ns-bg-base: #0f0f1a;
    --ns-bg-card: #141428;
    --ns-bg-card-hover: #1a1a32;
    --ns-bg-elevated: #1e1e38;
    --ns-border: rgba(255, 255, 255, 0.08);
    --ns-border-hover: rgba(255, 255, 255, 0.15);
    --ns-text: #e2e8f0;
    --ns-text-muted: #94a3b8;
    --ns-sidebar-width: 240px;
    --ns-sidebar-collapsed: 60px;
    --ns-topbar-height: 52px;
    --ns-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--ns-bg-base);
    color: var(--ns-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
}

a { color: var(--ns-primary); text-decoration: none; }
a:hover { color: #818cf8; }

/* === Layout === */
#app-wrapper {
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--ns-sidebar-width);
    min-height: 100vh;
    background: var(--ns-bg-deep);
    border-right: 1px solid var(--ns-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width var(--ns-transition);
    flex-shrink: 0;
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--ns-sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-footer .avatar-circle ~ div,
.sidebar.collapsed .sidebar-footer a[href="/logout"],
.sidebar.collapsed .px-3.py-2 {
    display: none !important;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.65rem;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar-brand {
    height: 60px;
    transition: all var(--ns-transition);
}

.sidebar-divider {
    border-color: var(--ns-border);
    opacity: 1;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--ns-text-muted);
    text-transform: uppercase;
}

.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    color: var(--ns-text-muted);
    border-radius: 8px;
    margin: 2px 8px;
    transition: all var(--ns-transition);
    font-size: 0.875rem;
    white-space: nowrap;
}

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

.sidebar-link.active {
    color: var(--ns-primary);
    background: rgba(99, 102, 241, 0.12);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    background: var(--ns-bg-deep);
}

/* === Top Bar === */
.topbar {
    height: var(--ns-topbar-height);
    background: var(--ns-bg-deep);
    border-bottom: 1px solid var(--ns-border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

/* === Main Content === */
.main-content {
    min-width: 0;
    background: var(--ns-bg-base);
}

.page-content {
    overflow: auto;
}

/* === Cards === */
.ns-card {
    background: var(--ns-bg-card);
    border: 1px solid var(--ns-border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color var(--ns-transition);
}

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

.ns-card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--ns-border);
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    background: rgba(255,255,255,0.02);
}

.ns-card-body {
    padding: 1.25rem;
}

/* === Stat Cards === */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--ns-bg-card);
    border: 1px solid var(--ns-border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all var(--ns-transition);
}

.stat-card:hover {
    border-color: var(--ns-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--ns-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Small stat cards */
.stat-card-sm {
    padding: 0.875rem;
    border-radius: 10px;
}
.stat-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.stat-value-sm {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}
.stat-label-sm {
    font-size: 0.68rem;
    color: var(--ns-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Tables === */
.ns-table {
    color: var(--ns-text);
    font-size: 0.875rem;
}

.ns-table thead th {
    background: rgba(255,255,255,0.03);
    color: var(--ns-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--ns-border);
    padding: 0.7rem 1rem;
    white-space: nowrap;
}

.ns-table tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}

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

.ns-table tbody tr:hover td {
    background: rgba(255,255,255,0.03);
}

/* === Buttons === */
.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ns-text-muted);
    transition: all var(--ns-transition);
}

.btn-ghost:hover {
    background: var(--ns-bg-elevated);
    border-color: var(--ns-border);
    color: var(--ns-text);
}

/* === Forms === */
.form-control,
.form-select {
    background: var(--ns-bg-deep);
    border: 1px solid var(--ns-border);
    color: var(--ns-text);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color var(--ns-transition), box-shadow var(--ns-transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--ns-bg-deep);
    border-color: var(--ns-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    color: var(--ns-text);
}

.form-control::placeholder { color: rgba(148, 163, 184, 0.5); }

.form-label {
    font-size: 0.8rem;
    color: var(--ns-text-muted);
    margin-bottom: 0.4rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--ns-text-muted);
    margin-top: 0.35rem;
}

/* === Modals === */
.ns-modal {
    background: var(--ns-bg-card);
    border: 1px solid var(--ns-border);
    border-radius: 16px;
    color: var(--ns-text);
}

.ns-modal .modal-header {
    border-bottom: 1px solid var(--ns-border);
    background: rgba(255,255,255,0.02);
}

.ns-modal .modal-footer {
    border-top: 1px solid var(--ns-border);
}

/* === Avatar === */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ns-primary), #4f46e5);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-circle.avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
}

.avatar-circle.avatar-xs {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
}

/* === Project Cards === */
.project-card {
    transition: all var(--ns-transition);
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    border-color: rgba(99, 102, 241, 0.3);
}

.project-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.mini-stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed var(--ns-border);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--ns-transition);
    background: rgba(99, 102, 241, 0.02);
}

.upload-zone:hover {
    border-color: var(--ns-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.dragging {
    border-color: var(--ns-primary);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* === Code Block === */
.code-block {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--ns-border);
    border-radius: 6px;
    padding: 0.6rem 0.875rem;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: #a5f3fc;
    white-space: pre-wrap;
    margin: 0;
}

/* === Limit Cards === */
.limit-card {
    background: var(--ns-bg-elevated);
    border: 1px solid var(--ns-border);
}

/* === Breadcrumb === */
.breadcrumb-item { font-size: 0.8rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--ns-text-muted); }
.breadcrumb-item a { color: var(--ns-text-muted); }
.breadcrumb-item a:hover { color: var(--ns-primary); }
.breadcrumb-item.active { color: var(--ns-text); }

/* === Badges === */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
}

/* === Dropdowns === */
.dropdown-menu {
    background: var(--ns-bg-elevated);
    border: 1px solid var(--ns-border);
    border-radius: 10px;
    padding: 0.4rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    color: var(--ns-text);
    transition: background var(--ns-transition);
}

.dropdown-item:hover {
    background: var(--ns-bg-card);
    color: var(--ns-text);
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
    border-color: var(--ns-border);
}

/* === Alerts === */
.alert {
    border-radius: 10px;
    font-size: 0.875rem;
    border: 1px solid;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ns-card, .stat-card {
    animation: fadeIn 0.3s ease both;
}

/* === Responsive === */
@media (max-width: 768px) {
    :root {
        --ns-sidebar-width: 0px;
    }
    .sidebar {
        position: fixed;
        width: 240px;
        transform: translateX(-100%);
        transition: transform var(--ns-transition);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .page-content {
        padding: 1rem !important;
    }
}

/* === Utility === */
.font-monospace { font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace !important; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Bootstrap overrides for dark theme */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(255,255,255,0.04);
}

[data-bs-theme="dark"] .modal-content {
    background: var(--ns-bg-card);
    border-color: var(--ns-border);
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.5;
}
[data-bs-theme="dark"] .btn-close:hover { opacity: 1; }

[data-bs-theme="dark"] .vr {
    background: var(--ns-border);
    opacity: 1;
}

/* Spinner */
.spinner-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
