:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --border-color: #dee2e6;
    --text-color: #212529;
    --diff-color: #fff3cd;
    --suggested-color: #fff3cd;
    --selected-color: #cce5ff;
    --font-family: 'Inter', sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 15px 20px;
    line-height: 1.2;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    gap: 20px; /* Add gap between header items */
}

header h1 {
    margin-top: 0.1rem;
    margin-bottom: 0.1rem;
}

header p {
    color: var(--secondary-color);
    max-width: 840px;
    margin: 0 auto;
}

.header-main-content {
    flex-grow: 1;
    text-align: center;
}

.header-title-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 30px; /* Adjust size as needed */
    width: auto;
}

#user-profile-section {
    /* position: absolute; */ /* Replaced with flexbox */
    /* top: 0px; */
    /* right: 5px; */
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent this section from shrinking */
    align-items: flex-end; /* Align items to the right */
    gap: 5px; /* Add some space between the elements */
}

#template-management-container {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    padding: 5px;
    background-color: var(--surface-color);
    border-radius: 6px;
}
main {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.file-selectors {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    background: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.file-control {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-control h2 {
    margin: 0;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-type-selector {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
}

/* Visually hide the default file input but keep it accessible */
.file-input-wrapper input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
}

.delimiter-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.no-header-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.file-name {
    font-style: italic;
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1; /* Allow the element to grow and take available space */
    min-width: 0; /* Allows the element to shrink below its content size, enabling ellipsis */
}

.previews-container {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicking through the canvas */
    z-index: 10;
}

.preview-wrapper {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents the wrapper from growing beyond its grid column width */
}

/* New styles for the preview loader */
.preview-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20; /* Above table, below header */
    border-radius: 8px;
}

.preview-loader p {
    margin-top: 10px;
}

/* Increase specificity to override the default .modal-content max-width */
.modal-content.modal-content-sm {
    max-width: 600px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.preview-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.filter-builder {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
    background-color: #fdfdfd;
}

.filter-rules-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-rule {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-rule select, .filter-rule input {
    padding: 6px;
    font-size: 0.9rem;
}

.filter-column { flex: 3; }
.filter-operator { flex: 2; }
.filter-value { 
    flex: 3;
    min-width: 0; /* Allows the input to shrink below its default minimum size */
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-container {
    overflow: auto; /* Adds scrollbars when content overflows */
    max-height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

thead th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
    z-index: 5;
}

.preview-wrapper thead th {
    cursor: grab;
    user-select: none;
}

.preview-wrapper thead th:active {
    cursor: grabbing;
}

.preview-wrapper thead th.selected {
    background-color: var(--selected-color);
    outline: 2px solid var(--primary-color);
}

.preview-wrapper thead th.paired {
    background-color: #e2e3e5;
    cursor: not-allowed;
}

.preview-wrapper thead th.unmatched {
    background-color: #f8f9fa;
    color: var(--secondary-color);
    cursor: not-allowed;
    font-style: italic;
}

.preview-wrapper thead th.unmatched[data-unmatched="true"] {
    background-color: #f8f9fa;
    color: var(--secondary-color);
    font-style: italic;
}

.lock-icon {
    margin-left: 8px;
    cursor: pointer;
    font-style: normal;
    opacity: 0.6;
    display: inline-block;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lock-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

.lock-icon.locked {
    font-style: normal; /* Ensure it's not italic like the header text */
}

.comparison-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.matching-actions, .run-actions {
    align-items: center;
    gap: 20px;
    padding-bottom: 0; /* Remove bottom padding if it's not the last element */
}

.matching-actions {
    display: flex;
    justify-content: space-between;
}

.matching-actions-left {
    display: flex;
    align-items: center; /* This ensures vertical alignment of buttons */
    gap: 20px;
}

.run-actions {
    display: flex;
}

.grouping-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0; /* Adjusted padding for a less button-like feel */
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}

/* === Modern Button Styles === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box; /* Ensures padding and border are included in the size */
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Primary Button (for main actions) */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.btn-primary:hover:not(:disabled) {
    background-color: #0069d9;
    border-color: #0062cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}
.btn.loading {
    cursor: wait;
}
.btn.loading .btn-text {
    display: none;
}
.btn.loading .btn-loader {
    display: inline-block;
}

/* Small spinner for buttons */
.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}


/* Secondary/Outline Button */
.btn-secondary {
    background-color: var(--surface-color);
    color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-secondary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

/* Icon-only button (for remove rule) */
.btn-icon {
    background-color: transparent;
    border: none;
    padding: 5px;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--secondary-color);
    line-height: 1;
    opacity: 0.7;
}
.btn-icon:hover {
    opacity: 1;
}

/* Smaller button variant */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Ensure buttons in the user profile section have a consistent width */
#user-profile-section .btn-sm {
    min-width: 90px;
    justify-content: center;
}

#results-section {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.hidden {
    display: none !important;
}

#results-section.hidden {
    display: none;
}

.results-header {
    display: flex;
    align-items: baseline; /* Aligns text nicely */
    gap: 20px;
    margin-bottom: 15px;
}

#results-section h2 {
    margin: 0;
    white-space: nowrap; /* Prevent wrapping */
}

#results-summary {
    margin: 0;
    margin-top: 15px;
    font-style: italic;
    color: var(--secondary-color);
}

