/* ═══════════════════════════════════════════════════════════════
   Pro'fil Architect - Design System
   Modern light theme with clean design
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Colors - Light Theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: rgba(255, 255, 255, 0.95);

    --surface-1: rgba(0, 0, 0, 0.02);
    --surface-2: rgba(0, 0, 0, 0.04);
    --surface-3: rgba(0, 0, 0, 0.06);

    --text-primary: #1e293b;
    --text-secondary: rgba(30, 41, 59, 0.7);
    --text-tertiary: rgba(30, 41, 59, 0.5);

    --accent-primary: #6366f1;
    --accent-primary-hover: #5558e6;
    --accent-secondary: #0ea5e9;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --border-color: rgba(0, 0, 0, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* Grid colors */
    --grid-line: rgba(0, 0, 0, 0.05);
    --grid-line-major: rgba(0, 0, 0, 0.12);

    /* Element colors */
    --wall-color: #374151;
    --wall-fill: #6b7280;
    --door-color: #f59e0b;
    --window-color: #0ea5e9;
    --room-fill: rgba(99, 102, 241, 0.1);
    --furniture-color: #8b5cf6;

    /* Sizing */
    --header-height: 56px;
    --toolbar-width: 200px;
    --panel-width: 240px;
    --status-height: 32px;

    /* Effects */
    --blur-sm: 8px;
    --blur-md: 16px;
    --blur-lg: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.25rem;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-elevated);
    backdrop-filter: blur(var(--blur-md));
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-left {
    flex: 1;
}

.header-right {
    flex: 1;
    justify-content: flex-end;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.logo svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.project-name {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    text-align: center;
    min-width: 200px;
    transition: all var(--transition-fast);
}

.project-name:hover {
    background: var(--surface-1);
    border-color: var(--border-color);
}

.project-name:focus {
    outline: none;
    background: var(--surface-2);
    border-color: var(--accent-primary);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: white;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--text-tertiary);
}

.btn-danger-outline {
    background: transparent;
    color: var(--accent-danger);
    border: 1px solid var(--accent-danger);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #dc2626;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--surface-2);
    color: var(--accent-primary);
}

.toggle-group {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    padding: 2px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.toggle-group .btn {
    flex: 1;
    padding: 6px 4px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    font-size: 11px;
}

.toggle-group .btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.toggle-group .btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

.btn-icon.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   TOOLBAR (LEFT)
   ═══════════════════════════════════════════════════════════════ */

.toolbar {
    width: var(--toolbar-width);
    background: var(--bg-elevated);
    backdrop-filter: blur(var(--blur-md));
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.toolbar-section h3 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    background: var(--surface-1);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.tool-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Properties */
.property-group {
    margin-bottom: 16px;
}

.property-group label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.input-with-unit input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    width: 100%;
}

.input-with-unit input:focus {
    outline: none;
}

.input-with-unit span {
    padding: 8px 12px;
    background: var(--surface-2);
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--font-size-sm) !important;
    color: var(--text-secondary) !important;
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked+.checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-label input:checked+.checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ═══════════════════════════════════════════════════════════════
   CANVAS CONTAINER
   ═══════════════════════════════════════════════════════════════ */

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-secondary);
}

#mainCanvas {
    position: absolute;
    top: 0;
    left: 0;
    /* Custom light-colored cursors for dark theme visibility */
    cursor: crosshair;
}

/* Custom cursor definitions for light theme */
#mainCanvas.cursor-select {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' stroke='%23ffffff' stroke-width='1' d='M5 3l14 11-6 1-3 6-2-8z'/%3E%3C/svg%3E") 5 3, default;
}

#mainCanvas.cursor-crosshair {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cline x1='12' y1='2' x2='12' y2='22' stroke='%23000000' stroke-width='2'/%3E%3Cline x1='2' y1='12' x2='22' y2='12' stroke='%23000000' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='%23000000' stroke-width='2'/%3E%3C/svg%3E") 12 12, crosshair;
}

