/* styles-desktop.css - Чистий CSS без банерів - З НОВИМ .btn-jpg - ВИПРАВЛЕНО КОНТЕЙНЕР + CROP */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* ✅ ДОДАНО - запобігання горизонтального скролу */
}

/* =================================================================== */
/* LAYOUT SYSTEM - ВИПРАВЛЕНО */
/* =================================================================== */

.main-layout {
    display: flex;
    margin: 0 auto;
    padding: 10px;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    width: 100%; /* ✅ ДОДАНО */
    max-width: 1000px; /* ✅ ЗМІНЕНО з 900px на 1000px */
}

.page-content {
    width: 100%; /* ✅ ВИДАЛЕНО max-width дублікат */
    flex: 1; /* ✅ ДОДАНО для повного використання простору */
}

.container {
    background: white;
    padding: 40px;
    min-height: calc(100vh - 160px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    width: 100%; /* ✅ КРИТИЧНЕ ДОДАВАННЯ */
    box-sizing: border-box; /* ✅ ВАЖЛИВО для правильного padding */
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
}

/* =================================================================== */
/* FOOTER */
/* =================================================================== */

.footer {
    background: #000000;
    padding: 25px 0;
    margin-top: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer-container {
    max-width: 1000px; /* ✅ ЗМІНЕНО з 900px на 1000px */
    margin: 0 auto;
    padding: 0 20px;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.footer-text {
    color: #ccc;
    font-size: 0.9em;
    text-align: center;
    margin: 0;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    flex-wrap: wrap;
}

.footer-link {
    color: #999;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    padding: 5px 0;
}

.footer-link:hover {
    color: #fff;
    transform: translateY(-1px);
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: #667eea;
    transition: width 0.3s ease;
}

.footer-link:hover::after {
    width: 100%;
}

.footer-link:not(:last-child)::before {
    content: '|';
    position: absolute;
    right: -15px;
    color: #555;
    font-weight: 300;
}

/* =================================================================== */
/* TYPOGRAPHY - ВИПРАВЛЕНО */
/* =================================================================== */

.section-title {
    color: #333;
    font-size: 1.8em;
    font-weight: 600;
    margin: 30px 0 20px 0;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    text-align: center;
    word-wrap: break-word; /* ✅ ДОДАНО */
    width: 100%; /* ✅ ДОДАНО */
}

.section-title.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 40px;
    font-size: 2.8em;
    font-weight: 700;
    word-wrap: break-word; /* ✅ ДОДАНО */
    hyphens: auto; /* ✅ ДОДАНО */
    max-width: 100%; /* ✅ ДОДАНО */
}

/* =================================================================== */
/* WORKSPACE & UPLOAD - ВИПРАВЛЕНО */
/* =================================================================== */

.workspace {
    border: 3px dashed #667eea;
    border-radius: 12px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    background: #f8f9fa;
    position: relative;
    transition: all 0.3s ease;
    width: 100%; /* ✅ ДОДАНО */
    box-sizing: border-box;
}

.workspace:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.workspace.has-image {
    border-style: solid;
    border-color: #2E7D32;
    border-radius: 12px;
    background: #e9ecef;
    min-height: auto;
    padding: 20px;
    width: 100%; /* ✅ ДОДАНО */
}

.upload-area {
    text-align: center;
    padding: 60px 20px;
}

.upload-text {
    color: #424242;
    font-size: 1.3em;
    margin-bottom: 25px;
    font-weight: 500;
}

.btn-upload {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 12px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(46, 125, 50, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-upload:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(46, 125, 50, 0.4);
}

#fileInput {
    display: none;
}

/* =================================================================== */
/* CANVAS & IMAGE DISPLAY - ВИПРАВЛЕНО ДЛЯ CROP OVERLAY */
/* =================================================================== */

.canvas-container {
    position: relative;
    display: block; /* ✅ ЗМІНЕНО з flex на block */
    text-align: center; /* ✅ ДОДАНО для центрування canvas */
    overflow: visible;
    max-width: 100%;
    max-height: 100%;
    background: #f8f9fa;
    width: 100%;
}

#canvas {
    display: block !important;
    max-width: 100%;
    max-height: 70vh;
    cursor: crosshair;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin: 0 auto !important; /* ✅ ДОДАНО НАЗАД для центрування canvas */
    position: relative; /* ✅ ДОДАНО для правильного позиціонування overlay */
}

/* =================================================================== */
/* CROP SYSTEM - CROP OVERLAY ТОЧНО ЯК CANVAS */
/* =================================================================== */

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto !important; /* ✅ ТОЧНО ЯК У CANVAS */
    display: none;
    pointer-events: none;
    z-index: 10;
    /* ✅ Розміри встановлюються через JavaScript */
}