.results-options {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.results-header .download-actions {
    margin-left: auto;
}

.dropdown-container {
    position: relative;
    display: inline-block;
}

#download-results-btn .dropdown-arrow {
    margin-left: 8px;
    font-size: 0.7em;
    display: inline-block;
    transition: transform 0.2s ease-in-out;
}

.dropdown-container.open #download-results-btn .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 100;
    min-width: 160px;
    padding: 5px 0;
    margin-top: 5px;
}

.dropdown-menu a {
    color: var(--text-color);
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.dropdown-menu a:hover {
    background-color: #f1f1f1;
}


#results-table-container .diff {
    background-color: var(--diff-color);
    font-weight: 500;
}

/* --- Modal Styles --- */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex; /* Default state is visible and flexed */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-container.hidden {
    /* This compound selector is specific enough to override the 'display: flex' above */
    display: none;
}

.modal-content {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* New class for modals that should auto-size with content */
.modal-content-auto {
    width: auto;
    max-width: 95%; /* Use percentage to be responsive */
    min-width: 500px; /* Set a reasonable minimum width */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 5px;
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    /* Let the content determine if scroll is needed. Flexbox will manage height. */
    overflow-y: hidden;
    flex: 1 1 auto; /* Allow body to grow and shrink */
    position: relative; /* Establishes a positioning context for the loader */
    display: flex; /* This is the key fix: allows the child container to use flex: 1 */
}

#fixed-width-modal .modal-body {
    flex-direction: column;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.excel-option-group select,
.excel-option-group input[type="text"] {
    width: 100%;
}

/* --- Loader / Spinner --- */
.modal-loader:not(.hidden) {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex; /* Apply flex only when not hidden */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1010; /* Above modal content */
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Fixed-width Editor Styles --- */
.fixed-width-editor {
    position: relative;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    padding: 10px;
    background: #fdfdfd;
}

#editor-content-wrapper {
    position: relative;
}

#fixed-width-preview {
    margin: 0;
    padding: 0;
    white-space: pre;
    line-height: 1.5;
    user-select: none;
}

#break-lines-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.break-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: rgba(255, 0, 0, 0.6);
    cursor: ew-resize;
    transform: translateX(-1.5px); /* Center the line on the cursor */
}

#header-options {
    margin-top: 15px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#custom-headers-container {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.custom-header-input-wrapper {
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent the wrapper from shrinking */
}
.custom-header-input-wrapper input {
    padding: 4px;
    font-size: 0.8rem;
    width: 120px; /* Set a fixed width for all inputs */
}

/* --- Value Mapping Modal Styles --- */
.value-mapping-container {
    display: flex;
    flex-direction: column;
    position: relative;
    gap: 10px;
    /* Let the container grow to fill the modal body */
    flex: 1; /* This allows the container to fill the flex parent (.modal-body) */
    visibility: hidden; /* Start hidden, JS will make it visible */
}

