

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f0f2f5; /* Light grayish blue */
    color: #333;
    line-height: 1.6;
    font-size: 16px;
}

#root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 25px; /* Increased padding */
    width: 100%;
    box-sizing: border-box;
    flex-grow: 1;
}

header {
    text-align: center;
    margin-bottom: 25px; /* Reduced margin to accommodate tabs */
    padding-bottom: 25px;
    border-bottom: 1px solid #dee2e6; /* Lighter border */
}

header h1 {
    color: #1a253c; /* Darker blue */
    margin-bottom: 0.5em;
    font-size: 2.4em; /* Slightly larger */
    font-weight: 600;
}

header p {
    font-size: 1.15em; /* Slightly larger */
    color: #5a677d; /* Softer color */
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.tabs-container {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 35px; /* Match main gap */
}

.tab-button {
    padding: 15px 25px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent; /* Placeholder for active state */
    font-size: 1.1em;
    font-weight: 500;
    color: #5a677d; /* Softer color */
    margin-bottom: -2px; /* Align with container's border */
    transition: all 0.2s ease-in-out;
}

.tab-button:hover:not(.active) {
    background-color: #f8f9fa; /* Light hover background */
    color: #343a40;
}

.tab-button.active {
    color: #007bff; /* Primary blue */
    border-bottom-color: #007bff;
    font-weight: 600;
}


main {
    display: flex;
    flex-direction: column;
    gap: 35px; /* Increased gap */
}

/* Make tab panels focusable for accessibility */
[role="tabpanel"] {
    outline: none;
}
[role="tabpanel"] > div,
[role="tabpanel"] > section {
    display: flex;
    flex-direction: column;
    gap: 35px;
}

.input-section, .output-section, .preview-section, .url-analysis-section {
    background-color: #ffffff;
    padding: 30px; /* Increased padding */
    border-radius: 12px; /* More rounded corners */
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07); /* Softer, more diffuse shadow */
    border: 1px solid #e9ecef; /* Subtle border */
    display: block; /* Override flex settings from parent */
}

.section-title { /* Common class for h2 and labels acting as titles */
    margin-top: 0;
    color: #343a40; /* Darker gray */
    font-size: 1.7em; /* Slightly larger */
    font-weight: 500;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 15px;
    margin-bottom: 25px;
    display: block; /* Ensures label takes full width if used as title */
}

.section-toggle-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.section-toggle-button:hover,
.section-toggle-button:focus {
    color: #0056b3; /* Darker blue on hover/focus for toggle */
}

.toggle-icon {
    font-size: 0.9em; /* Slightly smaller than title text */
    margin-left: 10px;
    font-weight: bold; /* Make icon more prominent */
}

/* For h2 elements that are visually hidden but available to SRs */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

textarea {
    width: 100%;
    padding: 15px; /* Increased padding */
    border: 1px solid #ced4da;
    border-radius: 8px; /* More rounded */
    font-size: 1em;
    box-sizing: border-box;
    margin-bottom: 20px; /* Space after textarea before image URL input */
    resize: vertical;
    min-height: 100px; /* Adjusted height for product description textarea */
    line-height: 1.5;
}

textarea:focus {
    outline: none;
    border-color: #007bff; /* Bootstrap blue for focus */
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.image-url-label {
    display: block;
    font-weight: 500;
    color: #495057;
    margin-bottom: 8px; /* Space between label and input group */
    font-size: 1.0em; 
}

.add-image-url-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px; /* Space below the input group */
    align-items: center; /* Align input and button vertically */
}

input[type="url"].image-url-input { /* Specifically for the input field within the group */
    flex-grow: 1; /* Input takes available space */
    padding: 12px 15px; /* Adjusted padding */
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    line-height: 1.5;
    margin-bottom: 0; /* Remove bottom margin as group handles it */
}

input[type="url"].image-url-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.add-image-button {
    padding: 12px 18px; /* Match input padding for height */
    white-space: nowrap; /* Prevent text wrapping */
    font-size: 0.95em;
}


.image-thumbnail-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* Increased gap */
    margin-top: 10px; /* Space above if there are URLs */
    margin-bottom: 20px; /* Space below before checkbox */
    padding: 10px;
    background-color: #f8f9fa; /* Light background for the container */
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.image-url-item {
    position: relative;
    border: 1px solid #dee2e6; /* Slightly darker border for item */
    border-radius: 6px; /* Consistent rounding */
    padding: 6px; /* Padding around thumbnail */
    background-color: #ffffff; /* White background for each item */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle shadow for item */
    display: flex; /* For placeholder alignment */
    flex-direction: column; /* For placeholder alignment */
    align-items: center; /* For placeholder alignment */
    justify-content: center; /* For placeholder alignment */
    width: 92px; /* Fixed width including padding */
    height: 92px; /* Fixed height including padding */
    box-sizing: border-box;
}