/* ✅ ДОДАНО: ERASER MASK OVERLAY - ТОЧНО ЯК CANVAS */
.eraser-mask-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important; /* ✅ ЦЕНТРУВАННЯ ЯК У CANVAS */
    pointer-events: none !important;
    z-index: 997 !important;
}

.crop-box {
    position: absolute;
    border: 2px solid #1565C0;
    background: transparent;
    cursor: move;
    min-width: 30px;
    min-height: 30px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
    pointer-events: auto;
    z-index: 12; /* ✅ ДОДАНО */
}

/* ✅ ДОДАНО СТИЛІ ДЛЯ OVERLAY ЧАСТИН */
.overlay-part {
    position: absolute;
    background: rgba(0, 0, 0, 0.4); /* ✅ Напівпрозоре затемнення */
    pointer-events: none;
    z-index: 11; /* ✅ Між overlay та crop-box */
}

#overlayTop,
#overlayBottom,
#overlayLeft,
#overlayRight {
    position: absolute;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 11;
}

.crop-handle {
    position: absolute;
    background: #1565C0;
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    margin: -6px;
    z-index: 15; /* ✅ ПІДВИЩЕНО для кращої видимості */
    pointer-events: auto;
    transition: all 0.3s ease; /* ✅ ДОДАНО для плавності */
}

.crop-handle:hover {
    background: #0D47A1;
    transform: scale(1.2);
}

/* ✅ ПОКРАЩЕНО КУРСОРИ ДЛЯ HANDLES */
.crop-handle.nw { top: 0; left: 0; cursor: nw-resize; }
.crop-handle.ne { top: 0; right: 0; cursor: ne-resize; }
.crop-handle.sw { bottom: 0; left: 0; cursor: sw-resize; }
.crop-handle.se { bottom: 0; right: 0; cursor: se-resize; }
.crop-handle.n { top: 0; left: 50%; cursor: n-resize; }
.crop-handle.s { bottom: 0; left: 50%; cursor: s-resize; }
.crop-handle.w { top: 50%; left: 0; cursor: w-resize; }
.crop-handle.e { top: 50%; right: 0; cursor: e-resize; }

/* =================================================================== */
/* IMAGE CAROUSEL */
/* =================================================================== */

.image-carousel {
    margin: 20px 0 30px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    display: none;
    width: 100%; /* ✅ ДОДАНО */
}

.image-carousel.show {
    display: block;
}

.carousel-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.carousel-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.carousel-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 120px));
    gap: 10px;
    padding: 5px 0;
    max-width: 800px; /* ✅ ЗМІНЕНО з 800px на 700px */
    margin: 0 auto;
    grid-auto-rows: 100px;
    overflow-y: auto;
    max-height: 320px;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.carousel-container::-webkit-scrollbar {
    width: 6px;
}

.carousel-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.carousel-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.carousel-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.carousel-item {
    width: 100px;
    height: 100px;
    position: relative;
    border-radius: 8px;
    overflow: visible;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    flex-shrink: 0;
}

