/* css/editor.css */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.main-area {
    flex-grow: 1;
    position: relative;
    background-color: var(--main-bg);
    min-width: 0;
}

.content-pane {
    display: none;
    padding: 40px;
    height: 100%;
    width: 100%;
    overflow-y: auto;
}

.content-pane.active {
    display: block;
}

.flex-layout {
    padding: 0 !important;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: #fafafa;
}

.flex-layout.active {
    display: flex;
}

.design-layout {
    padding: 0 !important;
    display: none;
}

.design-layout.active {
    display: flex;
    flex-direction: row;
}

.prototype-layout {
    padding: 0 !important;
    display: none;
    overflow: hidden;
}

.prototype-layout.active {
    display: flex;
}

#prototype-3d-container {
    width: 100%;
    height: 100%;
    display: block;
    overflow: hidden;
}

.canvas-wrapper {
    flex-grow: 1;
    position: relative;
    background-color: var(--main-bg);
    overflow: hidden;
    min-width: 0;
}

#skia-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.top-toolbar {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--rail-bg);
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    display: flex;
    gap: 4px;
    padding: 6px;
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.08),
        0 0 1px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.tool-btn {
    background: transparent;
    border: none;
    color: #333333;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition:
        background-color 0.2s,
        color 0.2s;
}

.tool-btn:hover {
    background-color: #f2f2f2;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5 !important;
}

.tool-btn.active {
    background-color: #18a0fb;
    color: white;
}

/* Tool Group */
.tool-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1px;
}

.tool-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background-color: #ffffff;
    color: #000000;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 100;
    padding: 4px 0;
}

.tool-dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #000000;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    margin-right: 12px;
}

/* Sync Status Override */
.sync-status-overlay {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background-color: var(--rail-bg);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sync-status-hidden {
    opacity: 0;
    visibility: hidden;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #27ae60;
    transition: background-color 0.3s ease;
}

.status-dot.syncing {
    background-color: var(--accent);
    animation: pulse 1s infinite alternate;
}

.status-dot.offline {
    background-color: #f24e1e;
}

@keyframes pulse {
    from {
        opacity: 0.5;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1.1);
    }
}

.top-notification-overlay {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background-color: var(--rail-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.top-notification-overlay.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Desktop Mobile Resets */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background-color: var(--rail-bg);
    border-bottom: 1px solid var(--border-color);
    height: 56px;
    flex-shrink: 0;
    z-index: 900;
}
.mobile-overlay {
    display: none;
}

.editor-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100vw;
}

.icon-btn {
    background: transparent;
    border: none;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .main-area {
        height: calc(100vh - 56px);
    }
}

/* Context Menu */
.context-menu {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    padding: 8px;
    z-index: 9999;
    min-width: 180px;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.context-menu-item {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
    color: var(--text-primary);
}

/* Tree View Drop Indicators */
.tree-item.drag-over-top {
    border-top: 2px solid var(--accent) !important;
}
.tree-item.drag-over-bottom {
    border-bottom: 2px solid var(--accent) !important;
}
.tree-item.drag-over-inside {
    background-color: rgba(24, 160, 251, 0.1) !important;
    border: 1px solid var(--accent) !important;
}

/* Templates Overlay */
.templates-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.templates-modal {
    background: white;
    width: 800px;
    height: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.templates-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
}
.templates-modal-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.templates-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.templates-close-btn:hover {
    background: #f0f0f0;
}
.templates-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.templates-sidebar {
    width: 200px;
    border-right: 1px solid #e0e0e0;
    background: #f9f9f9;
    padding: 10px 0;
}
.templates-sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.templates-sidebar li {
    padding: 8px 20px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
}
.templates-sidebar li.active {
    background: #e8eaed;
    font-weight: 500;
}
.templates-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
}
.template-item {
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    margin: 10px;
    flex-shrink: 0;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.template-item:hover {
    opacity: 1;
}
.template-add-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #333;
    border: 1px solid #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.template-item:hover .template-add-btn {
    opacity: 1;
}
.template-add-btn:hover {
    background: #f0f0f0;
}

@media (max-width: 768px) {
    .templates-modal {
        width: 95%;
        height: 85%;
    }
    .templates-modal-body {
        flex-direction: column;
    }
    .templates-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 0;
        overflow-x: auto;
    }
    .templates-sidebar ul {
        display: flex;
        flex-direction: row;
    }
    .templates-sidebar li {
        padding: 12px 20px;
        white-space: nowrap;
    }
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    .templates-content {
        padding: 12px;
    }
}

/* Comments Overlay */
#comments-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.comment-marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background-color: #f24e1e;
    border: 3px solid #ffffff;
    border-radius: 50% 50% 50% 0;
    transform: translate(-50%, -100%) rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.15s ease;
}

.comment-marker:hover {
    transform: translate(-50%, -100%) rotate(-45deg) scale(1.1);
}

.comment-marker-initial {
    transform: rotate(45deg);
    color: white;
    font-weight: 600;
    font-size: 14px;
    user-select: none;
}

.comment-popover {
    position: absolute;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    transform: translate(-50%, 16px);
    z-index: 10;
    min-width: 250px;
}

.comment-input-form {
    display: flex;
    flex: 1;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    padding: 4px 4px 4px 12px;
    transition: border-color 0.2s;
}

.comment-input-form:focus-within {
    border-color: #18a0fb;
}

.comment-input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    color: #333;
    background: transparent;
}

.comment-submit-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e5e5e5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background-color 0.2s;
}

.comment-submit-btn.active {
    background: #18a0fb;
}

.comment-submit-btn svg {
    width: 14px;
    height: 14px;
}

.comment-view-card {
    position: absolute;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 16px;
    display: flex;
    gap: 12px;
    pointer-events: auto;
    transform: translate(-50%, 16px);
    z-index: 10;
    min-width: 280px;
}

.comment-view-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #f24e1e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.comment-view-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.comment-view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.comment-view-author {
    font-weight: 600;
    color: #333;
}

.comment-view-time {
    color: #999;
}

.comment-view-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    word-break: break-word;
}
