/* General Body & Font Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    display: grid;
    place-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

/* Main Application Container */
.container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 100%;
    text-align: center;
}

h1 { color: #0056b3; margin-bottom: 10px; }
p { color: #666; margin-bottom: 30px; }

/* Form Styling */
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; color: #444; }

/* CHANGE: Added textarea to the selector group for consistent styling */
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px;
    font-size: 16px; font-family: inherit; /* Ensure textarea uses the body font */
    box-sizing: border-box; transition: border-color 0.3s, box-shadow 0.3s;
}

/* Add a vertical resize handle to the textarea for better UX */
.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #007bff; box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
}

/* Button Styling */
.button-group { display: flex; gap: 15px; justify-content: center; margin-top: 10px; }
button {
    padding: 12px 25px; font-size: 16px; font-weight: 600; border: none;
    border-radius: 6px; cursor: pointer; transition: background-color 0.3s, transform 0.2s;
}
#generate-btn { background-color: #007bff; color: white; }
#generate-btn:hover { background-color: #0056b3; transform: translateY(-2px); }
#print-btn { background-color: #28a745; color: white; }
#print-btn:hover { background-color: #1e7e34; transform: translateY(-2px); }
.hidden { display: none; }

/* ... (all previous CSS is the same until the output section) ... */

/* --- Output Area Styling --- */
#output-area {
    margin-top: 30px; padding: 20px; border: 1px dashed #ddd; border-radius: 8px;
    min-height: 100px; display: flex; flex-wrap: wrap; justify-content: center;
    align-items: flex-start; gap: 20px;
}

.output-wrapper {
    display: flex; align-items: center; justify-content: center;
    gap: 15px;
}

/* This container will hold the QR canvas/img or the Data Matrix SVG */
.code-image {
    display: flex; /* Helps center content if an error message is shown */
    align-items: center;
    justify-content: center;
}

/* Ensure generated images/svgs/canvases don't overflow their container */
.code-image img,
.code-image canvas,
.code-image svg {
    display: block; /* Removes any extra space below the element */
    margin: auto;
}

/* Flexbox direction classes for text position */
.position-below { flex-direction: column; }
.position-above { flex-direction: column-reverse; }
.position-right { flex-direction: row; }
.position-left { flex-direction: row-reverse; }

/* The text label itself */
.qr-text-label {
    margin: 0; font-weight: 500; color: #333;
    word-break: break-all; text-align: center;
    white-space: pre-wrap;
}

/* --- Print-specific Styles --- */
@media print {
    body, .container, .button-group, .form-group {
        visibility: hidden; margin: 0; padding: 0; box-shadow: none;
    }
    #output-area, #output-area * { visibility: visible; }
    #output-area {
        position: absolute; left: 0; top: 0; width: 100%; border: none;
    }
}
