/**
 * Poprawki dla panelu elementów graficznych
 */

/* Panel elementów - szerokość i scroll */
.cm-design-elements {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    /* Height synchronized via JS for reliability across layouts */
    height: auto;
    overflow-y: auto;
}

/* Kategorie - zakładki */
.cm-element-categories {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.cm-category-btn {
    padding: 8px 16px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    text-align: center;
}

.cm-category-btn:hover {
    background: #e8e8e8;
}

.cm-category-btn.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Grid elementów */
.cm-element-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 15px 5px;
    width: 100%;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ukryta siatka elementów (wymuszone) */
.cm-element-grid.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Pojedynczy element */
.cm-element-item {
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
    cursor: move;
    transition: all 0.3s;
    min-height: 100px;
    height: 100px;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

.cm-element-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-color: #007cba;
    background: #fff;
}

.cm-element-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

/* Obrazek elementu */
.cm-element-item img {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
}

/* Nazwa elementu */
.cm-element-name {
    font-size: 11px;
    margin-top: 5px;
    color: #666;
    word-break: break-word;
}

/* Placeholder dla elementów bez obrazka */
.cm-element-svg-placeholder,
.cm-element-text-placeholder,
.cm-element-placeholder {
    width: 60px;
    height: 60px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    border-radius: 4px;
    color: #666;
    font-size: 10px;
    text-align: center;
    padding: 5px;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Właściwości obiektu */
.cm-properties-panel {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.cm-properties-panel h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
}

.cm-property-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.cm-property-row label {
    flex: 0 0 80px;
    font-size: 12px;
    color: #666;
}

.cm-property-row input[type="range"] {
    flex: 1;
}

.cm-property-row input[type="number"] {
    width: 60px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

/* Scrollbar styling */
.cm-design-elements::-webkit-scrollbar {
    width: 8px;
}

.cm-design-elements::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cm-design-elements::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cm-design-elements::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsywność */
@media (max-width: 1200px) {
    .cm-design-layout {
        flex-direction: column;
    }
    
    .cm-design-canvas-area,
    .cm-design-elements {
        max-width: 100%;
        width: 100%;
        min-width: auto;
    }
    
    .cm-design-elements {
        height: 400px;
        margin-top: 20px;
        padding-left: 0;
    }
}
