:root {
    --title-font-size: 16px;
    --title-color: #ff0000;
    --order-number-font-size: 12px;
    --order-number-color: #000000;
    --from-title-font-size: 12px;
    --from-title-color: #000000;
    --from-address-font-size: 10px;
    --from-address-color: #000000;
    --ship-to-title-font-size: 20px;
    --ship-to-title-color: #000000;
    --ship-to-address-font-size: 18px;
    --ship-to-address-color: #000000;
    --special-note-font-size: 10px;
    --special-note-color: #000000;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.header {
    background-color: #ffffff;
    padding: 20px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.header h1 {
    margin: 0;
    font-size: 24px;
    color: #2c3e50;
}

.header p {
    margin: 5px 0 0;
    font-size: 14px;
    color: #7f8c8d;
}

.toggle-toolbar {
    position: absolute;
    right: 20px;
    top: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.toggle-toolbar svg {
    display: block;
}

.toolbar {
    display: none;
    background-color: #ffffff;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 80px;
    z-index: 900;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.toolbar h2 {
    margin: 0 0 10px;
    font-size: 18px;
    color: #2c3e50;
}

.customization-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.customization-section label {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #2c3e50;
}

.customization-section input[type="number"],
.customization-section select,
.customization-section input[type="color"] {
    margin-left: 5px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.customization-section input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
}

.reset-button {
    grid-column: span 2;
    justify-self: center;
}

.input-container {
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
}

.drop-zone {
    border: 2px dashed #3498db;
    border-radius: 8px;
    padding: 20px;
    background-color: #ffffff;
    transition: background-color 0.3s, border-color 0.3s;
    cursor: pointer;
    margin-bottom: 20px;
}

.drop-zone.dragover {
    background-color: #e1f0fa;
    border-color: #2980b9;
}

.drop-zone p {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
}

.drop-zone input[type="file"] {
    display: none;
}

.manual-add {
    margin: 20px 0;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.manual-add input,
.manual-add textarea {
    width: calc(100% - 20px);
    margin: 5px 0;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.manual-add textarea {
    height: 80px;
    resize: vertical;
}

.custom-label-form {
    display: none;
    margin-top: 20px;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.custom-label-form input {
    width: calc(100% - 20px);
    margin: 5px 0;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.title-input {
    margin: 10px 0;
    padding: 8px;
    width: calc(100% - 20px);
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.toggle-form,
.modal-button {
    background: none;
    border: none;
    color: #3498db;
    font-size: 14px;
    cursor: pointer;
    margin: 10px;
}

.toggle-form:hover,
.modal-button:hover {
    text-decoration: underline;
}

.action-button {
    padding: 10px 20px;
    background-color: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin: 10px 5px;
}

.action-button:hover {
    background-color: #2980b9;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 100%;
    text-align: left;
}

.modal-content h2 {
    margin: 0 0 10px;
    font-size: 18px;
    color: #2c3e50;
}

.modal-content input {
    width: calc(100% - 20px);
    margin: 5px 0;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.loading {
    display: none;
    margin: 20px auto;
    text-align: center;
    font-size: 16px;
    color: #7f8c8d;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #3498db;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.labels-container {
    /* margin: 20px auto; */
    /* max-width: 595px; */
            align-self: center;
        justify-self: center;
}

.a4-sheet {
    width: 800px;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 50px;
    justify-content: flex-start;
    page-break-after: always;
    margin-bottom: 20px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.label-container {
    width: 800px;
    height: 700px;
    border: 2px solid #000;
    box-sizing: border-box;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #fff;
    position: relative;
    --label-font-family: 'Roboto', Arial, sans-serif;
    font-family: var(--label-font-family);
}

.title {
    text-align: center;
    color: var(--title-color);
    font-size: var(--title-font-size);
    font-weight: bold;
    border: 1px solid #000;
    padding: 4px;
    margin: 10px;
    
}

.order-number {
    text-align: center;
    font-size: var(--order-number-font-size);
    color: var(--order-number-color);
    font-weight: bold;
    /* margin-bottom: 8px; */
}

.section {
    display: flex;
    justify-content: space-between;
}

.from,
.ship-to {
    width: 60%;
}

.from h3 {
    margin: 10px 10px 4px 10px;
    font-size: var(--from-title-font-size);
    color: var(--from-title-color);
}

.from p {
    font-size: var(--from-address-font-size);
    color: var(--from-address-color);
    margin: 10px 10px 4px 10px;
}

.ship-to {
    text-align: center;
}

.ship-to h3 {
    margin: 0 0 4px;
    font-size: var(--ship-to-title-font-size);
    color: var(--ship-to-title-color);
}

.ship-to p {
    font-size: var(--ship-to-address-font-size);
    color: var(--ship-to-address-color);
    margin: 0 0 2px;
    text-align: center;
    width: 21ch; /* wrap after approx. 20 characters */
  overflow-wrap: break-word;
}

.special-note {
    font-size: var(--special-note-font-size);
    color: var(--special-note-color);
    margin-top: 8px;
    border-top: 1px solid #000;
    padding-top: 4px;
}

.delete-button,
.edit-button,
.save-button,
.cancel-button {
    position: absolute;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.delete-button {
    top: 8px;
    right: 8px;
    background-color: #e74c3c;
    color: #fff;
}

.delete-button:hover {
    background-color: #c0392b;
}

.edit-button {
    top: 8px;
    right: 60px;
    background-color: #3498db;
    color: #fff;
}

.edit-button:hover {
    background-color: #2980b9;
}

.save-button {
    background-color: #3498db;
    color: #fff;
    bottom: 8px;
    right: 60px;
}

.save-button:hover {
    background-color: #2980b9;
}

.cancel-button {
    background-color: #7f8c8d;
    color: #fff;
    bottom: 8px;
    right: 8px;
}

.cancel-button:hover {
    background-color: #6c7a89;
}

.edit-form {
    display: none;
    padding: 8px;
    flex-grow: 1;
    flex-direction: column;
    gap: 4px;
}

.edit-form input,
.edit-form textarea {
    width: calc(100% - 10px);
    margin: 2px 0;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 10px;
}

.edit-form textarea {
    height: 40px;
    resize: vertical;
}

.print-button {
    margin: 0 auto 20px;
    display: none;
    padding: 10px 20px;
    background-color: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.print-button:hover {
    background-color: #2980b9;
}

@media print {
    body * {
        visibility: hidden;
    }
    .labels-container,
    .labels-container * {
        visibility: visible;
        background-color: #FFF;
    }
    .labels-container {
        margin: 0;
        position: absolute;
        top: 0;
        left: 0;
        
    }
    .a4-sheet {
        margin: 0;
        box-shadow: none;
        break-after: page;
        width: 100%;
        
        
    }
    .label-container {
        display: flex;
        justify-content: center;
        /* align-items: flex-end; */
        border: 2px solid #000;
        font-family: var(--label-font-family);
        width: 1000px !important;
        /* background-color: #2980b9; */
        height: 692px !important;
        margin: 0;
        padding: 0;

      
    }
    .header,
    .toolbar,
    .input-container,
    .print-button,
    .loading,
    .delete-button,
    .edit-button,
    .edit-form,
    .save-button,
    .cancel-button,
    .modal {
        display: none !important;
        visibility: hidden !important;
    }
}

@media (max-width: 768px) {

    
    .toolbar {
        top: 100px;
    }
    .customization-section {
        grid-template-columns: 1fr;
    }
    .a4-sheet {
        width: 100%;
        height: auto;
        /* transform: scale(0.8); */
        transform-origin: top;
    }
    .label-container {
        width: 100%;
        height: auto;
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 20px;
    }
    .header p {
        font-size: 12px;
    }
    .toggle-toolbar {
        right: 10px;
        top: 15px;
    }
    .toggle-toolbar svg {
        width: 20px;
        height: 20px;
    }
    .toolbar {
        padding: 5px;
    }
    .toolbar h2 {
        font-size: 16px;
    }
    .customization-section label {
        font-size: 12px;
    }
    .input-container {
        padding: 0 10px;
    }

        .label-container {
       transform: scale(0.5);
    }
}