﻿* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden; /* prevent page-level scrolling */
}

#sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    padding: 10px;
    position: relative;
    z-index: 10;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

    #sidebar h3 {
        margin: 10px 0 5px 0;
        font-size: 13px;
        text-transform: uppercase;
        color: #666;
    }

.palette-item {
    padding: 8px 10px;
    margin: 4px 0;
    border-radius: 4px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

    .palette-item:hover {
        opacity: 0.85;
    }

#sidebar-content {
    overflow-y: auto;
    flex: 1;
}

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* allows flex item to shrink below content size */
    overflow: hidden;
}

#toolbar {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
}

#canvas-container {
    flex: 1;
    overflow: auto; /* canvas scrolls internally */
    position: relative;
}

#canvas {
    position: relative;
    display: inline-block;
}

    #canvas .joint-paper {
        position: relative !important;
    }

#existing-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 10px;
    position: relative;
    z-index: 10;
}

#existing-sidebar-content {
    display: flex;
    flex-direction: column;
    height: calc(100% - 28px); /* account for collapse button row */
    overflow: hidden;
}

#elements-panel, #views-panel {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    height: 100%;
}

.existing-item {
    padding: 6px 8px;
    margin: 3px 0;
    border-radius: 4px;
    background: white;
    font-size: 13px;
    cursor: grab;
    border: 1px solid #ddd;
    overflow: hidden;
}

    .existing-item:hover {
        background: #f0f8ff;
    }

#existing-list h3 {
    margin: 10px 0 5px 0;
    font-size: 13px;
    text-transform: uppercase;
    color: #666;
}


#sidebar-tabs {
    display: flex;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
}

    .sidebar-tab.active {
        color: #222;
        border-bottom-color: #4A90D9;
        font-weight: bold;
    }

.diagram-item {
    padding: 8px 10px;
    margin: 3px 0;
    border-radius: 4px;
    background: white;
    border: 1px solid #ddd;
    font-size: 13px;
    cursor: pointer;
    overflow: hidden;
}

    .diagram-item:hover {
        background: #f0f8ff;
    }

    .diagram-item.active {
        border-color: #4A90D9;
        background: #e8f4ff;
        font-weight: bold;
    }

.group-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .group-header::after {
        content: '▾';
        font-size: 10px;
        color: #999;
    }

    .group-header.collapsed::after {
        content: '▸';
    }

.group-items.collapsed {
    display: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: white;
    border-radius: 8px;
    padding: 20px;
    width: 320px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.modal-input {
    width: 100%;
    padding: 8px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-btn {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    background: white;
}

.modal-btn-primary {
    background: #4A90D9;
    color: white;
    border-color: #4A90D9;
}

    .modal-btn-primary:hover {
        background: #3a7bc0;
    }

.modal-btn-secondary:hover {
    background: #f0f0f0;
}

.modal-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.sidebar-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.sidebar-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.existing-item:hover .item-actions,
.diagram-item:hover .item-actions {
    opacity: 1;
}

.item-action-btn {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    line-height: 16px;
    text-align: center;
    padding: 0;
    color: #999;
    border-radius: 2px;
}

    .item-action-btn.edit:hover {
        color: #4A90D9;
    }

    .item-action-btn.delete:hover {
        color: #e05555;
    }

.toolbar-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

    .toolbar-btn:hover {
        background: #f0f0f0;
    }

.toolbar-btn-primary {
    background: #4A90D9 ;
    color: white;
    border-color: #4A90D9;
}

    .toolbar-btn-primary:hover {
        background: #3a7bc0;
    }

.toolbar-btn-warning {
    background: #f0a500;
    color: white;
    border-color: #f0a500;
}

    .toolbar-btn-warning:hover {
        background: #d49200;
    }

#toolbar {
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
    display: flex;
    align-items: center;
}

.version-item {
    padding: 10px;
    margin: 4px 0;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

    .version-item:hover {
        background: #f0f8ff;
        border-color: #4A90D9;
    }

    .version-item.active {
        border-color: #4A90D9;
        background: #e8f4ff;
    }

.version-item-title {
    font-weight: bold;
    font-size: 13px;
    color: #333;
}

.version-item-meta {
    font-size: 11px;
    color: #888;
}

.version-item-notes {
    font-size: 12px;
    color: #555;
    font-style: italic;
}

#status-tray {
    height: 28px;
    background: #f0f0f0;
    border-top: 1px solid #ddd;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
}

#status-tray-messages {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-msg {
    display: inline-block;
    margin-right: 16px;
}

    .status-msg.success {
        color: #4CAF50;
    }

    .status-msg.error {
        color: #e05555;
    }

    .status-msg.info {
        color: #4A90D9;
    }

