/* General Body & Container */
:root {
    --bg-color: #f0f2f5;
    --container-bg-color: #ffffff;
    --text-color: #333;
    --heading-color: #2c3e50;
    --subtitle-color: #666;
    --border-color: #e0e0e0;
    --input-section-bg: #f8fcff;
    --input-section-border: #a0c4ff;
    --input-bg: #fff;
    --button-bg: #007bff;
    --button-hover-bg: #0056b3;
    --button-disabled-bg: #cccccc;
    --loading-bg: #fdfdff;
    --output-section-bg: #fdfdfd;
    --asset-item-bg: #ffffff;
    --asset-item-border: #e0e0e0;
    --asset-item-canvas-border: #d0d0d0;
}

body.dark-mode {
    --bg-color: #2c2c2c;
    --container-bg-color: #3a3a3a;
    --text-color: #e0e0e0;
    --heading-color: #f0f0f0;
    --subtitle-color: #b0b0b0;
    --border-color: #555;
    --input-section-bg: #4a4a4a;
    --input-section-border: #6a6a6a;
    --input-bg: #555;
    --button-bg: #6200ee;
    --button-hover-bg: #3700b3;
    --button-disabled-bg: #777;
    --loading-bg: #4a4a4a;
    --output-section-bg: #3a3a3a;
    --asset-item-bg: #4a4a4a;
    --asset-item-border: #6a6a6a;
    --asset-item-canvas-border: #888;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Modern, clean font */
    margin: 0;
    padding: 30px;
    background-color: var(--bg-color); /* Very light grey background */
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top */
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1000px;
    width: 100%;
    margin: 20px auto; /* Add some top margin */
    background-color: var(--container-bg-color);
    padding: 35px 45px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); /* Softer, more pronounced shadow */
    border: 1px solid var(--border-color); /* Subtle border */
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Headings */
h1 {
    text-align: center;
    color: var(--heading-color); /* Darker, more professional blue-grey */
    margin-bottom: 10px; /* Reduce margin to bring subtitle closer */
    font-size: 2.8em;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    text-align: center;
    color: var(--subtitle-color); /* Slightly lighter color for subtitle */
    font-size: 1.1em;
    margin-top: 0; /* Remove default top margin */
    margin-bottom: 35px; /* Add space below subtitle */
}

h2 {
    text-align: center;
    color: var(--heading-color);
    margin-top: 45px;
    margin-bottom: 25px;
    font-size: 2em;
    font-weight: 600;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    background-color: var(--input-section-bg);
    color: var(--text-color);
    padding: 12px 25px;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin: 0 2px;
}

.tab-button:hover {
    background-color: var(--border-color);
}

.tab-button.active {
    background-color: var(--button-bg);
    color: white;
    box-shadow: 0 -3px 10px rgba(0, 123, 255, 0.2);
    border-bottom: 2px solid var(--button-bg);
}

/* Tab Content */
.tab-content {
    display: none;
    padding-top: 20px;
}

.tab-content.active {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Input Section (Drag & Drop Area) */
.input-section {
    margin-bottom: 35px;
    padding: 35px;
    border: 3px dashed var(--input-section-border); /* More prominent, friendly blue dashed border */
    border-radius: 12px;
    background-color: var(--input-section-bg); /* Very light blue background */
    text-align: center;
    transition: all 0.3s ease; /* Smooth transitions for hover/drag */
}

.input-section.drag-over {
    border-color: var(--button-bg); /* Highlight on drag-over */
    background-color: var(--button-hover-bg);
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.25); /* Glow effect */
}

.input-section p {
    margin-bottom: 25px;
    font-size: 1.3em;
    color: var(--heading-color);
    font-weight: 500;
}

input[type="file"] {
    display: block;
    margin: 0 auto 25px auto; /* Center and add more space */
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    cursor: pointer;
    width: fit-content; /* Adjust width to content */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    color: var(--text-color);
}

/* Buttons */
button {
    background-color: var(--button-bg); /* Standard blue */
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.15em;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.25);
    margin-top: 20px; /* Space above buttons */
}

button:hover:not(:disabled) {
    background-color: var(--button-hover-bg);
    transform: translateY(-3px); /* Slight lift effect */
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.35);
}

button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.2);
}

button:disabled {
    background-color: var(--button-disabled-bg);
    cursor: not-allowed;
    box-shadow: none;
}

/* Options (OCR, Categorization, Detection) */
.ocr-option,
.assertion-option,
.categorization-options,
.detection-options,
.output-options,
.grid-options {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.05em;
    color: var(--text-color);
}

.ocr-option input[type="checkbox"],
.assertion-option input[type="checkbox"],
.categorization-options input[type="checkbox"] {
    transform: scale(1.2); /* Slightly larger checkboxes */
    margin-right: 5px;
}

.categorization-options input[type="number"],
.detection-options input[type="number"],
.output-options input[type="text"],
.output-options select,
.grid-options input[type="number"] {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 70px; /* Slightly wider */
    text-align: center;
    font-size: 1em;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    background-color: var(--input-bg);
    color: var(--text-color);
}

.output-options input[type="text"] {
    width: 200px; /* Wider for naming convention */
}

.output-options select {
    width: 100px; /* Adjust width for select dropdown */
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    font-style: italic;
    color: var(--text-color);
    margin-top: 25px;
    padding: 25px;
    border-radius: 10px;
    background-color: var(--loading-bg);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

#loadingMessage {
    font-size: 1.2em;
    font-weight: 500;
    color: var(--heading-color);
    margin-bottom: 18px;
}

#progressBarImage {
    width: 600px; /* Wider for test */
    height: auto;
    margin-top: 12px;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

/* Output Section */
.output-section {
    margin-top: 45px;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--output-section-bg);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.06);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.output-section button {
    display: block;
    margin: 25px auto 0 auto; /* Center the download button */
}

/* Asset Display Grid */
.asset-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Larger min-width */
    gap: 25px; /* More space between items */
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
    justify-content: center; /* Center grid items */
}

.asset-item {
    border: 1px solid var(--asset-item-border);
    padding: 18px;
    border-radius: 10px;
    text-align: center;
    background-color: var(--asset-item-bg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
    min-height: 200px; /* Set a minimum height for the card */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute space */
}

.asset-item:hover {
    transform: translateY(-5px); /* More pronounced lift effect */
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.asset-item canvas {
    max-width: 100%; /* Ensure image scales down to fit card */
    height: auto; /* Maintain aspect ratio */
    border: 1px solid var(--asset-item-canvas-border);
    border-radius: 6px;
    margin-bottom: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.asset-item p {
    font-size: 0.9em;
    color: var(--text-color);
    word-break: break-word;
    margin-bottom: 6px;
}

.asset-item a {
    display: inline-block;
    margin-top: 10px;
    color: var(--button-bg);
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    transition: color 0.2s ease;
}

.asset-item a:hover {
    text-decoration: underline;
    color: var(--button-hover-bg);
}

/* Grid Cropper Canvas Preview */
.preview-section {
    margin-top: 30px;
    text-align: center;
}

#gridCropperCanvas {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 800px; /* Set a maximum width */
    max-height: 800px; /* Set a maximum height */
    width: 100%; /* Ensure it scales down if needed */
    height: auto; /* Maintain aspect ratio */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Toggle Button */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #6200ee;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.theme-switch-wrapper span {
    margin-right: 10px;
    font-size: 1em;
    color: var(--text-color);
}