:root {
    --color-bg-light: rgba(245, 247, 250, 0.95);
    --color-text-light: #1b1b18;
    --color-primary-light: #4f8ef7;
    --color-accent-light: #ffffff;
    --color-gray-light: #e5e9ec;
    --color-gray-light-2: #b4b7ba;

    --color-bg-dark: rgba(20, 22, 28, 0.95);
    --color-text-dark: #e1e2e5;
    --color-primary-dark: #5aa9ff;
    --color-accent-dark: rgba(50, 50, 60, 0.8);
    --color-gray-dark: #45494a;
    --color-gray-dark-2: #757878;

    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --sidebar-margin: 1.5rem;
}

html, body {
    height: 100%;
    margin: 0;
}

html.light-theme {
    --bg: var(--color-bg-light);
    --text: var(--color-text-light);
    --primary: var(--color-primary-light);
    --accent: var(--color-accent-light);
    --input: var(--color-gray-light);
    --secondary-text: var(--color-gray-dark-2);
}

html.dark-theme {
    --bg: var(--color-bg-dark);
    --text: var(--color-text-dark);
    --primary: var(--color-primary-dark);
    --accent: var(--color-accent-dark);
    --input: var(--color-gray-dark);
    --secondary-text: var(--color-gray-light-2);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    transition: all 0.3s ease;
}

.sidebar-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    padding: 1.5rem;
    gap: 1.5rem;
    box-sizing: border-box;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--accent);

    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    min-height: calc(100vh - 3rem);
    padding: 1rem;

    border-radius: 16px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.05);
    transition: width .3s ease;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex-grow: 1;
}

@media (max-width: 992px) {
    .sidebar-wrapper {
        padding: 1rem;
    }
}
@media (max-width: 576px) {
    .sidebar-wrapper {
        padding: 0.8rem;
    }
}

.sidebar-toggle-btn {
    background: #e3e5ec;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 1.2rem;
    transition: transform .3s ease;
    position: absolute;
    left: 36px;
    top: 38px;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    justify-content: start;
    gap: .75rem;
    padding: .75rem 1rem;
    border-radius: 10px;
    color: var(--text);
    transition: .2s;
}

.sidebar .nav-link i {
    font-size: 1.2rem;
}

.sidebar .nav-link.active {
    background: var(--primary) !important;
    color: white;
}

.sidebar .menu-text {
    transition: .3s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar .nav-item {
    width: 100%;
}

.btn-theme {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    gap: .5rem;
    border: none;
    padding: .6rem 1rem;
    cursor: pointer;
    transition: .3s;
    box-sizing: border-box;
    width: 100%;
}
.btn-theme:hover {
    background: rgba(255,255,255,0.2);
}

#userDropdown {
    margin-top: 60px;
}

.sidebar-user a.sidebar-user-block {
    text-decoration: none;
    background: #d7dfff;
    padding: 10px 0;
    border-radius: 10px;
}

.sidebar-user-block:hover .user-avatar {
    background-color: #6c757d !important;
    transform: scale(1.03);
    transition: 0.15s;
    cursor: pointer;
}

.user-avatar {
    width: 45px;
    height: 45px;
    margin: 0 18px;
    display: flex;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
}
.user-avatar i {
    font-size: 32px;
}

.user-avatar.users-list {
    display:flex;
    align-items:center;
    justify-content:center;
    width:50px;
    height:50px;
    border-radius:50%;
}

.user-avatar.users-list img {
    border-radius:50%;
    width:100%;
    height:100%;
}

.sidebar-user-info div {
    text-decoration: none !important;
}
.user-name {
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
}

.user-email {
    font-size: 0.8rem;
    color: #8a8a8a;
    margin-top: -2px;
}

html.sidebar-collapsed-init #sidebar {
    width: var(--sidebar-collapsed) !important;
    min-width: var(--sidebar-collapsed) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-radius: 12px;
    overflow: visible;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed) !important;
    min-width: var(--sidebar-collapsed) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-radius: 12px;
    overflow: visible;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
    box-sizing: border-box;
}