.carousel-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.carousel-item.active {
    border-color: #2E7D32;
    box-shadow: 0 0 0 1px #2E7D32;
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    background: 
        linear-gradient(45deg, #f8f8f8 25%, transparent 25%), 
        linear-gradient(-45deg, #f8f8f8 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #f8f8f8 75%), 
        linear-gradient(-45deg, transparent 75%, #f8f8f8 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.carousel-item .delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #C62828;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.carousel-item .delete-btn:hover {
    background: #B71C1C;
    transform: scale(1.1);
}

.add-image-btn {
    width: 100px;
    height: 100px;
    border: 2px dashed #667eea;
    border-radius: 8px;
    background: #f8f9ff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #667eea;
    font-weight: bold;
    gap: 4px;
    position: relative;
    padding: 8px 4px;
    flex-shrink: 0;
}

.add-btn-icon {
    font-size: 28px;
    font-weight: 300;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #667eea;
    line-height: 1;
    font-family: Arial, sans-serif;
    flex-shrink: 0;
    margin-top: 4px;
}

.add-btn-text {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    color: #667eea;
    transition: all 0.3s ease;
    word-wrap: break-word;
    hyphens: auto;
    max-width: 85px;
    padding: 0 2px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-image-btn:hover {
    border-color: #2E7D32;
    background: #e8f5e8;
    color: #2E7D32;
    transform: translateY(-2px);
}

.add-image-btn:hover .add-btn-icon,
.add-image-btn:hover .add-btn-text {
    color: #2E7D32;
}

.add-image-btn:hover .add-btn-icon {
    transform: scale(1.1);
}

/* =================================================================== */
/* CROP CONTROLS */
/* =================================================================== */

.crop-inline-controls {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin: 0 auto 15px;
    max-width: 900px; /* ✅ ЗМІНЕНО з 800px на 700px */
    width: 100%; /* ✅ ДОДАНО */
    box-sizing: border-box;
}

.crop-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: center;
}

.crop-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.crop-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.crop-toggle input:checked + .toggle-slider {
    background-color: #2E7D32;
}

.crop-toggle input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-weight: 600;
    color: #424242;
    font-size: 0.95em;
}

.custom-dimensions {
    transition: opacity 0.3s ease;
}

.custom-dimensions.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.dimension-inputs {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.dimension-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.dimension-field label {
    font-size: 0.85em;
    font-weight: 600;
    color: #424242;
}

.dimension-field input {
    width: 80px;
    padding: 6px 8px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: center;
    transition: border-color 0.3s ease;
}

.dimension-field input:focus {
    outline: none;
    border-color: #1565C0;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

.dimension-field input::placeholder {
    color: #424242;
    font-style: italic;
}

.aspect-ratios-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    transition: opacity 0.3s ease;
}

.aspect-ratios-inline.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.aspect-btn {
    padding: 8px 12px;
    border: 2px solid #1565C0;
    background: white;
    color: #1565C0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.aspect-btn:hover, .aspect-btn.active {
    background: #1565C0;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(21, 101, 192, 0.3);
}

.btn-crop {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(46, 125, 50, 0.3);
    margin: 7.5px auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-crop:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 125, 50, 0.4);
}

.btn-crop .btn-icon {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    display: inline-block;
    vertical-align: middle;
    margin: 0;
}

/* =================================================================== */
/* CONTROL PANELS - ВИПРАВЛЕНО */
/* =================================================================== */

.controls-section {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    width: 100%; /* ✅ ДОДАНО */
    box-sizing: border-box;
}

.controls-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: flex-start;
    width: 100%; /* ✅ ДОДАНО */
}

.control-group {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    min-width: 250px;
    flex: 1;
    max-width: 300px;
    box-sizing: border-box; /* ✅ ДОДАНО */
}

.control-group h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-label {
    font-weight: 600;
    color: #424242;
    font-size: 0.9em;
}

.control-value {
    font-weight: bold;
    color: #1565C0;
    font-size: 1em;
}

.file-size-estimate {
    font-weight: bold;
    color: #E65100;
    font-size: 0.9em;
    background: #FFF8E1;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #FFB74D;
}

.file-size-real {
    font-weight: bold;
    color: #2E7D32;
    font-size: 0.9em;
    background: #F1F8E9;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #66BB6A;
}

.control-group input[type="range"] {
    width: 100%;
    margin: 10px 0;
    accent-color: #1565C0;
    outline: none;
    transition: all 0.3s ease;
}

.control-group input[type="range"]:focus,
.control-group input[type="range"]:active {
    box-shadow: 0 0 0 4px rgba(21, 101, 192, 0.15);
    transform: translateY(-1px);
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #1565C0;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #0D47A1;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.4);
    transform: scale(1.1);
}

.control-group input[type="range"]::-webkit-slider-thumb:active {
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.6);
    transform: scale(1.05);
}

.control-group input[type="range"]::-webkit-slider-track {
    height: 6px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 3px;
    border: none;
    transition: background 0.3s ease;
}

.control-group input[type="range"]:focus::-webkit-slider-track {
    background: #d4e4f7;
}

