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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
#sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

#sidebar h2, #sidebar h3 {
    margin-bottom: 15px;
    font-size: 16px;
}

#sidebar button {
    width: 100%;
    padding: 10px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 10px;
    font-size: 14px;
}

#sidebar button:hover {
    background: #2980b9;
}

.project-item {
    padding: 10px;
    background: #34495e;
    margin-bottom: 10px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.project-item-name {
    flex: 1;
    margin-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.project-item:hover {
    background: #3d566e;
}

.project-item.active {
    background: #3498db;
}

.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.delete-btn:hover {
    background: #c0392b;
}

/* Main content */
#mainContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Toolbar */
#toolbar {
    background: #ecf0f1;
    padding: 10px;
    border-bottom: 1px solid #bdc3c7;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.tool-btn, #toolbar button {
    padding: 8px 16px;
    border: 1px solid #bdc3c7;
    background: white;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    white-space: nowrap;
}

.tool-btn:hover, #toolbar button:hover {
    background: #f0f0f0;
}

.tool-btn.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

#saveBtn {
    background: #27ae60;
    color: white;
    border: none;
}

#saveBtn:hover {
    background: #229954;
}

#exportPdfBtn {
    background: #e74c3c;
    color: white;
    border: none;
}

#exportExcelBtn {
    background: #27ae60;
    color: white;
    border: none;
}

/* Canvas container */
#canvasContainer {
    flex: 1;
    position: relative;
    background: #f5f5f5;
    overflow: hidden;
    min-height: 0;
}

#canvas2d, #canvas3d {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Properties panel */
#propertiesPanel {
    width: 300px;
    background: white;
    border-left: 1px solid #bdc3c7;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

#propertiesPanel h3 {
    margin-bottom: 15px;
}

.property-group {
    margin-bottom: 15px;
}

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

.property-group input, .property-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
}

.btn-primary:hover {
    background: #2980b9;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    resize: vertical;
    font-size: 14px;
}

/* Catalog items */
.furniture-item, .texture-item {
    display: inline-block;
    width: 180px;
    margin: 10px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: center;
    vertical-align: top;
}

.furniture-item:hover, .texture-item:hover {
    background: #f0f0f0;
    border-color: #3498db;
}

.furniture-item h4, .texture-item h4 {
    margin-bottom: 10px;
    font-size: 14px;
}

.furniture-item p, .texture-item p {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.furniture-item button, .texture-item button {
    width: 100%;
    padding: 8px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 13px;
}

.furniture-item button:hover, .texture-item button:hover {
    background: #2980b9;
}

.texture-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 3px;
    margin-bottom: 10px;
}

/* Estimate */
.estimate-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.estimate-total {
    font-size: 20px;
    font-weight: bold;
    margin-top: 20px;
    padding: 15px;
    background: #f39c12;
    color: white;
    border-radius: 5px;
    text-align: center;
}

/* ============================================ */
/* МОБИЛЬНАЯ АДАПТИВНОСТЬ */
/* ============================================ */

@media (max-width: 768px) {
    /* На планшетах и больших телефонах */
    #sidebar {
        width: 180px;
        padding: 10px;
    }
    
    #sidebar h2 {
        font-size: 14px;
    }
    
    #sidebar h3 {
        font-size: 12px;
    }
    
    #sidebar button {
        padding: 8px;
        font-size: 12px;
    }
    
    #propertiesPanel {
        width: 200px;
        padding: 10px;
    }
    
    .tool-btn, #toolbar button {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 600px) {
    /* На маленьких телефонах — полная перестройка */
    #app {
        flex-direction: column;
    }
    
    /* Боковая панель становится горизонтальной сверху */
    #sidebar {
        width: 100%;
        height: auto;
        max-height: 120px;
        padding: 10px;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        overflow-x: auto;
    }
    
    #sidebar h2, #sidebar h3 {
        width: 100%;
        margin-bottom: 5px;
        font-size: 12px;
    }
    
    #sidebar button {
        width: auto;
        padding: 6px 10px;
        font-size: 11px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    #projectsList {
        width: 100%;
        display: flex;
        gap: 5px;
        overflow-x: auto;
    }
    
    .project-item {
        min-width: 120px;
        margin-bottom: 0;
    }
    
    /* Toolbar становится компактнее */
    #toolbar {
        padding: 5px;
        gap: 5px;
    }
    
    .tool-btn, #toolbar button {
        padding: 6px 8px;
        font-size: 11px;
        flex: 1;
        min-width: 60px;
    }
    
    /* Properties panel становится плавающей снизу */
    #propertiesPanel {
        width: 100%;
        height: 150px;
        border-left: none;
        border-top: 1px solid #bdc3c7;
        padding: 10px;
    }
    
    /* Canvas занимает всё оставшееся место */
    #canvasContainer {
        flex: 1;
        min-height: 200px;
    }
    
    /* Modals на весь экран */
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
    }
}

@media (max-width: 400px) {
    /* На очень маленьких экранах */
    #sidebar {
        max-height: 100px;
    }
    
    #sidebar button {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .tool-btn, #toolbar button {
        padding: 5px 6px;
        font-size: 10px;
    }
}