.sidebar.collapsed .nav-link i {
    display: inline-block;
    min-width: 0;
    font-size: 1.3rem;
    margin: 0 ;
    text-align: center;
    line-height: 1;
}

.sidebar.collapsed .nav-link[title] {
    position: relative;
}

.sidebar.collapsed .menu-text {
    opacity: 0;
    width: 0;
    display: none !important;
    margin: 0 !important;
}

.sidebar.collapsed .btn-theme {
    justify-content: center;
    width: 100%;
    padding: .6rem !important;
    border-radius: 10px !important;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .btn-theme .menu-text {
    opacity: 0;
    width: 0;
    margin: 0;
}

.sidebar.collapsed .btn-theme i {
    margin: 0;
    font-size: 1.2rem;
}

.sidebar.collapsed .list-group,
.sidebar.collapsed .list-group-item,
.sidebar.collapsed .list-block {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.sidebar.collapsed .sidebar-user-info {
    display: none;
}

.sidebar.collapsed .sidebar-user-block {
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0 auto;
}


@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        border-radius: 0;
        z-index: 1000;
    }

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

    .content {
        margin-left: 0 !important;
    }

    .sidebar-toggle-btn {
        padding: 5px 6px;
        border-radius: 8px;
        color: var(--text);
        font-size: 1.2rem;
        width: 40px;
        height: 40px;
        left: 10px;
        top: 10px !important;
    }
}

.sidebar * {
    box-sizing: border-box;
}
.sidebar,
.sidebar-wrapper {
    overflow: visible !important;
}

.bg-card {
    background-color: var(--accent);
    border-radius: 16px;
    border-color: var(--accent);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    width: 100%;
}

.bg-card .form-control.custom-input {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.bg-card .form-control.custom-input:focus {
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    outline: none;
}

.btn {
    border-radius: 12px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

#logContainer {
    background: #0b0b0b;
    color: #d6fac2;
    padding: 12px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace;
    font-size: 15px;
    line-height: 1.35;
    max-height: 70vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

#logContainer pre {
    margin: 0;
    white-space: pre-wrap;
}

#logPre {
    font-family: monospace;
    white-space: pre-wrap;
}


.list-group-item {
    border: none;
    background: transparent;
    transition: transform .15s ease;
}

.list-block {
    transition: background-color .25s ease, border-color .25s ease;
    border-left: 3px solid transparent;
    border-radius: 8px;
    padding: 1rem;
}

.list-group-item:hover .list-block {
    background-color: rgba(0, 0, 0, 0.05);
    border-left-color: #0d6efd;
}

.list-group-item:hover {
    transform: translateX(4px);
}

.nav-pills .nav-link {
    transition: background-color .25s ease, padding-left .2s ease;
}

.nav-pills .nav-link:hover {
    background-color: rgba(13, 110, 253, 0.15);
    padding-left: 18px;
}

.nav-pills .nav-link.active {
    background-color: #0d6efd;
    color: #fff !important;
}

.list-group-item {
    border: none !important;
}

.list-group-item + .list-group-item {
    margin-top: 4px;
}