.image-thumbnail {
    width: 78px; /* Inner image size */
    height: 78px;
    object-fit: cover;
    border-radius: 4px; /* Slightly rounded corners for image */
    display: block;
    background-color: #e9ecef; /* Placeholder color if image is loading */
}

.image-error-placeholder {
    font-size: 0.75em;
    color: #dc3545;
    text-align: center;
    padding: 5px;
}
.hidden {
    display: none;
}


.remove-image-button {
    position: absolute;
    top: -8px; /* Adjust for better positioning */
    right: -8px;
    background-color: #dc3545; /* Bootstrap danger red */
    color: white;
    border: 1px solid #dc3545; /* Ensure border matches */
    border-radius: 50%;
    width: 24px; /* Slightly larger */
    height: 24px;
    font-size: 14px; /* Larger 'x' */
    line-height: 22px; /* Adjust line height for vertical centering */
    text-align: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    font-weight: bold;
}
.remove-image-button:hover {
    background-color: #c82333; /* Darker red on hover */
    border-color: #bd2130;
}


.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* Space below checkbox, before the button */
}

.checkbox-container input[type="checkbox"] {
    margin-right: 8px;
    width: 18px; /* Slightly larger checkbox */
    height: 18px;
    cursor: pointer;
    accent-color: #007bff; /* Match button color */
}

.checkbox-container label {
    font-size: 0.95em;
    color: #495057; /* Slightly darker than default text for emphasis */
    cursor: pointer;
    user-select: none; /* Prevent text selection on label click */
}


button {
    background-color: #007bff; /* Primary blue */
    color: white;
    border: none;
    padding: 14px 24px; /* Larger padding */
    border-radius: 8px; /* More rounded */
    font-size: 1.05em; /* Slightly larger font */
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover {
    background-color: #0056b3; /* Darker blue */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(1px);
    background-color: #004085; /* Even darker blue */
}

button:disabled {
    background-color: #adb5bd; /* Gray for disabled */
    cursor: not-allowed;
    box-shadow: none;
}

.generation-buttons-container {
    display: flex;
    gap: 15px; /* Space between the two generation buttons */
}

.generation-buttons-container button {
    flex-grow: 1; /* Make buttons share space equally */
}


.error-message {
    color: #721c24; /* Darker red */
    background-color: #f8d7da; /* Lighter red background */
    border: 1px solid #f5c6cb; /* Reddish border */
    padding: 12px 15px;
    border-radius: 6px;
    margin-top: 20px;
    font-size: 0.95em;
    word-break: break-word; /* Ensure long error messages wrap */
}

#code-content-wrapper, #preview-content-wrapper {
    margin-top: 20px; /* Add some space below the toggle button */
}


.code-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center; /* Align items vertically */
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    gap: 10px; /* Add gap between buttons */
    margin-bottom: 12px;
}

.code-toolbar button {
    background-color: #6c757d; /* Secondary/gray color for toolbar buttons */
    font-size: 0.9em;
    padding: 8px 16px;
}
.code-toolbar button:hover {
    background-color: #5a6268;
}
.code-toolbar button.translate-button {
   background-color: #17a2b8; /* Info blue for translate */
}
.code-toolbar button.translate-button:hover {
   background-color: #138496; /* Darker info blue */
}

.code-editor-textarea {
    width: 100%;
    min-height: 200px; /* Adjust as needed */
    padding: 20px;
    border: 1px solid #343a40;
    border-radius: 8px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
    line-height: 1.6;
    background-color: #212529;
    color: #f8f9fa;
    box-sizing: border-box;
    resize: vertical;
    margin-bottom: 0; /* Remove default textarea margin if not needed here */
    white-space: pre; /* Preserve whitespace like <pre> */
    overflow-wrap: normal; /* Allow horizontal scrolling with pre */
    overflow-x: auto; /* Enable horizontal scrollbar */
}

.code-editor-textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}