#mainCanvas.cursor-text {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cline x1='12' y1='4' x2='12' y2='20' stroke='%23000000' stroke-width='2'/%3E%3Cline x1='8' y1='4' x2='16' y2='4' stroke='%23000000' stroke-width='2'/%3E%3Cline x1='8' y1='20' x2='16' y2='20' stroke='%23000000' stroke-width='2'/%3E%3C/svg%3E") 12 12, text;
}

#mainCanvas.cursor-grab {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' stroke='%23ffffff' stroke-width='1' d='M9 6a1 1 0 0 1 2 0v5h1V5a1 1 0 0 1 2 0v6h1V6a1 1 0 0 1 2 0v6h1V8a1 1 0 0 1 2 0v8c0 3-2 5-5 5h-2c-3 0-5-2-5-5V9a1 1 0 0 1 2 0v2h1V6z'/%3E%3C/svg%3E") 12 12, grab;
}

#mainCanvas.cursor-grabbing {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' stroke='%23ffffff' stroke-width='1' d='M9 9a1 1 0 0 1 2 0v5h1V8a1 1 0 0 1 2 0v6h1V9a1 1 0 0 1 2 0v6h1V11a1 1 0 0 1 2 0v5c0 3-2 5-5 5h-2c-3 0-5-2-5-5v-5a1 1 0 0 1 2 0v3h1V9z'/%3E%3C/svg%3E") 12 12, grabbing;
}

#mainCanvas.cursor-eraser {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23ef4444' stroke='%23000000' stroke-width='1.5' d='M7 21l-4-4c-1-1-1-2.5 0-3.4l10-10c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L14 21'/%3E%3Cline x1='5' y1='11' x2='14' y2='20' stroke='%23000000' stroke-width='1.5'/%3E%3C/svg%3E") 6 18, not-allowed;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.zoom-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 6px 12px;
    background: var(--bg-elevated);
    backdrop-filter: blur(var(--blur-sm));
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.zoom-indicator.visible {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   ELEMENTS PANEL (RIGHT)
   ═══════════════════════════════════════════════════════════════ */

.elements-panel {
    width: var(--panel-width);
    background: var(--bg-elevated);
    backdrop-filter: blur(var(--blur-md));
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
}

.elements-panel.collapsed {
    width: 48px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.elements-categories {
    display: flex;
    gap: 4px;
    padding: 12px;
    overflow-x: auto;
}

.category-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.category-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.category-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.elements-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
    align-content: start;
}

.element-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--surface-1);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition-fast);
}

.element-item:hover {
    background: var(--surface-2);
    border-color: var(--border-color);
    transform: translateY(-2px);
}

.element-item:active {
    cursor: grabbing;
}

.element-item.hidden {
    display: none;
}

.element-icon {
    font-size: 24px;
    line-height: 1;
}

.element-item span {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════════════════════════ */

.status-bar {
    height: var(--status-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.status-left,
.status-center,
.status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-left {
    flex: 1;
}

.status-right {
    flex: 1;
    justify-content: flex-end;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-controls span {
    min-width: 48px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(var(--blur-sm));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 320px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal.visible .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-base);
    margin-bottom: 16px;
    transition: all var(--transition-fast);
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-content select {
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBARS
   ═══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════ */

.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .elements-panel {
        width: 200px;
    }

    .toolbar {
        width: 160px;
    }
}

@media (max-width: 768px) {
    .header-center {
        display: none;
    }

    .elements-panel {
        position: absolute;
        right: 0;
        top: var(--header-height);
        height: calc(100% - var(--header-height) - var(--status-height));
        z-index: 50;
        transform: translateX(100%);
        transition: transform var(--transition-normal);
    }

    .elements-panel.open {
        transform: translateX(0);
    }

    .toolbar {
        width: 56px;
        padding: 8px;
    }

    .tool-btn span,
    .toolbar-section h3,
    .property-group {
        display: none;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }
}

.property-group-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.property-group-row .checkbox-label {
    flex: 1;
    margin-bottom: 0;
    font-size: 11px;
}

.property-group {
    margin-bottom: 1rem;
}