/* ---- Top bar (Dashboard + Search) ---- */
.sidebar-top-bar {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-dashboard-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sidebar-dashboard-btn:hover {
    color: #4f46e5;
    background: #eef2ff;
    border-color: #c7d2fe;
    text-decoration: none;
}

.sidebar-dashboard-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-top-bar .sidebar-search {
    flex: 1;
    padding: 0;
    border-bottom: none;
}

/* ---- Workspace selector ---- */
.workspace-selector {
    display: flex;
    gap: 2px;
    padding: 8px 12px 10px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

.workspace-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s ease;
    line-height: 1;
}

.workspace-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.workspace-btn:hover {
    background: #eef2ff;
    color: #4f46e5;
}

.workspace-btn.active {
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

/* ---- Search bar ---- */
.sidebar-search {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-icon {
    position: absolute;
    left: 10px;
    font-size: 15px;
    color: #94a3b8;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    padding: 6px 32px 6px 32px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search-input::placeholder {
    color: #94a3b8;
}

.sidebar-search-input:focus {
    border-color: #a5b4fc;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.sidebar-search-clear {
    position: absolute;
    right: 4px;
    padding: 4px;
    border: none;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    border-radius: 4px;
}

.sidebar-search-clear:hover {
    color: #475569;
    background: #f1f5f9;
}

.sidebar-search-results {
    margin-top: 6px;
    max-height: 360px;
    overflow-y: auto;
    border-radius: 8px;
    background: #f8fafc;
}

.sidebar-search-result {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    color: #1e293b;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.1s ease;
}

.sidebar-search-result:hover {
    background: #eef2ff;
    text-decoration: none;
    color: #4f46e5;
}

.sidebar-search-result-label {
    font-size: 13px;
    font-weight: 500;
}

.sidebar-search-result-crumb {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 1px;
}

.sidebar-search-empty {
    padding: 12px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* ---- System footer button ---- */
.sidebar-system-footer {
    padding: 8px 12px 12px;
    border-top: 1px solid #e2e8f0;
    margin-top: auto;
}

.sidebar-system-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-system-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-system-btn:hover {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #c7d2fe;
}

/* ---- System Modal ---- */
.system-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.system-modal-backdrop.open {
    opacity: 1;
}

.system-modal {
    width: 480px;
    max-width: 92vw;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
}

.system-modal-backdrop.open .system-modal {
    transform: scale(1) translateY(0);
}

.system-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.system-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.system-modal-title svg {
    width: 22px;
    height: 22px;
    color: #6366f1;
}

.system-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.15s ease;
}

.system-modal-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.system-modal-body {
    padding: 12px 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.system-modal-group {
    margin-bottom: 8px;
}

.system-modal-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.1s ease;
}

a.system-modal-group-title:hover {
    background: #f1f5f9;
    color: #4f46e5;
    text-decoration: none;
}

.system-modal-group-title i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    color: #6366f1;
}

.system-modal-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 40px;
    font-size: 13px;
    color: #64748b;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.1s ease;
}

.system-modal-link:hover {
    background: #eef2ff;
    color: #4f46e5;
    text-decoration: none;
}

.system-modal-link i {
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.system-modal-link--standalone {
    padding-left: 12px;
    font-weight: 500;
    color: #475569;
}

.system-modal-link--standalone i {
    color: #6366f1;
    font-size: 18px;
    width: 20px;
}

.system-modal-empty {
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* ---- Dark mode ---- */
[data-bs-theme="dark"] .sidebar-top-bar {
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .sidebar-dashboard-btn {
    color: #94a3b8;
    background: #0f172a;
    border-color: #334155;
}

[data-bs-theme="dark"] .sidebar-dashboard-btn:hover {
    color: #818cf8;
    background: rgba(129, 140, 248, 0.1);
    border-color: #4f46e5;
}

[data-bs-theme="dark"] .workspace-selector {
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .workspace-btn {
    color: #94a3b8;
}

[data-bs-theme="dark"] .workspace-btn:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
}

[data-bs-theme="dark"] .workspace-btn.active {
    background: rgba(129, 140, 248, 0.15);
    color: #818cf8;
}

[data-bs-theme="dark"] .sidebar-search {
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .sidebar-search-input {
    border-color: #334155;
    background: #0f172a;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .sidebar-search-input:focus {
    border-color: #6366f1;
    background: #1e293b;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

[data-bs-theme="dark"] .sidebar-search-input::placeholder {
    color: #64748b;
}

[data-bs-theme="dark"] .sidebar-search-results {
    background: #0f172a;
}

[data-bs-theme="dark"] .sidebar-search-result {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .sidebar-search-result:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
}

[data-bs-theme="dark"] .sidebar-search-result-crumb {
    color: #64748b;
}

[data-bs-theme="dark"] .sidebar-search-clear {
    color: #64748b;
}

[data-bs-theme="dark"] .sidebar-search-clear:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .sidebar-system-footer {
    border-top-color: #334155;
}

[data-bs-theme="dark"] .sidebar-system-btn {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar-system-btn:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
    border-color: #4f46e5;
}

[data-bs-theme="dark"] .system-modal {
    background: #1e293b;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .system-modal-header {
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .system-modal-title {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .system-modal-close {
    color: #64748b;
}

[data-bs-theme="dark"] .system-modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .system-modal-group-title {
    color: #cbd5e1;
}

[data-bs-theme="dark"] a.system-modal-group-title:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
}

[data-bs-theme="dark"] .system-modal-group-title i {
    color: #818cf8;
}

[data-bs-theme="dark"] .system-modal-link {
    color: #94a3b8;
}

[data-bs-theme="dark"] .system-modal-link:hover {
    background: rgba(129, 140, 248, 0.1);
    color: #818cf8;
}

[data-bs-theme="dark"] .system-modal-link--standalone {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .system-modal-link--standalone i {
    color: #818cf8;
}

[data-bs-theme="dark"] .system-modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* ---- Collapsed/minimal sidebar ---- */
.navbar-minimal .workspace-selector {
    flex-direction: column;
    padding: 6px 4px;
    gap: 1px;
}

.navbar-minimal .workspace-btn span {
    display: none;
}

.navbar-minimal .workspace-btn {
    padding: 6px;
}

.navbar-minimal .sidebar-top-bar {
    flex-direction: column;
    padding: 6px 4px;
    gap: 4px;
}

.navbar-minimal .sidebar-search {
    display: none;
}

.navbar-minimal .sidebar-dashboard-btn {
    width: 100%;
}

.navbar-minimal .sidebar-system-btn span {
    display: none;
}

.navbar-minimal .sidebar-system-btn {
    justify-content: center;
    padding: 8px;
}