.html-preview-content {
    border: 1px solid #dee2e6;
    padding: 20px;
    border-radius: 8px;
    min-height: 150px; /* Adjusted min-height */
    background-color: #fff; /* Clean white background */
    line-height: 1.7; /* Slightly more spacious line height for preview */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.preview-placeholder {
    color: #6c757d; /* Softer gray for placeholder text */
    font-style: italic;
    text-align: center;
    padding: 20px;
}


/* Basic styling for elements inside preview as a fallback */
.html-preview-content h1,
.html-preview-content h2,
.html-preview-content h3,
.html-preview-content h4,
.html-preview-content h5,
.html-preview-content h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}
.html-preview-content p {
    margin-bottom: 1em;
}
.html-preview-content ul,
.html-preview-content ol {
    padding-left: 25px; /* More indentation */
    margin-bottom: 1em;
}
.html-preview-content li {
    margin-bottom: 0.5em;
}
.html-preview-content a {
    color: #007bff;
    text-decoration: none;
}
.html-preview-content a:hover {
    text-decoration: underline;
}
.html-preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* New section for URL Analysis */
.url-analysis-section p {
    color: #5a677d;
    margin-bottom: 25px;
}
.url-analysis-section label {
    display: block;
    font-weight: 500;
    color: #495057;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.meta-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 25px;
    border-top: 1px solid #e9ecef;
    padding-top: 25px;
}

.url-analysis-section .result-container {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
    display: flex;
    flex-direction: column;
}

.url-analysis-section .result-container h3 {
    margin-top: 0;
    color: #343a40;
}

.url-analysis-section .result-container textarea {
    width: 100%;
    min-height: 100px;
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #333;
    white-space: normal;
    overflow-x: hidden;
    margin-bottom: 10px;
    flex-grow: 1;
}

.url-analysis-section .result-container .copy-button {
    background-color: #6c757d; /* Secondary color */
    font-size: 0.9em;
    padding: 8px 16px;
    align-self: flex-end;
}
.url-analysis-section .result-container .copy-button:hover {
    background-color: #5a6268;
}

.url-analysis-section .loading-message {
    margin-top: 20px;
    color: #5a677d;
}

footer {
    text-align: center;
    padding: 30px 0;
    margin-top: 40px;
    font-size: 0.9em;
    color: #6c757d; /* Softer gray */
    border-top: 1px solid #dee2e6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    header h1 {
        font-size: 2em;
    }
    header p {
        font-size: 1.05em;
    }
    .tabs-container {
        margin-bottom: 25px;
    }
    .tab-button {
        padding: 12px 15px;
        font-size: 1em;
    }
    .section-title {
        font-size: 1.5em;
    }
    button {
        padding: 12px 18px;
        font-size: 1em;
    }
    textarea {
        font-size: 0.95em;
        min-height: 80px; /* Adjusted for smaller screens */
    }
    input[type="url"].image-url-input { /* Styles for the input field itself */
        font-size: 0.95em;
        padding: 10px 12px; /* Adjusted padding for smaller screens */
    }
    .add-image-button {
        padding: 10px 15px; /* Adjusted padding */
        font-size: 0.9em;
    }
    .image-thumbnail-container {
        gap: 8px;
    }
    .image-url-item {
        width: 72px;
        height: 72px;
        padding: 4px;
    }
    .image-thumbnail {
        width: 62px;
        height: 62px;
    }
    .remove-image-button {
        width: 20px;
        height: 20px;
        font-size: 12px;
        line-height: 18px; /* Adjusted line height */
        top: -6px;
        right: -6px;
    }

    .code-editor-textarea {
        font-size: 0.85em;
        padding: 15px;
        min-height: 150px;
    }
    .html-preview-content {
        padding: 15px;
    }
    .checkbox-container {
        margin-top: 8px;
        margin-bottom: 15px;
    }
    .checkbox-container label {
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8em;
    }
    header p {
        font-size: 1em;
    }
    .tabs-container {
        /* Allow tabs to wrap if needed, though they should fit on most phones */
        flex-wrap: wrap;
    }
    .tab-button {
        flex-grow: 1; /* Each tab takes up 50% width */
        text-align: center;
    }
    .section-title {
        font-size: 1.3em;
    }
    .add-image-url-group {
        flex-direction: column; /* Stack input and button */
        align-items: stretch; /* Make input and button full width */
    }
    .add-image-url-group .image-url-input {
        margin-bottom: 8px; /* Add space when stacked */
    }
    .add-image-url-group .add-image-button {
        width: 100%; /* Full width button */
    }

    .generation-buttons-container {
        flex-direction: column; /* Stack generation buttons vertically */
        gap: 10px; /* Space between stacked buttons */
    }
    .generation-buttons-container button {
        width: 100%; /* Make stacked buttons full width */
    }

    .code-toolbar {
        justify-content: center; /* Center toolbar buttons on small screens */
    }
    .code-toolbar button {
        flex-grow: 1; /* Allow toolbar buttons to grow */
        min-width: 120px; /* Minimum width for toolbar buttons */
    }
     .checkbox-container {
        margin-top: 10px;
        margin-bottom: 18px; /* Slightly more space on very small screens */
    }
}