.form-control-custom {
    background: var(--bg);
    border: 1px solid var(--input);
    border-radius: 15px;
    color: var(--text, #8e8e8e);
}
.form-control.form-control-custom::placeholder {
    color: var(--text);
    opacity: 1;
}

.form-floating > .form-control-custom:focus,
.form-floating > .form-control-custom:not(:placeholder-shown) {
    background: var(--bg) !important;
    color: var(--text, #8e8e8e);
}

.form-floating .form-control-custom::placeholder {
    color: transparent !important;
}

.form-control-custom:hover {
    border-color: #c5c9cc;
}

.form-floating > label {
    color: var(--secondary-text) !important;
}

.logContainer {
    overflow-y:auto;
    max-height:70vh;
    background:#1e1e1e;
    padding:10px;
    border-radius:5px;
}

.logPre {
    white-space:pre-wrap;
    word-break:break-word;
    margin:0
}

.form-control-custom {
    background: var(--bg);
    border: 1px solid var(--input);
    border-radius: 15px;
}
.form-floating > .form-control-custom:focus,
.form-floating > .form-control-custom:not(:placeholder-shown) {
    background: var(--bg) !important;
}

.form-floating .form-control-custom::placeholder {
    color: transparent !important;
}

.form-floating > .form-control-custom:focus,
.form-floating > .form-control-custom:not(:placeholder-shown) {
    background: var(--bg) !important;
}

form-floating > label {
    color: var(--text);
}

.border-radius-10 {
    border-radius: 10px;
}

.form-check-label {
    margin-top: 1px;
}

.login-form {
    background-color: var(--accent);
}
html.dark-theme .login-form {
    background-color: var(--accent);
}

html.dark-theme .sidebar-user a.sidebar-user-block {
    border: 2px solid var(--color-primary-dark);
    background: var(--bs-secondary-color);
}
html.dark-theme .sidebar-user a.sidebar-user-block .user-name {
    color: var(--text);
}
html.dark-theme .sidebar-user a.sidebar-user-block .user-email {
    color: var(--text);
}

html.dark-theme .form-show-custom {
    background: var(--bg);
    color: var(--text);
}

html.dark-theme .list-group-item + .list-group-item {
    margin-top: 6px;
}

html.dark-theme .bg-card {
    background-color: rgba(40, 40, 50, 0.55);
    border-color: transparent;
}

html.dark-theme .nav-pills .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.07);
}

html.dark-theme .nav-pills .nav-link.active {
    background-color: var(--primary);
    color: #fff;
}

html.dark-theme .sidebar {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    background-color: rgba(40, 40, 50, 1);
}

html.dark-theme .form-control.custom-input {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

html.dark-theme .form-control.custom-input:focus {
    background-color: rgba(255, 255, 255, 0.12);
}

html.dark-theme .btn {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

html.dark-theme .btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

html.dark-theme #logContainer {
    background: #111;
    color: #c6fcb4;
}

html.light-theme h1,
html.light-theme h2,
html.light-theme h3,
html.light-theme h4,
html.light-theme h5,
html.light-theme h6 {
    color: var(--color-text-light) !important;
}

html.dark-theme h1,
html.dark-theme h2,
html.dark-theme h3,
html.dark-theme h4,
html.dark-theme h5,
html.dark-theme h6 {
    color: var(--color-text-dark) !important;
}

.page-container {
    background-color: transparent;
}

.list-group-item.project-item {
    background-color: var(--accent);
    color: var(--text);
}

html.light-theme .list-group-item.project-item {
    background-color: var(--color-accent-light);
    color: var(--color-text-light);
}

html.dark-theme .list-group-item.project-item {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--color-text-dark);
}

.list-group-item .text-muted {
    color: rgba(0, 0, 0, 0.6);
}

html.dark-theme .list-group-item .text-muted {
    color: rgba(255, 255, 255, 0.6);
}

.list-group-item a,
.list-group-item a * {
    color: inherit;
    text-decoration: none;
}

.list-group-item.project-item:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.list-group-item a:hover {
}

.list-group-item .btn {
    border-radius: 8px;
}

html.dark-theme .list-group-item,
html.dark-theme .list-group-item.project-item {
    background-color: rgba(30, 30, 40, 0.9) !important;
    color: #e1e2e5 !important;
}

html.dark-theme .list-group-item .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

html.dark-theme .list-group-item strong {
    color: #fff !important;
}