.control-group input[type="range"]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #1565C0;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: #0D47A1;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.4);
    transform: scale(1.1);
}

.control-group input[type="range"]::-moz-range-thumb:active {
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.6);
    transform: scale(1.05);
}

.control-group input[type="range"]::-moz-range-track {
    height: 6px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 3px;
    border: none;
    transition: background 0.3s ease;
}

.control-group input[type="range"]:focus::-moz-range-track {
    background: #d4e4f7;
}

.control-group input[type="range"]:active {
    box-shadow: 0 0 0 6px rgba(21, 101, 192, 0.1);
}

/* =================================================================== */
/* ✅ ACTION BUTTONS - ЗАХИСТ ВІД MODAL СТИЛІВ + НОВИЙ .btn-jpg */
/* =================================================================== */

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
    margin-bottom: 30px;
    width: 100%; /* ✅ ДОДАНО */
}

/* ✅ КРИТИЧНЕ ВИПРАВЛЕННЯ: Захист кнопок від modal CSS + фіксована висота */
.action-buttons .btn,
.background-buttons-row .btn,
.carousel-container .btn {
    flex: none !important;  /* ✅ Скасовуємо flex: 1 з modal CSS */
    width: auto !important; /* ✅ Автоматична ширина */
    min-height: 54px;       /* ✅ ДОДАНО: Фіксована висота */
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box; /* ✅ ДОДАНО: Стабільні розміри */
}