.value-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 10px 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}
.value-mapping-container > p {
    margin-top: 0;
    flex-shrink: 0;
}


.primary-key-selectors {
    display: flex;
    gap: 15px;
    margin-left: auto;
}

/* Prevent the main body of the value mapping modal from scrolling; scrolling is handled by the lists inside. */
#value-mapping-modal .modal-body {
    overflow-y: hidden;
    padding-bottom: 5px; /* Add a small buffer to prevent parent scrollbars */
}

.value-map-header h4, .value-list-wrapper h5, .mapped-values-wrapper h5 {
    margin: 0;
}

.value-list-wrapper h5, .mapped-values-wrapper h5 {
    margin-bottom: 8px;
}

.primary-key-selector-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
}

.value-search-container {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}

.mapped-values-wrapper {
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent this wrapper from shrinking */
}

.mapped-values-list {
    max-height: 30vh; /* Use 30% of the viewport height */
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    background-color: #fdfdfd;
}

.mapped-item-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
}

.mapped-item-pair .value-item {
    flex: 1;
}

.mapped-item-pair .arrow {
    font-size: 1.2rem;
    color: var(--secondary-color);
}

.unmapped-values-container {
    display: flex;
    gap: 20px;
    flex: 1; /* Allow this container to grow and fill remaining space */
    min-height: 0; /* Important for flexbox children with overflow */
}

.value-list-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex items from overflowing their container */
}

.value-list {
    flex: 1; /* Ensure the list grows to fill the wrapper */
    overflow-y: scroll; /* Use 'scroll' to always show scrollbar track, preventing layout shifts */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    background-color: #fdfdfd;
}

.value-item {
    padding: 6px 10px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.3s ease;
    /* Add relative positioning to allow z-index to work */
    position: relative; 
    z-index: 1;
}

/* Add margin between items, but not before the first one */
.value-item + .value-item, .mapped-item-pair + .mapped-item-pair {
    margin-top: 4px;
}

.value-item:active {
    cursor: grabbing;
}

.value-item.mapped {
    background-color: var(--selected-color);
    font-weight: 500;
    border-color: var(--primary-color);
    z-index: 2; /* Bring mapped items to the front */
}

.value-item.suggested {
    background-color: var(--suggested-color); /* A light yellow for suggestions */
    border-color: #ffeeba;
    z-index: 2;
}

.value-search-box {
    width: 100%;
    padding: 8px;    
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* --- Legend Styles --- */
.legend-container {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

.modal-footer-actions { display: flex; gap: 10px; }

/* --- Excel Options Modal --- */
#excel-options-form {
    flex: 1; /* Make the form fill the available space in the flex container */
    visibility: visible; /* Ensure it's visible when the loader is not */
}

.excel-option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.excel-option-group label {
    font-weight: 500;
}

.excel-option-group select,
.excel-option-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#cell-range-input {
    width: 50%;
}

#worksheet-select {
    width: 100%;
}

/* --- Auth Modal Styles --- */
#auth-modal .modal-body {
    flex-direction: column;
}

.auth-form-group {
    margin-bottom: 15px;
}

.checkbox-group {
    display: flex;
    display: grid;
    grid-template-columns: auto max-content; /* Label on left, checkbox on right */
    justify-content: start; /* Align grid to the left */
    align-items: center;
    gap: 8px 15px; /* 8px between rows, 15px between columns */
}
#save-template-modal .auth-form-group {
    width: 100%;
}

.auth-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.auth-form-group input[type="text"],
.auth-form-group input[type="email"],
.auth-form-group input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Make the template name input a bit wider */
#template-name-input {
    width: 100%;
}

.auth-btn {
    width: 100%;
    margin-top: 10px;
}

.configs-label {
    margin-top: 15px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
}

.auth-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}

/* Password Strength Meter */
#password-strength-meter {
    height: 5px;
    width: 0%;
    background-color: #ddd;
    border-radius: 5px;
    margin-top: 8px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