html.dark-theme .list-group-item:hover,
html.dark-theme .list-group-item.project-item:hover {
    background-color: rgba(50, 50, 60, 0.9) !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

.sidebar-user ul.dropdown-menu {
    min-width: 180px;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

html.dark-theme .dropdown-menu {
    --bs-dropdown-bg: var(--color-bg-dark);
    --bs-dropdown-color: var(--color-text-dark);
    --bs-dropdown-border-color: #333;
    --bs-dropdown-link-color: var(--color-text-dark);
    --bs-dropdown-link-hover-bg: var(--color-gray-dark);
    --bs-dropdown-link-hover-color: var(--color-text-dark);
    --bs-dropdown-divider-bg: #333;
}

html.dark-theme .alert-danger {
    --bs-alert-bg: rgba(255, 59, 59, 0.15);
    --bs-alert-color: #ffb3b3;
    --bs-alert-border-color: rgba(255, 59, 59, 0.4);
}
html.dark-theme .alert-danger i {
    color: #ff9a9a;
}

html.dark-theme .alert-primary {
    --bs-alert-bg: rgba(0, 123, 255, 0.15);
    --bs-alert-color: #a8d4ff;
    --bs-alert-border-color: rgba(0, 123, 255, 0.4);
}

html.dark-theme .alert-primary i {
    color: #cce6ff;
}

.avatar-box {
    width: 100px;
    height: 100px;
    overflow: hidden;
    border-radius: 50%;
}

.avatar-box img {
    width: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
}

.avatar-box-text {
    font-size: 45px;
}

.avatar-wrapper {
    margin-right: 25px;
}

.avatar-wrapper .pen {
    width: 32px;
    height: 32px;
    margin-left: 75px;
    margin-top: -10px;
}

.avatar-box-small {
    width: 35px;
    height: 35px;
    overflow: hidden;
    border-radius: 50%;
}

.avatar-box-small img {
    width: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
}
.cropper-view-box,
.cropper-face {
    border-radius: 50%;
}

/* Модалка cropper подхватывает тему */
#cropperModal .modal-content {
    background-color: var(--accent) !important;
    color: var(--text) !important;
    border-radius: 12px;
    transition: background 0.3s, color 0.3s;
}

html.dark-theme #cropperModal .modal-content {
    background-color: rgba(40, 40, 50, 0.95) !important;
    color: #e1e2e5 !important;
}

#cropperModal .modal-header,
#cropperModal .modal-footer {
    background-color: transparent;
    border-color: transparent;
    color: var(--text) !important;
}

html.dark-theme #cropperModal .modal-header,
html.dark-theme #cropperModal .modal-footer {
    color: #e1e2e5 !important;
}

#cropperModal .btn-close {
    filter: none;
    opacity: 1;
}

html.dark-theme #cropperModal .btn-close {
    filter: invert(1);
}

.modal-backdrop {
    background-color: rgba(0,0,0,0.35) !important;
}

html.dark-theme .modal-backdrop {
    background-color: rgba(0,0,0,0.6) !important;
}

#cropperModalContent {
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

#cropperImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: transparent;
}

.cropper-view-box,
.cropper-face {
    border-radius: 50%;
    outline: 1px solid var(--input);
}
/* END Модалка cropper подхватывает тему */

#builderArea {
    width: 100%;
    height: 80vh;
    background: #f8f9fa; /* светлый BS цвет */
    border: 2px dashed #ced4da;
    position: relative;
    overflow: auto;
    border-radius: .5rem;
}

.node {
    position: absolute;
    width: 220px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    padding: 12px;
    box-shadow: 0 .125rem .25rem rgba(0,0,0,.075);
    cursor: move;
}

.node .card {
    border-radius: .6rem;
}

.node .card-header {
    background: #f8f9fa;
    font-weight: 600;
}

.node-header {
    font-weight: 600;
}

.ep-yes circle { fill: #28a745 !important; }
.ep-no circle { fill: #dc3545 !important; }

.cond-label {
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    color: #555;
}

.yes-label {
    bottom: -18px;
    left: 20px;
}

.no-label {
    bottom: -18px;
    right: 20px;
}
