:root {
    --sidebar-width: 220px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-bright: #f1f5f9;
}

body {
    min-height: 100vh;
    background-color: #f1f5f9;
    font-family: system-ui, -apple-system, sans-serif;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.75rem;
}

.sidebar-nav .nav-label {
    padding: 1rem 0.75rem 0.4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    font-weight: 700;
}

.sidebar-nav .nav-link {
    padding: 0.5rem 0.75rem;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: 6px;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text-bright);
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active);
    color: #fff;
}

.sidebar-nav .nav-link .bi {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    opacity: 0.7;
}

.sidebar-nav .nav-link.active .bi {
    opacity: 1;
}

.sidebar-nav .nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    font-weight: 500;
}

.sidebar-nav .nav-link.active .nav-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--sidebar-text);
    font-size: 0.85rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background-color: #475569;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #cbd5e1;
    font-weight: 600;
}

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

.sidebar-user-name {
    color: var(--sidebar-text-bright);
    font-weight: 500;
    font-size: 0.85rem;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: #64748b;
}

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

/* ── Top bar ── */
.topbar {
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* ── Content area ── */
.content-area {
    padding: 1.5rem 1.75rem;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.toolbar-search {
    position: relative;
    width: 280px;
}

.toolbar-search .form-control {
    padding-left: 2.25rem;
    border-radius: 8px;
    border-color: #e2e8f0;
    font-size: 0.85rem;
    background-color: #fff;
}

.toolbar-search .bi-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
}

.toolbar-filters {
    display: flex;
    gap: 0.5rem;
}

.btn-filter {
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
}

.btn-filter:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* ── Data table ── */
.data-table {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.data-table .table {
    margin: 0;
}

.data-table .table thead th {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    font-weight: 600;
    padding: 0.7rem 1rem;
    white-space: nowrap;
}

.data-table .table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

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

.data-table .table tbody tr:hover {
    background-color: #f8fafc;
}

.row-title {
    font-weight: 600;
    color: #0f172a;
}

.row-meta {
    font-size: 0.8rem;
    color: #64748b;
}

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

.status-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-dot.active {
    color: #16a34a;
}

.status-dot.active::before {
    background-color: #22c55e;
}

.status-dot.inactive {
    color: #dc2626;
}

.status-dot.inactive::before {
    background-color: #ef4444;
}

/* ── Difficulty ── */
.difficulty-pill {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-weight: 500;
}

.difficulty-easy {
    background-color: #dcfce7;
    color: #166534;
}

.difficulty-medium {
    background-color: #fef3c7;
    color: #92400e;
}

.difficulty-hard {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ── Action buttons ── */
.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

/* ── Table footer ── */
.data-table-footer {
    padding: 0.7rem 1rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f8fafc;
    font-size: 0.8rem;
    color: #64748b;
}

.data-table-footer .pagination {
    margin: 0;
    gap: 2px;
}

.data-table-footer .page-link {
    border: none;
    color: #64748b;
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border-radius: 5px;
    background: transparent;
}

.data-table-footer .page-link:hover {
    background: #e2e8f0;
    color: #334155;
}

.data-table-footer .page-item.active .page-link {
    background: var(--sidebar-active);
    color: #fff;
}

/* ── Create button ── */
.btn-create {
    background: var(--sidebar-active);
    border: none;
    color: #fff;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-create:hover {
    background: #2563eb;
    color: #fff;
}

/* ── Login page ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--sidebar-bg);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 2rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #0f172a;
}

.login-card .form-control {
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    border-color: #e2e8f0;
}

.login-card .btn-primary {
    background: var(--sidebar-active);
    border: none;
    border-radius: 8px;
    padding: 0.65rem;
    font-weight: 500;
}

.login-card .btn-primary:hover {
    background: #2563eb;
}

/* ── Test Case Editor Modal ── */
.tc-editor-arg-row {
    padding: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.tc-editor-output-row {
    padding: 0.5rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
}

.tc-editor-type-select {
    width: 150px;
    flex-shrink: 0;
}

.tc-editor-graph {
    padding: 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

#tc-editor-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

#tc-editor-modal .form-select-sm,
#tc-editor-modal .form-control-sm {
    font-size: 0.8rem;
}

/* ── Binary Tree Editor ── */
.bt-editor {
    overflow-x: auto;
    padding: 0.75rem 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.bt-node {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.bt-node-box {
    position: relative;
    width: 52px;
    height: 34px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bt-node-box:hover {
    border-color: #94a3b8;
}

.bt-node-input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    background: transparent;
    border-radius: 8px;
    padding: 0 2px;
    -moz-appearance: textfield;
}

.bt-node-input::-webkit-inner-spin-button,
.bt-node-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bt-node-input:focus {
    background: #eff6ff;
}

.bt-node-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.7rem;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    display: none;
    font-weight: 700;
}

.bt-node-box:hover .bt-node-remove {
    display: block;
}

.bt-node-remove:hover {
    background: #dc2626;
    color: #fff;
}

.bt-placeholder {
    width: 36px;
    height: 28px;
    border: 1.5px dashed #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.15s;
}

.bt-placeholder:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}

.bt-children {
    display: flex;
    position: relative;
    margin-top: 24px;
    gap: 4px;
}

/* Vertical line from parent down */
.bt-children::before {
    content: '';
    position: absolute;
    top: -24px;
    left: calc(50% - 0.75px);
    width: 1.5px;
    height: 12px;
    background: #cbd5e1;
}

/* Horizontal bar */
.bt-children::after {
    content: '';
    position: absolute;
    top: -12px;
    left: calc(25%);
    width: calc(50%);
    height: 1.5px;
    background: #cbd5e1;
}

/* Each child: vertical line up from node */
.bt-children > .bt-node {
    flex: 1;
    position: relative;
    padding-top: 12px;
}

.bt-children > .bt-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(50% - 0.75px);
    width: 1.5px;
    height: 12px;
    background: #cbd5e1;
}
