/* ==================== CSS Variables ==================== */

:root {
    --sidebar-width: 260px;
    --sidebar-mini-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --header-bg: #1e293b;           /* matches sidebar-bg — dark card headers */
    --header-text: #ffffff;

    /* Height variables — avoids magic numbers in HTML */
    --trap-table-max-height: calc(100vh - 450px);
    --walker-history-max-height: calc(100vh - 220px);
    --walker-results-height: calc(100vh - 180px);
    --sim-log-height: calc(100vh - 350px);
    --mib-list-max-height: 400px;
    --mib-trap-table-max-height: 600px;

    /* Input width helpers */
    --input-w-port: 70px;
    --input-w-community: 90px;
}

/* ==================== Layout Base ==================== */

body {
    font-size: 14px;
    overflow-x: hidden;
    background-color: var(--bs-body-bg);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
}

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    height: 100vh;
    overflow: hidden;
}

#page-content-wrapper {
    width: 100%;
    overflow-y: auto;
    height: 100vh;
}

/* ==================== Sidebar ==================== */

#sidebar-wrapper {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    transition: margin 0.3s ease, width 0.3s ease;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

#sidebar-wrapper .sidebar-heading {
    padding: 1.25rem 1.5rem;
    color: #fff;
    font-size: 1.1rem;
    background-color: rgba(0,0,0,0.2);
    white-space: nowrap;
    overflow: hidden;
}

#sidebar-wrapper .list-group-item {
    background-color: transparent;
    color: var(--sidebar-text);
    border: none;
    padding: 0.65rem 1.25rem;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
}

#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: #fff;
}

#sidebar-wrapper .list-group-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: #fff;
    border-left-color: var(--sidebar-active);
    font-weight: 500;
}

#sidebar-wrapper .list-group-item i {
    min-width: 28px;
    text-align: center;
    margin-right: 10px;
    font-size: 0.95rem;
}

/* ==================== Mobile Responsiveness ==================== */

@media (max-width: 768px) {
    #sidebar-wrapper {
        margin-left: calc(-1 * var(--sidebar-width));
    }
    body.sb-sidenav-toggled #sidebar-wrapper {
        margin-left: 0;
        width: var(--sidebar-width);
    }
    #page-content-wrapper {
        min-width: 100vw;
    }
}

/* ==================== Desktop Collapsed State ==================== */

@media (min-width: 769px) {
    body.sb-sidenav-toggled #sidebar-wrapper {
        width: var(--sidebar-mini-width);
    }
    body.sb-sidenav-toggled #sidebar-wrapper .sidebar-heading span,
    body.sb-sidenav-toggled #sidebar-wrapper .list-group-item span,
    body.sb-sidenav-toggled #sidebar-wrapper #app-version {
        display: none;
    }
    body.sb-sidenav-toggled #sidebar-wrapper .sidebar-heading {
        text-align: center;
        padding: 1.25rem 0;
    }
    body.sb-sidenav-toggled #sidebar-wrapper .list-group-item {
        padding: 0.65rem 0;
        justify-content: center;
    }
    body.sb-sidenav-toggled #sidebar-wrapper .list-group-item i {
        margin-right: 0;
    }
}

/* ==================== Components & Utils ==================== */

.cursor-pointer { cursor: pointer; }

pre {
    background: #212529;
    color: #f8f9fa;
    border-radius: 4px;
}

/* ==================== Cards ==================== */

.card {
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.card-bordered {
    border: 1px solid #cbd5e1 !important;
}

.card-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    min-height: 44px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-header .badge {
    background-color: rgba(255,255,255,0.15) !important;
    color: #fff !important;
}
.card-header code {
    background-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
    padding: 1px 5px;
    border-radius: 3px;
}
.card-header .text-muted {
    color: #94a3b8 !important;
}
.card-header .btn-close {
    filter: invert(1);
}

/* ==================== Dashboard Tool Cards ==================== */

.tool-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    height: 100%;
    border: 1px solid #cbd5e1;
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 12px -3px rgba(0, 0, 0, 0.12);
    border-color: var(--sidebar-active);
}

