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

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 28px;
}

#tools {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    justify-content: center;
}

button {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s, transform 0.1s;
}

button:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

/* Улучшенные стили для элементов управления */
#uploadBtn {
    background: #e74c3c;
}

#uploadBtn:hover {
    background: #c0392b;
}

#generateBtn {
    background: #2ecc71;
}

#generateBtn:hover {
    background: #27ae60;
}

#exportPdfBtn {
    background: #9b59b6;
}

#exportPdfBtn:hover {
    background: #8e44ad;
}

#printBtn, #printPosterBtn {
    background: #f39c12;
}

#printBtn:hover, #printPosterBtn:hover {
    background: #d35400;
}

label {
    margin-right: 10px;
    font-weight: bold;
    font-size: 14px;
    color: #555;
}

#canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    padding: 15px;
    max-width: 100%;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border: 1px solid #eee;
    image-rendering: -webkit-optimize-contrast;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
}

.info-message {
    margin-top: 20px;
    padding: 15px;
    background-color: #e8f4fd;
    border-radius: 8px;
    color: #3498db;
    font-size: 14px;
    border: 1px solid #bee5eb;
}

@media (max-width: 768px) {
    #tools {
        flex-direction: column;
        align-items: stretch;
    }
    
    button {
        width: 100%;
    }
    
    h1 {
        font-size: 24px;
    }
}

/* Стили для индикатора загрузки */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 30px 40px;
    border-radius: 12px;
    z-index: 10000;
    display: none;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    min-width: 280px;
    max-width: 90vw;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-indicator .spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Прогресс-бар внутри индикатора */
.progress-bar {
    width: 80%;
    height: 12px;
    background-color: #ddd;
    border-radius: 6px;
    margin: 15px auto;
    overflow: hidden;
    border: 1px solid #bbb;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: #3498db;
    transition: width 0.2s ease;
    border-radius: 6px;
}

.progress-text {
    margin-top: 10px;
    font-size: 16px;
    color: white;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Стили для счетчика цветов */
.color-count-container {
    margin: 20px auto;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    max-width: 800px;
    overflow-y: auto;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.color-count-container h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #343a40;
}

.color-count-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}

.color-item {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.color-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.color-square {
    width: 20px;
    height: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
}

.color-info {
    font-size: 14px;
    color: #495057;
}

.total-count {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: #e9ecef;
    border-radius: 6px;
    font-weight: bold;
    margin-top: 10px;
    color: #2c3e50;
}

/* Стили для кнопки выбора размера стразы и макета */
.stone-size-selector {
    position: relative;
    display: inline-block;
}

.stone-size-button {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #2980b9;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    min-width: 180px;
    text-align: center;
    transition: all 0.2s;
}

.stone-size-button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.stone-size-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stone-size-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
    border-bottom: 1px solid #eee;
}

.stone-size-item:last-child {
    border-bottom: none;
}

.stone-size-item:hover {
    background-color: #f1f1f1;
    color: #2c3e50;
}

/* ПЕЧАТЬ: скрываем всё, кроме холста */
@media print {
    body * {
        visibility: hidden;
    }
    #canvas-container, #canvas-container * {
        visibility: visible;
    }
    #canvas-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        text-align: center;
        padding: 10px;
        margin: 0;
    }
    canvas {
        max-width: 100%;
        height: auto;
        margin: 10px auto;
        display: block;
        border: none;
    }
    #tools, .color-count-container, .loading-indicator, .info-message {
        display: none !important;
    }
}

/* СТИЛИ ДЛЯ ПЕЧАТИ ПО ЛИСТАМ */
.print-poster-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px auto;
    max-width: 100%;
    background-color: #f0f0f0;
    padding: 20px;
    min-height: 100vh;
}

.print-poster-page {
    page-break-inside: avoid;
    break-inside: avoid;
    box-sizing: border-box;
    position: relative;
    border: 1px dashed #ccc;
    background: white;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
    padding: 10px;
}

.print-poster-page canvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}