#password-strength-text {
    font-size: 0.8rem;
    height: 1.2em; /* Reserve space to prevent layout shift */
    margin-top: 4px;
    margin-bottom: 0;
}

.strength-weak {
    width: 33% !important;
    background-color: #dc3545 !important; /* Red */
}

.strength-medium {
    width: 66% !important;
    background-color: #ffc107 !important; /* Yellow */
}

.strength-strong {
    width: 100% !important;
    background-color: #28a745 !important; /* Green */
}

.logged-in-text {
    font-size: 0.8rem; /* Make font smaller */
    margin-top: 5px; /* Add some space above the text */
    text-align: right; /* Align text to the right */
    white-space: nowrap; /* Prevent the text from wrapping into two lines */
    text-decoration: none; /* Remove underline from auth-link class */
}

/* Template List in Profile Modal */
#profile-templates-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
}

/* --- Toast Notification Styles --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none; /* Allow clicks to pass through the container */
}

.toast {
    background-color: var(--surface-color);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    border-left: 5px solid var(--primary-color);
    opacity: 0;
    transform: translateX(110%);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto; /* Make the toasts themselves clickable */
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-success {
    border-left-color: #28a745;
}

.toast.toast-warning {
    border-left-color: #ffc107;
}

.toast.toast-error {
    border-left-color: #dc3545;
}

.toast-message {
    white-space: pre-wrap; /* To respect newlines in the message */
}

/* --- Tutorial/Onboarding Styles --- */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1999;
}

#tutorial-popover {
    position: absolute;
    background-color: var(--surface-color);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 2002; /* Increase z-index to be above the overlay */
    max-width: 350px;
    line-height: 1.5;
}

.tutorial-navigation {
    display: flex;
    justify-content: flex-end; /* Align items to the right */
    align-items: center;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    gap: 12px; /* Add space between the items */
}

#tutorial-step-indicator {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-right: auto; /* Push the step indicator to the far left */
}

.tutorial-highlight {
    position: relative;
    z-index: 2000;
    /* Use a prominent outline instead of changing the background color. */
    /* This preserves the original style of buttons and other elements. */
    outline: 3px solid var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.7);
    border-radius: 4px;
}

/* Disable pointer events for specific tutorial steps */
[data-tutorial-disabled] {
    pointer-events: none;
}

/* Make the terms modal body scrollable if content overflows */
#terms-modal-body {
    overflow-y: auto;
    flex-direction: column;
}

/* Make the privacy modal body scrollable if content overflows */
#privacy-modal-body {
    overflow-y: auto;
    flex-direction: column;
}

/* Make the contact modal body scrollable if content overflows */
#contact-modal-body {
    overflow-y: auto;
    flex-direction: column;
}

#contact-modal-body h3 {
    margin-top: 4px;
    margin-bottom: 1px;
}

#contact-modal-body p {
    margin-top: 1px;
    margin-bottom: 4px;
}

#about-modal-body h3 {
    margin-top: 4px;
    margin-bottom: 1px;
}


/* Make the about us modal body scrollable and stack content vertically */
#about-modal-body {
    overflow-y: auto;
    flex-direction: column;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--secondary-color);
}

footer a {
    color: var(--primary-color);
}

/* Increase width for specific informational modals */
#terms-modal .modal-content,
#privacy-modal .modal-content,
#contact-modal .modal-content,
#about-modal .modal-content {
    max-width: 900px; /* 600px * 1.5 */
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .file-selectors {
        flex-direction: column;
        gap: 30px; /* Increase gap for vertical layout */
    }

    .previews-container {
        grid-template-columns: 1fr; /* Stack previews vertically */
    }

    header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header-actions {
        margin-top: 15px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start; /* Align items to the left */
    }

    .results-header .download-actions {
        margin-left: 0; /* Reset margin for stacked layout */
        margin-top: 15px;
    }

    .matching-actions {
        flex-direction: column;
        align-items: stretch; /* Make child elements take full width */
        gap: 15px;
    }

    #template-management-container {
        justify-content: center; /* Center template buttons */
    }

    body {
        padding: 15px 10px; /* Reduce side padding on smaller screens */
    }
}

