/* Paintify Styles - Full Width Layout */
.paintify-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 20px 30px;
    font-family: Arial, sans-serif;
    box-sizing: border-box;
}

.paintify-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

/* ========== ДВОКОЛОНКОВИЙ LAYOUT ========== */
.paintify-editor-layout {
    display: flex;
    gap: 25px;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
}

/* Ліва колонка - Canvas (70%) */
.paintify-left-column {
    flex: 0 0 70%;
    min-width: 0;
}

.paintify-left-column #paintify-canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Права колонка - Палітра та зони (30%) */
.paintify-right-column {
    flex: 0 0 calc(30% - 25px);
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 85vh;
    overflow-y: auto;
    padding-right: 5px;
    box-sizing: border-box;
}

/* ========== ЗОНА ЗАВАНТАЖЕННЯ ========== */
.paintify-drop-zone {
    border: 3px dashed #ccc;
    border-radius: 10px;
    padding: 60px 40px;
    text-align: center;
    background: #f9f9f9;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.paintify-drop-zone.dragover {
    border-color: #83b735;
    background: #f0f8e8;
    transform: scale(1.01);
}

.paintify-upload-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.paintify-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
    flex-wrap: wrap;
}

.paintify-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    background: #83b735;
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    font-weight: 600;
}

.paintify-btn:hover {
    background: #74a32f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(131, 183, 53, 0.3);
}

.paintify-btn-secondary {
    background: #6c757d;
}

.paintify-btn-secondary:hover {
    background: #545b62;
}

.paintify-btn-primary {
    background: #28a745;
}

.paintify-btn-primary:hover {
    background: #218838;
}

.paintify-hint {
    color: #999;
    font-size: 14px;
    margin-top: 15px;
}

/* ========== ЗАВАНТАЖЕННЯ ========== */
.paintify-loading,
.paintify-processing {
    text-align: center;
    padding: 60px;
}

.paintify-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #83b735;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: paintify-spin 1s linear infinite;
    margin: 0 auto 20px;
}

.paintify-spinner-small {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #28a745;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: paintify-spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

@keyframes paintify-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== РЕДАКТОР ========== */
.paintify-editor {
    margin-top: 20px;
    width: 100%;
}

#paintify-canvas {
    width: 100%;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: #fff;
}

/* ========== УПРАВЛІННЯ ========== */
.paintify-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

/* ========== AI КНОПКИ ========== */
.paintify-btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    padding: 14px 28px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
}

.paintify-btn-ai:hover:not(:disabled) {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6) !important;
}

.paintify-btn-ai:disabled {
    opacity: 0.6;
    cursor: wait !important;
}

.paintify-ai-status {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* ========== ІНСТРУМЕНТИ МАЛЮВАННЯ ========== */
.paintify-brush-tools {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 10px;
    margin: 15px 0;
    border: 2px solid #e9ecef;
}

.brush-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.brush-btn {
    padding: 10px 18px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 14px;
}

.brush-btn.active {
    border-color: #83b735;
    background: #83b735;
    color: white;
}

.brush-btn:hover {
    border-color: #83b735;
    transform: translateY(-1px);
}

.paintify-separator {
    color: #ccc;
    margin: 0 5px;
    font-size: 18px;
}

.brush-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brush-size-control input[type="range"] {
    width: 150px;
}

#paintify-toggle-brush.active {
    background: #83b735 !important;
    color: white !important;
}

/* ========== КНОПКИ ІНСТРУМЕНТІВ ========== */
#paintify-tool-brush.active,
#paintify-tool-rect.active {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
}

/* ========== ЗОНА-КОНТРОЛИ ========== */
.zone-controls {
    padding-top: 15px;
    border-top: 2px dashed #ddd;
    margin-top: 10px;
}

#paintify-new-zone-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
}

#paintify-new-zone-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ========== БЛОК ЗОН ========== */
.paintify-zones-block {
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 15px;
}

.paintify-zones-block h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #333;
}

.zones-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.paintify-btn-new-zone {
    padding: 8px 14px !important;
    font-size: 13px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
}

.paintify-btn-new-zone:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.paintify-zones-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
}

.zones-empty-hint {
    text-align: center;
    color: #999;
    font-size: 13px;
    font-style: italic;
    padding: 12px;
    margin: 0;
}

