/*
This new CSS provides a professional and modern look for the plugin.
It uses a clean layout, consistent spacing, and smooth transitions.
*/

:root {
    --primary-color: #0073e6;
    --secondary-color: #555;
    --background-color: #f5f7fa;
    --card-background-color: #fff;
    --border-color: #e0e6ed;
    --hover-color: #005bb5;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--secondary-color);
    margin: 0;
    padding: 20px;
}

.ttb-labels-container {
    background-color: var(--card-background-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 30px;
    max-width: 900px;
    margin: 40px auto;
}

.ttb-labels-container h2 {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--secondary-color);
}

#ttb-label-format {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: #fff;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-speed) ease-in-out;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23555' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

#ttb-label-format:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 115, 230, 0.2);
    outline: none;
}

.ttb-labels-table {
    margin-top: 25px;
}

.ttb-labels-sheet {
    border-collapse: separate;
    border-spacing: 5px;
    width: 100%;
}

.ttb-labels-sheet td {
    padding: 0;
    border: none;
    position: relative; /* Needed for positioning the link */
    text-align: right;
}

.ttb-labels-sheet textarea {
    width: 100%;
    height: 100px;
    resize: none;
    font-size: 14px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: #fcfdfe;
    transition: all var(--transition-speed);
}

.ttb-labels-sheet textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 115, 230, 0.2);
    outline: none;
}

.customize-text-link {
    font-size: 12px;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 5px;
    transition: color var(--transition-speed);
    float: right;
}

.customize-text-link:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

.apply-to-all-link {
    font-size: 12px;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 5px;
    transition: color var(--transition-speed);
    float: left;
}

.apply-to-all-link:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

.ttb-labels-buttons {
    margin: 20px 0;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.ttb-labels-buttons button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform 0.1s ease-in-out;
    box-shadow: var(--shadow);
}

#ttb-print-labels {
    background-color: var(--primary-color);
    color: #fff;
}

#ttb-print-labels:hover {
    background-color: var(--hover-color);
    transform: translateY(-2px);
}

#ttb-fill-labels, #ttb-check-all-labels, #ttb-uncheck-all-labels {
    background-color: var(--secondary-color);
    color: #fff;
}

#ttb-fill-labels:hover, #ttb-check-all-labels:hover, #ttb-uncheck-all-labels:hover {
    background-color: #333;
    transform: translateY(-2px);
}

/* Modal styles */
.ttb-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 99999; /* Increased for maximum precedence */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.5); /* Slightly darker overlay */
    backdrop-filter: blur(5px);
    
    /* Using flexbox for reliable centering */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure the initial state is hidden for flexbox */
.ttb-modal:not(.is-visible) {
    display: none;
}

.ttb-modal-content {
    background-color: var(--card-background-color);
    padding: 30px;
    border-radius: 12px;
    max-width: 700px;
    box-shadow: var(--shadow);
    z-index: 100000;
}
/* Fixed width for the modal content to prevent resizing */
.ttb-modal-content .wp-editor-wrap {
    width: 640px !important;
    overflow: auto;
}

.ttb-close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.ttb-close-modal:hover,
.ttb-close-modal:focus {
    color: #000;
    text-decoration: none;
}

/* Sample Display styles */
.ttb-sample-heading {
    margin-top: 40px;
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

#ttb-sample-display {
    border: 1px solid #000;
    min-height: 150px;
    padding: 20px;
    margin-top: 20px;
    background-color: #fdfdfd;
    overflow: auto;
}

.ttb-sample-sheet {
    width: 8.5in;
    height: 11in;
    margin: 0.5in auto;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    flex-wrap: wrap;
    box-sizing: border-box;
    align-content: center;
    justify-content: center;
}

.ttb-sample-label-box {
    box-sizing: border-box;
    border: 1px dashed #ccc;
    overflow: hidden;
    padding: 0.125in;
    font-family: Arial, sans-serif;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.ttb-sample-label-box > div {
    /* This inner div will now receive the dynamic font-size */
    overflow: hidden;
}

/* Fixed dimensions for each label format */
.ttb-sample-sheet.template-5160 .ttb-sample-label-box {
    width: 2.625in;
    height: 1in;
}
.ttb-sample-sheet.template-5163 .ttb-sample-label-box {
    width: 4in;
    height: 2in;
}

.ttb-sample-sheet.template-5164 .ttb-sample-label-box {
    width: 4in;
    height: 3.333in;
}
    
.ttb-sample-sheet.template-5162 .ttb-sample-label-box {
    width: 4in;
    height: 1.333in;
}
    
.ttb-sample-sheet.template-5167 .ttb-sample-label-box {
    width: 1.75in;
    height: 0.5in;
}
    
.ttb-sample-sheet.template-5161 .ttb-sample-label-box {
    width: 4in;
    height: 1in;
}
    
.ttb-sample-sheet.template-5195 .ttb-sample-label-box {
    width: 1.75in;
    height: 0.666in;
}
    
.ttb-sample-sheet.template-5168 .ttb-sample-label-box {
    width: 3.5in;
    height: 5in;
}

/* New styles for the form and checkboxes */
#ttb-address-form h3 {
    margin-top: 30px;
}
.ttb-form-group {
    margin-bottom: 15px;
}
.ttb-city-zip-group {
    display: flex;
    gap: 15px;
}

.ttb-city-input {
    flex: 3;
}

.ttb-zip-input {
    flex: 2;
}


.ttb-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: all var(--transition-speed);
}

.ttb-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 115, 230, 0.2);
    outline: none;
}

#ttb-checkbox-container h3 {
    margin-top: 30px;
}

.ttb-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.ttb-checkbox-item {
    display: flex;
    align-items: center;
}

.ttb-checkbox-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* New styles for font size slider */
.ttb-slider-container {
    margin: 20px auto;
    text-align: center;
    max-width: 400px;
}

#ttb-font-size-range {
    width: 100%;
    margin-top: 10px;
}
#ttb-fill-labels-button-container {
    margin: 20px 0;
}
/* Print-specific styles using a class on the body to trigger */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: #fff;
        font-family: Helvetica, Arial, sans-serif;
    }

    body:not(.ttb-is-printing) {
        display: none !important;
    }

    .ttb-print-container {
        display: block !important;
        position: relative !important;
    }
}
