/* Gaya Asas */
body {
    background-color: #e9e9e9;
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
}

/* Gaya Halaman Katalog */
.page {
    position: relative;
    background: white;
    width: 210mm;
    height: 297mm;
    display: flex;
    flex-direction: column;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
    box-sizing: border-box;
}

.cover {
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: #2c3e50;
    color: white;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative; /* Penting untuk posisi teks */
}

/* === GAYA UNTUK TEKS BOLEH ALIH === */
.editable-text-wrapper {
    position: absolute;
    cursor: move;
    padding: 5px;
    border: 1px dashed transparent;
    transition: border-color 0.2s;
    z-index: 10;
}

.editable-text-wrapper:hover {
    border-color: #3498db;
}

.editable-text-wrapper.dragging {
    border-color: #e74c3c !important;
    opacity: 0.8;
    z-index: 1001; /* Pastikan ia di atas elemen lain semasa diseret */
}

.editable-text-wrapper .text-content {
    outline: none; /* Buang bingkai semasa edit */
}

.editable-text-wrapper h1 {
    font-size: 52px;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    margin: 0;
}

.editable-text-wrapper p {
    font-size: 26px;
    font-style: italic;
    text-shadow: 1px 1px 6px rgba(0,0,0,0.5);
    margin: 0;
}

.delete-text-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: none; /* Sembunyi secara lalai */
    text-align: center;
    line-height: 22px;
    font-weight: bold;
    font-size: 14px;
    z-index: 20;
}

.editable-text-wrapper:hover .delete-text-btn {
    display: block; /* Paparkan bila hover pada wrapper */
}

.content {
    padding: 10mm;
    box-sizing: border-box;
}

/* Gaya Produk */
.image-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: flex-end;
    margin-bottom: 0;
}

.image-placeholder {
    position: relative;
    width: 55mm;
    height: 55mm;
    background-color: #f0f0f0;
    border: 2px dashed #cccccc;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #aaa;
    transition: background-color 0.2s, border-color 0.2s;
}

.image-placeholder.drag-over {
    background-color: #e0eaf1;
    border-color: #3498db;
}

.image-placeholder span {
    pointer-events: none;
}

.edit-product-btn {
    width: 80%;
    background-color: #2c3e50;
    color: white;
    text-align: center;
    border-radius: 4px;
    margin-top: 4mm;
    margin-bottom: 4mm;
    padding: 5px 0;
    font-size: 13px;
    cursor: pointer;
    border: none;
    font-weight: bold;
}

.product-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.product-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background-color: transparent;
}

.product-code {
    margin: 0 0 5px 0;
    font-weight: bold;
    font-size: 14px;
    color: #2c3e50;
}

.size-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    min-height: 15mm;
}

.size-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    font-size: 12px;
    color: #333;
}

.size-price {
    font-weight: bold;
    margin-left: 10px;
    color: #c0392b;
}

/* Gaya Butang Terapung */
#add-page-btn, #edit-background-btn, #export-pdf-btn, #bulk-upload-btn, #add-text-btn {
    padding: 12px 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    border: none;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    position: fixed;
    right: 20px;
    font-family: inherit;
}

#add-page-btn {
    bottom: 20px;
    background-color: #27ae60;
}

#bulk-upload-btn {
    bottom: 80px;
    background-color: #f39c12;
}

#add-text-btn {
    bottom: 140px;
    background-color: #8e44ad;
}

#edit-background-btn {
    bottom: 200px; 
    background-color: #3498db;
}

#export-pdf-btn {
    top: 20px;
    background-color: #c0392b;
}

#export-pdf-btn:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,.3);
    position: relative;
}

.modal-content h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

input[type=text],
input[type=file] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
}

input[type=color] {
    width: 100%;
    height: 40px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    cursor: pointer;
}

.modal-actions {
    text-align: right;
    margin-top: 20px;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    margin-left: 10px;
    font-family: inherit;
}

#modal-size-editor {
    border-top: 1px solid #eee;
    margin-top: 20px;
    padding-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.modal-size-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.modal-size-row input {
    margin-right: 10px;
}
.modal-size-row .input-size {
    flex: 3;
}
.modal-size-row .input-price {
    flex: 2;
}

.btn-delete-modal-row {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 8px 12px;
    font-weight: bold;
}

#btn-add-modal-row {
    background-color: #3498db;
    color: white;
    padding: 8px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
}

#btn-modal-save,
#btn-bg-modal-save,
#btn-export-confirm {
    background-color: #27ae60;
    color: white;
}

#btn-modal-cancel,
#btn-bg-modal-cancel,
#btn-export-cancel {
    background-color: #e0e0e0;
    color: #333;
}

#background-modal .form-group {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

#background-modal .form-group:last-of-type {
    border-bottom: none;
}

.btn-remove-bg {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 8px;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,.7);
    color: white;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    z-index: 3000;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    opacity: .5;
    transition: opacity .2s;
    z-index: 10;
}

.page:hover .delete-btn {
    opacity: 1;
}

.page-number {
    position: absolute;
    bottom: 5mm;
    left: 50%;
    transform: translateX(-50%);
    font-size: 15px;
    color: #555;
    display: none;
}

.settings-group {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.settings-group:last-of-type {
    border-bottom: none;
}

.settings-group label {
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.settings-group small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #777;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider-container input[type=range] {
    flex-grow: 1;
    cursor: pointer;
}

.slider-container span {
    font-weight: bold;
    color: #2c3e50;
    min-width: 50px;
    text-align: right;
    background-color: #f0f4f8;
    padding: 5px 8px;
    border-radius: 4px;
}

.size-preview {
    margin-top: 20px;
    padding: 15px;
    background-color: #e9eef2;
    border-radius: 5px;
    text-align: center;
}

.size-preview p {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
}

.size-preview strong {
    font-size: 18px;
}