.wc-engraving-frontend-wrapper {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
}
.wc-engraving-field-group {
    margin-bottom: 15px;
}
.wc-engraving-field-group > label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}
.text-input-row {
    display: flex;
    gap: 10px;
}
.engraving-input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ddd;
}
.engraving-font-select {
    width: 150px;
    padding: 8px;
}

.engraving-graphic-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.engraving-swatch {
    width: 50px;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    background-color: #fff;
    transition: border-color 0.2s;
}
.engraving-swatch:hover {
    border-color: #999;
}
.engraving-swatch.selected {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Dostosowanie do The7 (lub ogólnie) */
#wc-engraving-live-preview {
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: 5px;
    background: #fff;
}
/* Blokada scrolla strony gdy modal jest otwarty */
body.wc-modal-open {
    overflow: hidden !important;
}

/* Modal Style */
.wc-engraving-modal {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}
.wc-engraving-modal-content {
    background-color: #fefefe;
    margin: 0 auto;
    border: 1px solid #888;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow: hidden;
}
.wc-engraving-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}
.wc-engraving-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.wc-engraving-close:hover,
.wc-engraving-close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
.wc-engraving-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #f9f9f9;
}
.wc-engraving-preview-col {
    flex: 2;
    overflow: hidden;
    padding: 20px;
    user-select: none;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
/* Obrazek w lewej kolumnie - skaluj do dostępnej przestrzeni */
.wc-engraving-preview-col #wc-engraving-live-preview {
    width: 100%;
    max-height: 100%;
    overflow: hidden;
}
.wc-engraving-preview-col #wc-engraving-live-preview img {
    width: 100%;
    height: auto;
    display: block;
    max-height: calc(90vh - 120px);
    object-fit: contain;
}
.wc-engraving-tools-col {
    flex: 1 1 350px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-left: 1px solid #eee;
}
.wc-engraving-tools-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    min-height: 0;
}
.wc-engraving-tools-footer {
    flex: 0 0 auto;
    padding: 16px 20px;
    background: #fff;
    border-top: 2px solid #eee;
}
/* Przycisk zatwierdzenia - wszystkie style z !important żeby motyw nie mógł ich nadpisać */
.wc-engraving-btn {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    padding: 16px !important;
    background: #28a745 !important;
    background-color: #28a745 !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: bold !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    text-align: center !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4) !important;
    transition: background 0.2s !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}
.wc-engraving-btn:hover,
.wc-engraving-btn:focus {
    background: #218838 !important;
    background-color: #218838 !important;
    color: #fff !important;
    outline: none !important;
}

/* ================================================
   RESPONSIVE - MOBILE (max-width: 768px)
   ================================================ */
@media (max-width: 768px) {

    /* Modal zajmuje cały ekran */
    .wc-engraving-modal {
        align-items: flex-start;
        padding: 0;
    }
    .wc-engraving-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        height: 100dvh; /* dynamic viewport height - obsługuje pasek adresu Safari */
        border-radius: 0;
        margin: 0;
        border: none;
    }

    /* Header bardziej zwarty */
    .wc-engraving-modal-header {
        padding: 12px 15px;
        flex-shrink: 0;
    }
    .wc-engraving-modal-header h3 {
        font-size: 16px !important;
    }

    /* Body zmienia kierunek na kolumnowy */
    .wc-engraving-modal-body {
        flex-direction: column;
        overflow: hidden;
    }

    /* Podgląd zdjęcia - miniatura na górze, ograniczona wysokość */
    .wc-engraving-preview-col {
        flex: 0 0 auto;
        max-height: 35vh;
        padding: 10px;
        overflow: hidden;
        background: #f0f0f0;
        border-bottom: 1px solid #ddd;
        justify-content: center;
        align-items: center;
    }
    .wc-engraving-preview-col #wc-engraving-live-preview {
        max-height: 100%;
        width: auto;
        max-width: 100%;
    }
    .wc-engraving-preview-col #wc-engraving-live-preview img {
        max-height: calc(35vh - 20px);
        width: auto;
        max-width: 100%;
        object-fit: contain;
        display: block;
        margin: 0 auto;
    }

    /* Kolumna narzędzi - zajmuje resztę */
    .wc-engraving-tools-col {
        flex: 1 1 0;
        min-height: 0;
        max-width: 100%;
        border-left: none;
    }
    .wc-engraving-tools-scroll {
        padding: 15px;
    }

    /* Większe elementy dotykowe */
    .engraving-input {
        padding: 12px 10px;
        font-size: 16px; /* zapobiega auto-zoom na iOS */
        border-radius: 4px;
    }
    .engraving-font-select {
        padding: 12px 8px;
        font-size: 16px;
        width: auto;
        flex: 1;
        min-width: 0;
        max-width: 140px;
    }
    .text-input-row {
        gap: 8px;
    }

    /* Swatche graficzne - większe na dotyk */
    .engraving-swatch {
        width: 56px;
        height: 56px;
        touch-action: manipulation;
    }
    .engraving-graphic-swatches {
        gap: 8px;
    }

    /* Grupy pól - mniejszy margines */
    .wc-engraving-field-group {
        margin-bottom: 12px;
    }

    /* Stopka z przyciskiem */
    .wc-engraving-tools-footer {
        padding: 12px 15px;
    }
    .wc-engraving-btn {
        padding: 18px !important;
        font-size: 17px !important;
    }
}

/* Bardzo małe ekrany (iPhone SE itp.) */
@media (max-width: 375px) {
    .wc-engraving-preview-col {
        max-height: 28vh;
    }
    .wc-engraving-preview-col #wc-engraving-live-preview img {
        max-height: calc(28vh - 20px);
    }
    .engraving-swatch {
        width: 48px;
        height: 48px;
    }
    .engraving-font-select {
        max-width: 120px;
        font-size: 14px;
    }
}