.btn-primary {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    color: white;
    box-shadow: 0 5px 15px rgba(46, 125, 50, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(46, 125, 50, 0.4);
}

.btn-blue {
    background: #1565C0;
    color: white;
    box-shadow: 0 5px 15px rgba(21, 101, 192, 0.3);
}

.btn-blue:hover {
    background: #0D47A1;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(21, 101, 192, 0.4);
}

/* ✅ НОВИЙ КЛАС: .btn-jpg - СТАБІЛЬНА БІЛА КНОПКА БЕЗ РАМКИ */
.btn-jpg {
    background: #ffffff;
    color: #000000;
    /* ✅ БЕЗ BORDER ВЗАГАЛІ - ніякої тряски */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-height: 54px;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    flex: none !important;
    width: auto !important;
}

.btn-jpg:hover {
    background: #f8f9fa;        /* ✅ Легкий сірий фон */
    color: #000000;
    /* ✅ БЕЗ ЗМІНИ BORDER - стабільність */
    transform: translateY(-3px); /* ✅ ОДНАКОВИЙ підйом як WebP */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-jpg .btn-icon {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(0); /* ✅ Чорна іконка */
    display: inline-block;
    vertical-align: middle;
    margin: 0;
}

/* ✅ СТАРИЙ .btn-yellow - ЗАЛИШАЄМО ДЛЯ СУМІСНОСТІ */
.btn-yellow {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-yellow:hover {
    background: #f8f9fa;
    color: #000000;
    border: 2px solid #333333;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-yellow .btn-icon {
    filter: brightness(0) invert(0);
}

.btn-plus-background {
    background: #ffffff;
    border: none;
    color: #000000;
    box-shadow: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    transition: transform 0.3s ease;
    padding: 15px 30px;
    cursor: pointer;
}

.btn-plus-background:hover {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
    transform: translateY(-2px);
}

.btn-plus-background:focus {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
}

.btn-plus-background:active {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
    transform: none;
}

.plus-icon {
    width: 40px;
    height: 40px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.plus-text {
    font-weight: 600;
    color: #000000;
    font-size: 1.1em;
    transition: transform 0.3s ease;
}

.btn-eraser {
    background: #ffffff;
    border: none;
    color: #000000;
    box-shadow: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    transition: transform 0.3s ease;
    padding: 15px 30px;
    cursor: pointer;
}

.btn-eraser:hover {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
    transform: translateY(-2px);
}

.btn-eraser:focus {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
}

.btn-eraser:active {
    background: #ffffff;
    border: none;
    box-shadow: none;
    outline: none;
    transform: none;
}

.btn-eraser:hover .eraser-icon {
    transform: scale(1.15);
}

.eraser-icon {
    width: 34px;
    height: 34px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.background-buttons-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%; /* ✅ ДОДАНО */
}

#removeBackgroundBtn {
    margin: 0;
}

/* =================================================================== */
/* ✅ WEBP PREVIEW SECTION - FLEXBOX ЦЕНТРУВАННЯ */
/* =================================================================== */

.webp-preview-section {
    display: none;
    margin-top: 30px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 30px;
    border: 1px solid #dee2e6;
    width: 100%; /* ✅ ДОДАНО */
    box-sizing: border-box;
}

.webp-preview-section.show {
    display: block;
}

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.preview-image-container {
    width: 800px; /* ✅ ЗМІНЕНО на 800px як ви просили */
    height: 800px; /* ✅ ЗМІНЕНО на 800px як ви просили */
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.preview-image-container.loading {
    background: #f8f9fa;
}

.before-after-slider {
    position: relative;
    width: 100%;
    height: 100%;
    display: none;
    overflow: hidden;
}

.before-after-slider.active {
    display: block;
}

.original-image, .webp-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    width: auto;
    height: auto;
}

.original-image {
    z-index: 1;
}

.webp-image {
    clip-path: inset(0 50% 0 0);
    z-index: 2;
}

.slider-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #1565C0;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    background: #1565C0;
    border: 3px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: ew-resize;
    z-index: 15;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.slider-handle:hover {
    background: #0D47A1;
    transform: translate(-50%, -50%) scale(1.1);
}

.slider-handle::before,
.slider-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
}

.slider-handle::before {
    left: 8px;
    border-left: 6px solid white;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.slider-handle::after {
    right: 8px;
    border-right: 6px solid white;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.image-label {
    position: absolute;
    top: 20px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    z-index: 20;
}

.label-original {
    left: 20px;
}

.label-webp {
    right: 20px;
}

.preview-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preview-image.loaded {
    opacity: 1;
}

.preview-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #999;
    font-size: 1.1em;
}

.preview-placeholder-icon {
    font-size: 4em;
    margin-bottom: 15px;
    opacity: 0.3;
}

.download-info {
    text-align: center;
    margin-bottom: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 100%;
    margin: 0 0 15px 0;
    display: none;
}

.download-info-text {
    font-size: 1.1em;
    color: #333;
    font-weight: 600;
}

.rendering-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    text-align: center;
    color: #666;
    font-style: italic;
}

.rendering-indicator.show {
    display: block;
}

.crop-tool-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid #2E7D32;
    max-width: 400px;
    z-index: 30;
}

.crop-message-title {
    font-size: 1.3em;
    font-weight: 600;
    color: #2E7D32;
    margin-bottom: 10px;
}

.crop-message-text {
    color: #424242;
    font-size: 1em;
    line-height: 1.4;
}

/* =================================================================== */
/* PROGRESS INDICATORS */
/* =================================================================== */

.heic-conversion-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.heic-conversion-progress.show {
    display: flex;
}

.progress-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1565C0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.success-message {
    background: #e8f5e8;
    border: 2px solid #2E7D32;
    border-radius: 12px;
    padding: 15px;
    margin: 20px 0;
    text-align: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.success-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    color: #2e7d32;
}

.drag-over {
    border-color: #2E7D32 !important;
    background: #e8f5e8 !important;
    transform: scale(1.02);
}

.btn-icon {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(1);
    display: inline-block;
    vertical-align: middle;
    margin: 0;
}

/* =================================================================== */
/* FOCUS STATES */
/* =================================================================== */

input[type="number"]:focus,
input[type="file"]:focus,
button:focus,
.aspect-btn:focus,
.carousel-item:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.3);
}

/* =================================================================== */
/* RESPONSIVE ВИПРАВЛЕННЯ - ПЛАНШЕТИ ТА ВЕЛИКІ ЕКРАНИ */
/* =================================================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .main-layout {
        max-width: 100%; /* ✅ ПОВНА ШИРИНА ДЛЯ ПЛАНШЕТІВ */
        padding: 15px;
    }
    
    .container {
        padding: 30px;
    }
    
    h1 {
        font-size: 2.4em;
    }
    
    .preview-image-container {
        width: 100%;
        max-width: 700px;
        height: auto;
        aspect-ratio: 1;
    }
}

@media (min-width: 1400px) {
    .main-layout {
        max-width: 1000px; /* ✅ ЗМІНЕНО з 900px на 1000px */
    }
}