body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}
/* --- DEFINITIVE FIX: Remove padding for full-width landing page sections. --- */
/* The .landing-container is used on the landing page, which has its own
   full-width sections with their own internal padding. This removes the
   extra padding from the base template's .container div. */
.container:has(.landing-container) {
    padding: 0;
}
.container {
    padding: 20px;
}
/* Styles for static content pages like Terms, Privacy, etc. inside the .container */
.container h2:first-child {
    margin-bottom: 20px;
}
.container h3:first-child {
    margin-top: 30px;
    margin-bottom: 15px;
}
.container p:first-child, .container ul:first-child {
    line-height: 1.6;
    margin-bottom: 15px;
}
.container ul:first-child {
    padding-left: 20px;
}
.container .last-updated:first-child {
    color: #6c757d;
    font-style: italic;
    margin-bottom: 25px;
}
.container a:first-child {
    color: #007bff;
    text-decoration: none;
}
.container a:hover {
    text-decoration: underline;
}
.profile-panel {
    position: fixed;
    top: 50px;
    right: -320px;
    width: 300px;
    height: calc(100% - 50px);
    background-color: #f9f9f9;
    box-shadow: -2px 0 5px rgba(0,0,0,0.2);
    padding: 20px;
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    box-sizing: border-box;
}
.profile-panel.show {
    right: 0;
}
.profile-panel p {
    margin: 10px 0;
}
.profile-panel img {
    max-width: 100px;
    border-radius: 50%;
    margin-bottom: 10px;
}
.profile-panel a {
    color: #333;
    text-decoration: none;
}
.profile-panel a:hover {
    text-decoration: underline;
}
.profile-panel .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 18px;
}
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1001;
}
.modal.show {
    display: block;
}
.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    position: relative;
}
.modal-content .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 18px;
}
.modal-content h5 {
    margin-top: 0;
}
.modal-content .form-group {
    margin-bottom: 15px;
}
.modal-content label {
    display: block;
    margin-bottom: 5px;
}
.modal-content input[type="text"],
.modal-content input[type="checkbox"] {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
}
.modal-content button {
    background-color: #333;
    color: white;
    padding: 10px 15px;
    border: none;
    cursor: pointer;
}
.modal-content button:hover {
    background-color: #ddd;
    color: black;
}
.modal-actions {
    text-align: right;
    margin-top: 20px;
}
.modal-actions button {
    margin-left: 10px;
    padding: 10px 15px;
}
#confirmOkBtn {
    background-color: #dc3545;
    color: white;
}
#confirmOkBtn:hover {
    background-color: #c82333;
}
.share-link-container {
    display: flex;
    margin-top: 10px;
}
.share-link-container input {
    flex-grow: 1;
    border-right: none;
    border-radius: 4px 0 0 4px;
}
.share-link-container button {
    border-radius: 0 4px 4px 0;
}
.social-share-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}
.social-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
}
.social-btn.email { background-color: #7f8c8d; }
.social-btn.email:hover { background-color: #6c7a7b; }
.social-btn.x { background-color: #14171A; }
.social-btn.x:hover { background-color: #272c30; }
.social-btn.facebook { background-color: #1877F2; }
.social-btn.facebook:hover { background-color: #166fe5; }
.instance-actions {
    display: flex; gap: 10px; justify-content: flex-end;
}
.native-share-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: center;
}
.native-share-section p { font-size: 14px; color: #555; }
.list-table {
    border-collapse: collapse;
    margin-bottom: 20px;
    max-width: 700px; /* But don't get wider than this */
}
.list-table th, .list-table td {
    border: none;
    border-bottom: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.list-table th {
    background-color: transparent;
    border-bottom-width: 2px;
}
.list-table tfoot tr td.list-actions {
    text-align: right;
    border: none !important;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.list-table tbody tr {
    cursor: pointer;
}
.list-table tbody tr.selected {
    background-color: #e2e2e2;
}
.instance {
    border: none;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
    padding-bottom: 20px;
    max-width: 700px;
}
.instance-summary-details {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}
.instance-summary-details p {
    margin: 0 0 5px 0;
}
.instance-summary-details p:last-child {
    margin-bottom: 0;
}
.instance-subtitle {
    color: #6c757d;
    margin-top: -15px;
    margin-bottom: 20px;
}
.shared-estimate-view fieldset {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}
.shared-estimate-view legend {
    font-weight: bold;
    padding: 0 10px;
}
.shared-estimate-view p {
    margin: 5px 0;
}
.shared-estimate-view h4 {
    margin-top: 20px;
    margin-bottom: 10px;
}
.shared-estimate-view ul {
    list-style-position: inside;
    padding-left: 0;
}
.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    text-align: center;
    color: white !important; /* Use !important to override the conflicting .container a style */
}
.btn-primary {
    background-color: #007bff;
}
.btn-primary:hover {
    background-color: #0056b3;
}
.btn-info {
    background-color: #17a2b8;
}
.btn-info:hover { background-color: #138496; }
.btn-danger {
    background-color: #dc3545;
}
.btn-danger:hover { background-color: #c82333; }
.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #5a6268;
}
.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}
.view-switcher {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.view-switcher span {
    font-size: 14px;
}
.btn-success {
    background-color: #28a745;
}
.btn-success:hover {
    background-color: #218838;
}
.list-actions .add-item {
    margin-left: 0;
}
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 15px 20px;
    border-radius: 5px;
    color: white;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.5s forwards, fadeOut 0.5s 4.5s forwards;
}
.toast.success { background-color: #28a745; }
.toast.error { background-color: #dc3545; }
.toast.info { background-color: #17a2b8; }

@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; } }

.alert {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
}
.alert.error {
    background-color: #f8d7da;
    color: #721c24;
}
.alert.success {
    background-color: #d4edda;
    color: #155724;
}
.pagination {
    margin: 20px 0;
}
.pagination a, .pagination span {
    margin: 0 5px;
    text-decoration: none;
    color: #333;
}
.pagination a:hover {
    text-decoration: underline;
}
.cta-button {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 10px;
}
.cta-button:hover {
    background-color: #0056b3;
}
.site-footer {
    background-color: #f8f9fa;
    color: #6c757d;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid #e7e7e7;
    margin-top: 40px;
}
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
.footer-nav a {
    color: #007bff;
    text-decoration: none;
    margin: 0 10px;
    font-size: 14px;
}
.footer-nav a:hover {
    text-decoration: underline;
}
.footer-nav a + a::before {
    content: "|";
    margin: 0 10px;
    color: #6c757d;
}

/* --- NEW: Styles for the template selector buttons on the home page --- */
.template-selector-grid {
    display: grid;
    /* --- DEFINITIVE FIX: Revert to a simple and explicit two-column grid. --- */
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 10px;
}

.template-selector-column {
    display: flex;
    flex-direction: column;
    gap: 0px; /* --- DEFINITIVE FIX: Reduce the gap between rows for a more compact look. --- */
}

.template-option input[type="radio"] {
    display: none; /* Hide the actual radio button */
}

.template-option label {
    display: block;
    /* --- DEFINITIVE FIX: Change style from a button to a checkbox-like element. --- */
    display: flex;
    align-items: center;
    padding: 12px;
    /* --- DEFINITIVE FIX: Remove the border for a cleaner look. --- */
    border-radius: 5px;
    cursor: pointer;
    background-color: #fff;
    text-align: center;
    text-align: left;
    transition: all 0.2s ease-in-out;
    position: relative;
}

/* Create the custom checkbox box */
.template-option label::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    margin-right: 10px;
    background-color: white;
    transition: all 0.2s ease-in-out;
}

.template-option input[type="radio"]:checked + label {
    background-color: #e7f1ff; /* A light blue highlight for the whole row */
}

/* Style the custom checkbox when it's checked */
.template-option input[type="radio"]:checked + label::before {
    background-color: #007bff;
    border-color: #0056b3;
    content: '✓'; /* Add a checkmark */
    color: white;
    border-color: #0056b3;
    text-align: center;
    line-height: 18px;
    font-weight: bold;
}

/* --- DEFINITIVE FIX: Add spacing between form groups for better layout. --- */
.form-group {
    margin-bottom: 15px;
}

/* Template Form Styles */
.template-form {
    max-width: none;
    margin: 20px 0;
    padding: 0;
    background-color: transparent;
    border: none;
}
.form-grid {
    display: grid;
    /* Create responsive columns: 2 on medium screens, 1 on small */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.form-row-full-width {
    /* Make an element span all columns in the grid */
    grid-column: 1 / -1;
}
.template-form fieldset {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
}
.template-form legend {
    font-weight: bold;
    padding: 0 10px;
}
.form-row {
    margin-bottom: 15px;
}
.form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
.repeatable-item {
    position: relative;
    border: 1px dashed #ccc;
    padding: 20px;
    padding-top: 30px;
    margin-bottom: 15px;
    border-radius: 4px;
}
.full-width-textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.remove-repeatable-item {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
}
.list-type-badge {
    font-size: 0.6em;
    font-weight: normal;
    color: #6c757d;
    vertical-align: middle;
    margin-left: 5px;
}
.calculated-field {
    background-color: #e9ecef;
    color: #495057;
    cursor: not-allowed;
}
.list-summary-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}
.list-summary-actions .btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 12px;
    color: white;
    text-align: center;
}
.list-summary-actions .btn-edit {
    background-color: #007bff; /* primary */
}
.list-summary-actions .btn-edit:hover { background-color: #0056b3; }

.list-summary-actions .btn-duplicate {
    background-color: #17a2b8; /* info */
}
.list-summary-actions .btn-duplicate:hover { background-color: #138496; }

.list-summary-actions .btn-save-instance {
    background-color: #28a745; /* success */
}
.list-summary-actions .btn-save-instance:hover { background-color: #218838; }

.list-summary-actions .btn-delete-list {
    background-color: #dc3545; /* danger */
}
.list-summary-actions .btn-delete-list:hover { background-color: #c82333;
}
.page-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.tree-controls {
    margin-bottom: 15px;
}

.search-form {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    max-width: 500px;
}
.search-form button {
    background-color: #333;
    padding: 6px 12px;
}
.search-form a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #555;
}
.search-form a:hover { text-decoration: underline; }
.snaps-grid {
    /* Change from a grid to a single-column flex layout */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align items to the start, so they don't stretch */
    gap: 20px;
    margin-top: 20px;
}

.snap-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    max-width: 100%; /* Ensure cards don't overflow on small screens */
    flex-direction: column;
    /* --- DEFINITIVE FIX: Make the card only as wide as its content. --- */
    /* This prevents the long warning text from stretching the card wider than the image.
       The previous `width: fit-content` was not sufficient to override the text's intrinsic size. */
    max-width: 400px;
}

.snap-image-container {
    /* --- DEFINITIVE FIX: Remove the grey background from the snap container. --- */
    /* This allows the snapshot's own background (or transparency) to show through correctly. */
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.snap-image {
    /* Let the image have its natural width, but don't let it exceed the container */
    max-width: 100%;
    height: auto;
    display: block;
}

.snap-placeholder {
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    padding: 20px;
    min-height: 150px; /* Give it some body */
    border-bottom: 1px solid #ddd;
}

.snap-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    /* This prevents the text content from stretching the container wider than the image,
       which was causing the extra side margins. */
    overflow-wrap: break-word;
}

.snap-title {
    margin: 0 0 5px 0;
    font-size: 1.1em;
}

.snap-timestamp {
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.snap-card-warning {
    background-color: #fffbe6; /* Light yellow */
    border: 1px solid #ffe58f; /* Gold border */
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px; /* Space before the action buttons */
}

.snap-card-warning p {
    margin: 0;
    font-size: 0.85em;
    color: #5c3c00; /* Dark brown for readability */
    line-height: 1.4;
}

.snap-actions {
    margin-top: auto; /* Pushes actions to the bottom */
    display: flex;
    gap: 8px;
}

/* --- DEFINITIVE FIX: Add a container to constrain the template selector's width. --- */
.template-selector-container {
    max-width: 700px; /* Set a max width to prevent the columns from spreading apart. */
    /* --- DEFINITIVE FIX: Remove auto margin to align the block to the left. --- */
    margin: 0;
}

/* --- NEW: Styles for the template preview feature. --- */
.template-selection-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.template-preview-pane {
    flex-shrink: 0;
    /* --- DEFINITIVE FIX: Remove the background color to prevent a square behind the image. --- */
    /* --- DEFINITIVE FIX: The pane no longer has a fixed size; it will wrap the image. --- */
    background-color: transparent;
    /* --- DEFINITIVE FIX: Remove the border to eliminate the enclosing square. --- */
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* --- FIX: Hide the preview pane by default. --- */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.template-preview-pane img {
    /* --- DEFINITIVE FIX: Reduce the preview image size by ~30% and let the pane wrap it. --- */
    max-width: 210px; /* Approx 70% of the original 300px width */
    max-height: 210px;
    object-fit: contain;
    transition: opacity 0.2s ease-in-out;
}

/* --- FIX: Show the preview pane when hovering over the selection area. --- */
.template-selection-wrapper:hover .template-preview-pane {
    opacity: 1;
    visibility: visible;
}

/* --- DEFINITIVE FIX: Revert to a simple two-column grid. --- */
/* The responsive behavior is now handled by the container's max-width. */

/* --- NEW: Responsive styles for the template preview on mobile. --- */

/* --- DEFINITIVE FIX: Improve mobile form usability --- */
/* Set a minimum font size for inputs to prevent iOS from auto-zooming, which can cause a blurry effect. */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea {
    font-size: 16px;
}

/* --- NEW: Styles for the AI creation section on the home page. --- */
.ai-create-section {
    /* --- DEFINITIVE FIX: Constrain the width to make the input field wider. --- */
    max-width: 700px;
    margin-bottom: 20px;
    margin-left: auto;
    margin-right: auto;
}

.or-divider {
    text-align: center;
    margin: 20px 0;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 15px;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex-grow: 1;
    height: 1px;
    background-color: #dee2e6;
}

.or-divider span {
    font-size: 0.9em;
    font-weight: bold;
}
/* --- NEW: Styles for the AI creation section on the home page. --- */
.ai-prompt-input-group {
    display: flex;
    gap: 8px;
}

.ai-prompt-input-group input {
    flex-grow: 1; /* Allow the input to take up the available space */
}

/* --- NEW: Styles for the global AI Assistant --- */
.ai-assistant-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #6a0dad; /* A distinct purple color */
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s ease;
}
.ai-assistant-toggle-btn:hover {
    transform: scale(1.1);
}

.ai-assistant-window {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 350px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 1001;
    display: none; /* Hidden by default */
}
.ai-assistant-window.show {
    display: block;
}

.ai-assistant-header {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}
.ai-assistant-close {
    cursor: pointer;
    font-size: 20px;
}
.ai-assistant-body {
    padding: 15px;
}

/* --- NEW: Style the textarea inside the AI assistant. --- */
.ai-assistant-body textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    resize: vertical; /* Allow the user to resize it vertically */
}
