body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #f0f0f0;
    font-family: sans-serif;
}

canvas {
    display: block;
}

#projectName {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 20px;
    font-weight: bold;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: text;
    z-index: 50;
    background: rgba(0,0,0,0.8);
}

#projectName:hover {
    background: black;
    border-color: #555;
}

#projectName:focus {
    background: black;
    border-color: white;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
}

#helpContainer {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 100;
}

#helpIcon {
    width: 30px;
    height: 30px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
    cursor: help;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    color: #555;
    font-family: sans-serif;
    transition: background-color 0.2s;
}

#helpIcon:hover {
    background-color: #f8f8f8;
}

#helpText {
    display: none;
    position: absolute;
    bottom: 40px;
    left: 0;
    width: max-content;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    pointer-events: none;
    user-select: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
    line-height: 1.6;
    font-size: 14px;
    color: #333;
}

#helpContainer:hover #helpText {
    display: block;
}

#controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

#controls button {
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#controls button#resetView {
    width: auto;
    padding: 0 10px;
    font-size: 14px;
}

#controls button#toggleFullscreen {
    font-size: 18px;
    line-height: 1;
}

#controls button#settingsBtn {
    width: auto;
    padding: 0 10px;
    font-size: 14px;
}

#controls button#projectsBtn {
    width: auto;
    padding: 0 10px;
    font-size: 14px;
    margin-right: 10px;
    background-color: #007bff;
    color: white;
    border: none;
}

#controls button#projectsBtn:hover {
    background-color: #0056b3;
}

/* Settings Modal */
.setting-group {
    margin-bottom: 15px;
    text-align: left;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.setting-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Ensure padding doesn't overflow width */
}

/* Modal Styles */
.modal {
    display: flex; /* Flex to center content */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    width: 500px; /* Widened for better layout */
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    text-align: center;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.project-info {
    text-align: left;
    flex-grow: 1;
    cursor: pointer;
}

.project-name {
    font-weight: bold;
    font-size: 16px;
}

.project-date {
    font-size: 12px;
    color: #666;
}

.project-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px;
    max-width: 250px;
}

.project-actions button {
    margin-left: 2px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #f8f8f8;
    border-radius: 3px;
}

.project-actions button:hover {
    background: #e0e0e0;
}

.project-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.divider {
    width: 1px;
    height: 20px;
    background: #ccc;
}

#newProjectBtn, #closeModalBtn, #backupAllBtn, #restoreAllBtn {
    padding: 8px 16px;
    cursor: pointer;
}

#newProjectBtn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
}

#newProjectBtn:hover {
    background-color: #0056b3;
}

#closeModalBtn {
    margin-top: 15px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Project List Updates */
.project-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-preview-icon {
    cursor: help;
    font-size: 16px;
    position: relative;
}

.project-preview-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 4px;
    margin-top: 4px;
}

.project-preview-popup img {
    display: block;
    max-width: 200px;
    max-height: 150px;
    background-color: #f0f0f0;
}

.project-preview-icon:hover .project-preview-popup {
    display: block;
}

.project-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.project-synopsis {
    color: #888;
}

#controls button#collabBtn {
    width: auto;
    padding: 0 10px;
    font-size: 14px;
    background-color: #10b981;
    color: white;
    border: none;
}

#controls button#collabBtn:hover {
    background-color: #059669;
}

#collabIndicator {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 50;
}

#collabIndicator.hidden {
    display: none;
}

.collab-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-connected {
    color: #10b981;
    font-weight: bold;
}

.status-disconnected {
    color: #6b7280;
}

.collab-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.collab-buttons button {
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    border: none;
    font-size: 14px;
}

#startCollabBtn {
    background-color: #10b981;
    color: white;
}

#startCollabBtn:hover {
    background-color: #059669;
}

#stopCollabBtn {
    background-color: #ef4444;
    color: white;
}

#stopCollabBtn:hover {
    background-color: #dc2626;
}

.share-link-row {
    display: flex;
    gap: 8px;
}

.share-link-row input {
    flex: 1;
    font-size: 12px;
}

.share-link-row button {
    padding: 8px 16px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.share-link-row button:hover {
    background-color: #2563eb;
}

.peer-list {
    margin-top: 10px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.peer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
}

.peer-item:last-child {
    border-bottom: none;
}

.peer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.peer-name {
    font-size: 14px;
}

.no-peers {
    padding: 12px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

#closeCollabBtn {
    margin-top: 15px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

#closeCollabBtn:hover {
    background: #f3f4f6;
}

.session-ended-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10000;
    pointer-events: none;
}

.session-ended-popup.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.setting-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#saveSettingsBtn, #closeSettingsBtn {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    margin: 5px;
}

#saveSettingsBtn {
    background-color: #007bff;
    color: white;
    border: none;
}

#saveSettingsBtn:hover {
    background-color: #0056b3;
}

#closeSettingsBtn {
    background: transparent;
    border: 1px solid #ccc;
}

#closeSettingsBtn:hover {
    background: #f3f4f6;
}

.setting-group small.hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
}

.status-error {
    color: #ef4444;
    font-weight: bold;
}