/* ========== КАРТКА ЗОНИ ========== */
.paintify-zone-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.paintify-zone-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.paintify-zone-item.active {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.zone-color-preview {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.zone-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.zone-name {
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-color-name {
    font-size: 11px;
    color: #667eea;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-delete-btn {
    background: transparent;
    border: none;
    color: #999;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.zone-delete-btn:hover {
    color: #e74c3c;
}

.paintify-zone-item.active .zone-delete-btn {
    color: rgba(0,0,0,0.4);
}

.paintify-zone-item.active .zone-delete-btn:hover {
    color: #ff6b6b;
}

/* ========== ПАЛІТРА В ПРАВІЙ КОЛОНЦІ ========== */
.paintify-right-column .paintify-color-palette {
    margin: 0;
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 18px;
}

.paintify-right-column .paintify-color-palette h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #333;
}

.paintify-right-column .paintify-palette-info {
    margin-bottom: 10px;
    font-size: 13px;
    color: #666;
}

.paintify-right-column .paintify-search-container {
    margin-bottom: 15px;
}

.paintify-right-column .paintify-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.paintify-right-column .paintify-search-input:focus {
    outline: none;
    border-color: #83b735;
}

.paintify-right-column .paintify-selected-info {
    margin: 12px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.paintify-right-column .paintify-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-height: 350px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fafafa;
}

.paintify-color-swatch {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.2s;
    position: relative;
}

.paintify-color-swatch:hover {
    transform: scale(1.15);
    border-color: #83b735;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
}

.paintify-color-swatch.active {
    border-color: #83b735;
    border-width: 3px;
    transform: scale(1.1);
}

.paintify-color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 0 0 3px white;
}

/* ========== КНОПКИ ДІЙ ========== */
.paintify-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

/* ========== АДАПТИВНІСТЬ ========== */

/* Великі екрани (1920px+) */
@media (min-width: 1920px) {
    .paintify-container {
        padding: 30px 50px;
    }
    
    .paintify-left-column {
        flex: 0 0 72%;
    }
    
    .paintify-right-column {
        flex: 0 0 calc(28% - 25px);
        min-width: 380px;
    }
}

/* Стандартні ПК (1200px - 1919px) */
@media (max-width: 1919px) and (min-width: 1200px) {
    .paintify-left-column {
        flex: 0 0 70%;
    }
    
    .paintify-right-column {
        flex: 0 0 calc(30% - 25px);
        min-width: 340px;
    }
}

/* Маленькі ПК та великі планшети (1024px - 1199px) */
@media (max-width: 1199px) and (min-width: 1024px) {
    .paintify-left-column {
        flex: 0 0 65%;
    }
    
    .paintify-right-column {
        flex: 0 0 calc(35% - 25px);
        min-width: 300px;
    }
}

/* Планшети (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .paintify-editor-layout {
        flex-direction: column;
    }
    
    .paintify-left-column,
    .paintify-right-column {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        max-height: none;
    }
    
    .paintify-right-column .paintify-colors {
        max-height: 250px;
    }
    
    .paintify-zones-list {
        max-height: 200px;
    }
}

/* Мобільні пристрої (< 768px) */
@media (max-width: 767px) {
    .paintify-container {
        padding: 15px;
    }
    
    .paintify-drop-zone {
        padding: 30px 20px;
    }
    
    .paintify-upload-icon {
        font-size: 50px;
    }
    
    .paintify-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .paintify-color-swatch {
        width: 42px;
        height: 42px;
    }
    
    .brush-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .paintify-actions {
        flex-direction: column;
    }
    
    .paintify-actions .paintify-btn {
        width: 100%;
    }
}

/* Дуже маленькі екрани (< 480px) */
@media (max-width: 479px) {
    .paintify-container {
        padding: 10px;
    }
    
    .paintify-buttons {
        flex-direction: column;
    }
    
    .paintify-buttons .paintify-btn {
        width: 100%;
    }
    
    .brush-controls {
        flex-direction: column;
    }
    
    .brush-size-control {
        width: 100%;
    }
    
    .brush-size-control input[type="range"] {
        width: 100%;
    }
}

/* ========== СКРОЛБАР ========== */
.paintify-right-column::-webkit-scrollbar,
.paintify-right-column .paintify-colors::-webkit-scrollbar,
.paintify-zones-list::-webkit-scrollbar {
    width: 8px;
}

.paintify-right-column::-webkit-scrollbar-track,
.paintify-right-column .paintify-colors::-webkit-scrollbar-track,
.paintify-zones-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.paintify-right-column::-webkit-scrollbar-thumb,
.paintify-right-column .paintify-colors::-webkit-scrollbar-thumb,
.paintify-zones-list::-webkit-scrollbar-thumb {
    background: #83b735;
    border-radius: 4px;
}

.paintify-right-column::-webkit-scrollbar-thumb:hover,
.paintify-right-column .paintify-colors::-webkit-scrollbar-thumb:hover,
.paintify-zones-list::-webkit-scrollbar-thumb:hover {
    background: #74a32f;
}

/* ========== 🔥 КНОПКА ТЕКСТУРИ ========== */
.paintify-tool-texture-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
    color: white !important;
    border: none !important;
}

.paintify-tool-texture-btn.active {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%) !important;
    box-shadow: 0 0 10px rgba(245, 87, 108, 0.5) !important;
}

/* ========== 🔥 ПІДКАЗКА ДЛЯ ТЕКСТУРИ ========== */
.paintify-texture-hint {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px 0;
    text-align: center;
    font-size: 13px;
    color: #856404;
    font-weight: 500;
}

/* ========== 🔥 КАРТКИ ТЕКСТУР В ПАЛІТРІ ========== */
.paintify-texture-swatch {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.paintify-texture-swatch:hover {
    transform: scale(1.1);
    border-color: #f5576c;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
    z-index: 10;
}

.paintify-texture-swatch img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    display: block;
}

.paintify-texture-swatch .texture-label {
    font-size: 10px;
    text-align: center;
    padding: 2px 4px;
    background: rgba(255,255,255,0.9);
    color: #333;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== 🔥 МІНІАТЮРА ТЕКСТУРИ В СПИСКУ ЗОН ========== */
.zone-texture-preview {
    width: 24px !important;
    height: 24px !important;
    border-radius: 4px !important;
    border: 1px solid rgba(0,0,0,0.2) !important;
}

/* ========== 🔥 АКТИВНА ТЕКСТУРА ========== */
.paintify-active-texture {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.active-texture-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.active-texture-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.active-texture-info span {
    flex: 1;
    font-size: 13px;
    color: #333;
}

.clear-texture-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
}

.clear-texture-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* ========== 🔥 АКТИВНА ТЕКСТУРА В ПАЛІТРІ ========== */
.paintify-texture-swatch.active-texture {
    border: 3px solid #667eea !important;
    box-shadow: 0 0 12px rgba(102, 126, 234, 0.6);
    transform: scale(1.05);
}

.paintify-texture-swatch.active-texture::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    background: #667eea;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.paintify-texture-swatch {
    position: relative;
}