.tool-card:focus {
    outline: 2px solid var(--sidebar-active);
    outline-offset: 2px;
}

.tool-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

/* ==================== Unified Button Sizes ==================== */

.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.4;
}
.btn-sm,
.btn-group-sm > .btn {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* ==================== Trap VarBind List ==================== */

.varbind-list {
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.varbind-list::-webkit-scrollbar { width: 4px; }
.varbind-list::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 2px; }

/* ==================== Badges ==================== */

.badge.bg-success { background-color: #10b981 !important; }
.badge.bg-danger  { background-color: #ef4444 !important; }
.badge.bg-warning { background-color: #f59e0b !important; color: #000 !important; }

.badge { font-weight: 500; padding: 0.25em 0.6em; }

/* ==================== Input Width Helpers ==================== */

.input-w-port      { width: var(--input-w-port); }
.input-w-community { width: var(--input-w-community); }

/* ==================== Tables ==================== */

.table-wrapper {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.table-dense {
    font-size: 0.8125rem;
}

.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #fff;
}

#trap-table-body tr   { vertical-align: middle; }
#trap-table-body td   { padding: 0.5rem 0.75rem; word-wrap: break-word; overflow-wrap: break-word; }

#tr-table-body tr { vertical-align: middle; }
#tr-table-body td { padding: 0.5rem 0.75rem; overflow: hidden; text-overflow: ellipsis; }

/* Trap receiver column widths */
.trap-receiver-table { table-layout: fixed; }

.trap-receiver-table th:nth-child(1),
.trap-receiver-table td:nth-child(1) { width: 140px; }

.trap-receiver-table th:nth-child(2),
.trap-receiver-table td:nth-child(2) { width: 150px; }

.trap-receiver-table th:nth-child(3),
.trap-receiver-table td:nth-child(3) { width: 130px; }

.trap-receiver-table th:nth-child(4),
.trap-receiver-table td:nth-child(4) { width: auto; min-width: 200px; }

.trap-receiver-table th:nth-child(5),
.trap-receiver-table td:nth-child(5) { width: 90px; text-align: center; }

.trap-receiver-table code {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* MIB Manager trap table */
.mib-trap-table { table-layout: fixed; width: 100%; }

.mib-trap-table th,
.mib-trap-table td { padding: 0.5rem 0.75rem; vertical-align: middle; }

.mib-trap-table td:nth-child(1),
.mib-trap-table td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mib-trap-table td:nth-child(5) { white-space: nowrap; overflow: visible; }

.mib-trap-table .btn-group { display: inline-flex; }

/* ==================== MIB Browser ==================== */

.bg-purple   { background-color: #8b5cf6 !important; }
.text-purple { color: #8b5cf6 !important; }

.tool-icon.bg-purple { background-color: rgba(139, 92, 246, 0.1) !important; }

.tree-node { position: relative; user-select: none; }

.tree-node-content {
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border-radius: 4px;
    margin: 1px 0;
    padding: 0.5rem 0.75rem;
}

.tree-node-content:hover { background-color: #f1f5f9; }

.tree-node-content.bg-primary {
    background-color: #3b82f6 !important;
    color: white !important;
}

.tree-node-content.bg-primary:hover { background-color: #2563eb !important; }

.tree-node-content.bg-primary code,
.tree-node-content.bg-primary .badge {
    color: #e0e7ff !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.tree-node-name    { font-size: 0.85rem; font-weight: 500; }

.tree-expand-icon {
    cursor: pointer;
    transition: transform 0.2s;
    color: #64748b;
}

.tree-expand-icon:hover { color: #3b82f6; }

.tree-children { border-left: 1px dashed #cbd5e0; margin-left: 10px; }
.tree-module   { margin-bottom: 8px; }

/* Search results */
.search-result-item {
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
    padding: 0.5rem 0.75rem;
}

.search-result-item:hover {
    background-color: #f8fafc !important;
    border-left-color: #3b82f6;
}

.search-result-item.bg-primary {
    background-color: #3b82f6 !important;
    color: white !important;
    border-left-color: #1e40af;
}

.search-result-item.bg-primary code,
.search-result-item.bg-primary .badge {
    color: #e0e7ff !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Details panel */
#browser-details-panel { font-size: 0.9rem; }

#browser-details-panel code {
    background-color: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
}

#browser-details-panel table td { padding: 0.5rem 0.75rem; vertical-align: middle; }

/* Breadcrumb */
.breadcrumb {
    background-color: #f8fafc;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.breadcrumb-item {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb-item a          { text-decoration: none; color: #3b82f6; }
.breadcrumb-item a:hover    { text-decoration: underline; }
.breadcrumb-item.active     { font-weight: 600; color: #1e293b; }

/* Scrollbars */
#browser-tree-container::-webkit-scrollbar,
#browser-details-panel::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#browser-tree-container::-webkit-scrollbar-track,
#browser-details-panel::-webkit-scrollbar-track { background: #f1f5f9; }

#browser-tree-container::-webkit-scrollbar-thumb,
#browser-details-panel::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

#browser-tree-container::-webkit-scrollbar-thumb:hover,
#browser-details-panel::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

#browser-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-label.small { margin-bottom: 0.25rem; color: #64748b; }

/* ==================== Tree Controls ==================== */

#tree-controls {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 4px;
}

#expand-depth-select {
    border-right: none;
    background-color: rgba(255,255,255,0.1);
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    border-color: rgba(255,255,255,0.2);
}

#expand-depth-select option {
    background-color: #1e293b;
    color: #fff;
}

#expand-depth-select:focus {
    box-shadow: none;
    border-color: rgba(255,255,255,0.4);
    background-color: rgba(255,255,255,0.15);
}

#btn-expand {
    font-weight: 500;
    min-width: 90px;
}

#btn-expand:disabled { cursor: not-allowed; opacity: 0.6; }

#tree-controls .btn-outline-secondary:hover { background-color: #6c757d; color: white; }

#tree-controls button,
#tree-controls select { transition: all 0.2s ease; }

/* ==================== Walk Result Empty State ==================== */

#walk-output.walk-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
}

/* ==================== Received Traps Section Header ==================== */
.section-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    min-height: 44px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: calc(0.375rem - 1px) calc(0.375rem - 1px) 0 0; 
}

.section-header .badge {
    background-color: rgba(255,255,255,0.15) !important;
    color: #fff !important;
}

.section-header .form-control,
.section-header .form-select {
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #fff;
}

.section-header .form-control::placeholder {
    color: rgba(255,255,255,0.5);
}

.section-header .form-control:focus,
.section-header .form-select:focus {
    background-color: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    box-shadow: none;
    color: #fff;
}

/* ==================== Dark Mode Overrides ==================== */
[data-bs-theme="dark"] .card, 
[data-bs-theme="dark"] .tool-card,
[data-bs-theme="dark"] .card-bordered {
    border-color: #334155 !important;
    background-color: #1e293b;
}

[data-bs-theme="dark"] .bg-light {
    background-color: rgba(255,255,255,0.05) !important;
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: #1e293b;
    --bs-table-color: #f8fafc;
}
[data-bs-theme="dark"] .table {
    --bs-table-color: #cbd5e1;
}
[data-bs-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}
[data-bs-theme="dark"] #wrapper .bg-white {
    background-color: #1e293b !important;
}
[data-bs-theme="dark"] .list-group-item {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
[data-bs-theme="dark"] .modal-content {
    background-color: #1e293b;
    border-color: #334155;
}
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #334155;
}
[data-bs-theme="dark"] .form-control {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-bs-theme="dark"] .form-control:focus {
    background-color: #0f172a;
    color: #e2e8f0;
}
[data-bs-theme="dark"] #browser-details-panel code {
    background-color: #0f172a;
    color: #f8fafc;
}
