/* layout.css */

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* Left Column - Editor + Preference */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.editor-panel {
    flex: 2;  /* 2/3 of the space */
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Fix editor container height */
.editor-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#editor {
    width: 100%;
    height: 100%;
    border: none;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    color: var(--editor-text);
    background: var(--editor-bg);
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

/* Preference Pane */
.preference-pane {
    flex: 1;  /* 1/3 of the space */
    min-height: 0;  /* Allow shrinking */
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.preference-pane.collapsed {
    flex: 0;
    min-height: 40px;
}

.preference-pane .pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Workspace Panel */
.workspace-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    overflow: hidden;
    height: 100%;
}

.workspace-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Vertical Tools Sidebar - Fixed width */
.tools-sidebar {
    width: 48px;
    min-width: 48px;
    background: var(--toolbar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 8px 4px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 0 auto 4px auto;
    flex-shrink: 0;
}

/* No min-width: 100px! That was a funny desktop thinking 😄 */
.tool-btn i {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Tooltips - now properly positioned from the compact button */
.tool-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    font-size: 12px;
    margin-left: 8px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    border-radius: 3px;
    pointer-events: none;
}

/* Light theme - black icons */
.light-theme .tool-btn i {
    color: #333333;
    stroke: #333333;
}

.light-theme .tool-btn.active i {
    color: var(--primary-color);
    stroke: var(--primary-color);
}

/* Dark theme - white icons */
.dark-theme .tool-btn i,
.monokai-theme .tool-btn i {
    color: #ffffff;
    stroke: #ffffff;
}

.dark-theme .tool-btn.active i,
.monokai-theme .tool-btn.active i {
    color: var(--primary-color);
    stroke: var(--primary-color);
}

/* Active state */
.tool-btn.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* Square Workspace Area */
.workspace-area.square {
    aspect-ratio: 1 / 1;
    max-width: 100%;
    max-height: 100%;
    margin: auto;
}

.workspace-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Transform Handles */
.transform-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 2px;
    z-index: 100;
    pointer-events: all;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.transform-handle:hover {
    background: var(--primary-color);
    transform: scale(1.2);
}

.transform-handle.corner {
    width: 12px;
    height: 12px;
}

.transform-handle.edge {
    width: 8px;
    height: 8px;
}

/* Selection Ants with handles */
.selection-ants {
    position: absolute;
    pointer-events: none;
    border: 2px dashed var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
    z-index: 15;
    animation: marching-ants 0.5s linear infinite;
}

@keyframes marching-ants {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 8; }
}

/* Element hover */
.element-hover {
    outline: 2px dashed var(--primary-color) !important;
    outline-offset: 2px !important;
    opacity: 0.9;
    transition: all 0.1s ease;
    cursor: pointer;
}

/* Property groups */
.property-group {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.property-group h4 {
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.property-group label span {
    min-width: 60px;
    color: var(--text-secondary);
}

.property-group input[type="text"],
.property-group input[type="number"],
.property-group select {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
}

.property-group input[type="color"] {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.color-hex {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: 4px;
}

/* Snapping options */
.snap-options {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    font-size: 11px;
    border-radius: 3px;
}

.snap-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Read-only values in footer */
.footer .object-info {
    display: flex;
    gap: 20px;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 11px;
}

.footer .object-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer .object-info .readonly-value {
    color: var(--text-secondary);
    font-weight: normal;
    font-family: monospace;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    
    .workspace-area.square {
        aspect-ratio: auto;
        max-height: 50vh;
    }
}