.align-action-btn {
    font-size: 12px;
    padding: 6px 4px;
    text-align: center;
    cursor: pointer;
    line-height: 1.4;
}

    .align-action-btn:hover {
        background: #e8f4ff;
        border-color: #4A90D9;
    }


.sidebar-collapse-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: #999;
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 3px;
    width: 100%;
    text-align: right;
}

    .sidebar-collapse-btn:hover {
        background: #e0e0e0;
        color: #333;
    }

#existing-sidebar.collapsed {
    width: 24px;
    padding: 6px 4px;
}

    #existing-sidebar.collapsed #existing-sidebar-content {
        display: none;
    }

    #existing-sidebar.collapsed #collapse-left-btn {
        writing-mode: vertical-rl;
        text-align: center;
        width: 100%;
    }

#sidebar.collapsed {
    width: 24px;
    padding: 6px 4px;
}

    #sidebar.collapsed #sidebar-content {
        display: none;
    }

    #sidebar.collapsed #collapse-right-btn {
        writing-mode: vertical-rl;
        text-align: center;
        width: 100%;
    }

.group-items .group-items .existing-item {
    margin-left: 12px;
}

.group-items .group-items .group-header {
    padding-left: 12px;
    font-size: 12px;
}

#diagram-list .group-items .diagram-item {
    margin-left: 12px;
}

#diagram-list .group-items .group-header {
    padding-left: 12px;
    font-size: 12px;
}

#context-menu {
    padding: 4px 0;
}

.context-menu-item {
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    white-space: nowrap;
}

    .context-menu-item:hover {
        background: #f0f8ff;
        color: #4A90D9;
    }

    .context-menu-item.danger:hover {
        background: #fff0f0;
        color: #e05555;
    }

.context-menu-separator {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}
#auth-overlay input {
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #4A90D9;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

    #user-avatar:hover {
        background: #3a7bc0;
    }

#user-dropdown {
    position: absolute;
    top: 38px;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
}

#logout-btn:hover {
    background: #f5f5f5;
}

#auth-register-fields input {
    box-sizing: border-box;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid #f0f0f0;
}

.user-row-info {
    display: flex;
    flex-direction: column;
}

.user-row-name {
    font-weight: bold;
    font-size: 13px;
}

.user-row-email {
    font-size: 12px;
    color: #888;
}

.user-status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 60px;
    text-align: center;
    box-sizing: border-box;
}

.user-status-active {
    background: #e3f5e1;
    color: #2e7d32;
}

.user-status-pending {
    background: #fff4e0;
    color: #b8720a;
}

.user-status-disabled {
    background: #fde8e8;
    color: #c0392b;
}

.user-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 140px;
    gap: 8px;
}

.user-row-actions button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    color: #4A90D9;
    padding: 4px 8px;
}

    .user-row-actions button:hover {
        text-decoration: underline;
    }

.dropdown-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}

    .dropdown-menu-item:hover {
        background: #f0f0f0;
    }

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

#pickr-container .pcr-button {
    display: none !important;
}

.pcr-button {
    display: none !important;
}

#elements-panel form {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    margin: 0;
}

.role-select {
    font-size: 12px;
    padding: 4px 24px 4px 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='%23666' d='M7 10l5 5 5-5z'/%3e%3c/svg%3e") no-repeat right 6px center;
    background-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    color: #333;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .role-select:hover {
        border-color: #4A90D9;
    }

    .role-select:focus {
        outline: none;
        border-color: #4A90D9;
        box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
    }