/* Base layout */
body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 2rem;
    background: #f9f9f9;
    color: #333;
    transition: background 0.3s ease, color 0.3s ease;
}

html.dark body {
    background: #121212;
    color: #e0e0e0;
}

/* Container */
.container {
    width: 100%;
    max-width: 640px;
    margin: 60px auto 40px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transition: background 0.3s ease;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

html.dark .container {
    background: #1e1e1e;
}

@media screen and (max-height: 700px), screen and (max-width: 800px) {
    .container {
        padding-bottom: 60px; /* Ensure room for buttons and inputs */
    }
}

/* Logo */
.logo {
    display: block;
    max-width: 180px;
    margin: 0 auto 1rem auto;
}

/* Header */
h1 {
    margin-top: 0;
    font-size: 1.8rem;
}

/* Labels and Inputs */
label {
    display: block;
    margin: 0.8rem 0 0.2rem;
    font-weight: 600;
}

input[type='text'],
input[type='number'],
input[type='file'] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    color: #000;
    transition: background 0.3s ease;
}

html.dark input[type='text'],
html.dark input[type='number'],
html.dark input[type='file'] {
    background: #2c2c2c;
    color: #e0e0e0;
    border: 1px solid #444;
}

/* Fieldset */
fieldset {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

legend {
    font-weight: bold;
}

/* Submit Button */
button {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin: 2rem auto 1rem;
    display: block;
}

button:hover {
    background: #0056b3;
}

html.dark button {
    background: #2196f3;
}

html.dark button:hover {
    background: #42a5f5;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    background-color: #eee;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 1rem;
    height: 20px;
    display: none;
}

html.dark .progress-container {
    background-color: #444;
}

.progress-fill {
    height: 100%;
    background-color: #4caf50;
    width: 0%;
    transition: width 0.4s ease-in-out;
}

/* Drag and Drop Inputs */
.drop-zone {
    margin-top: 1rem;
}

.drop-box {
    border: 2px dashed #aaa;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    color: #666;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.drop-box.dragover {
    background: #e0f7fa;
    border-color: #007bff;
    color: #007bff;
}

.drop-box.dragover-invalid {
    background: #ffe6e6;
    border-color: #e53935;
    color: #e53935;
}

html.dark .drop-box {
    border-color: #666;
    background: #2c2c2c;
    color: #ccc;
}

html.dark .drop-box.dragover {
    background: #333;
    border-color: #2196f3;
    color: #2196f3;
}

html.dark .drop-box.dragover-invalid {
    background: #4a1f1f;
    border-color: #ff5252;
    color: #ffaaaa;
}

/* Help Tooltips */
.help-icon {
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 0.4rem;
    color: #888;
    position: relative;
}

.help-icon:hover,
.help-icon:focus {
    color: #007bff;
}

.help-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 10;
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(5px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    visibility: hidden;
}

.help-icon:hover::after,
.help-icon:focus::after {
    opacity: 1;
    transform: translateY(0px);
    pointer-events: auto;
    visibility: visible;
}

/* Results Page Grid */
.results-grid {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px; /* prevent scrollbar from overlapping */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.2rem;
    margin-top: 1rem;
    max-height: 40vh; /* You can adjust this height */
}

.result-card {
    text-align: center;
    background: #f0f0f0;
    border-radius: 10px;
    padding: 1rem;
    text-decoration: none;
    color: #007bff;
    transition: background 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-card:hover {
    background: #e0e0e0;
}

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.96);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.result-card.just-completed {
    border: 2px solid #00ff88;
    background-color: rgba(0, 255, 136, 0.08);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    animation: pop-in 0.35s ease-out;
}

.file-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.file-name {
    font-size: 0.9rem;
    word-break: break-word;
}

html.dark .result-card {
    background: #2c2c2c;
    color: #90caf9;
}

html.dark .result-card:hover {
    background: #3a3a3a;
}

/* Footer: Link + Theme Toggle */
.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    font-size: 0.85rem;
}

/* Footer Link */
.footer-link {
    background: #f0f0f0;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    color: #007bff;
    transition: background 0.3s ease;
}

.footer-link:hover {
    background: #e0e0e0;
}

html.dark .footer-link {
    background: #2c2c2c;
    color: #90caf9;
}

html.dark .footer-link:hover {
    background: #3a3a3a;
}

/* Theme Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.switch.small {
    width: 36px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 22px;
}

.slider::before {
    position: absolute;
    content: '';
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.switch.small .slider::before {
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
}

.switch input:checked + .slider {
    background-color: #007bff;
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.switch.small input:checked + .slider::before {
    transform: translateX(18px);
}

/* Fade-in effect on page load */
body {
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

html,
body {
    transition: background 0.3s ease, color 0.3s ease;
}

.download-button {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    background-color: #28a745;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.download-button:hover {
    background-color: #218838;
}

html.dark .download-button {
    background-color: #3cb371;
}

html.dark .download-button:hover {
    background-color: #2e8b57;
}

.download-container {
    text-align: center;
    margin-top: 1.5rem;
}

.download-button {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    background-color: #28a745;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.download-button:hover {
    background-color: #218838;
}

html.dark .download-button {
    background-color: #3cb371;
}

html.dark .download-button:hover {
    background-color: #2e8b57;
}

.processing-list {
    overflow-y: auto;
    max-height: 30vh; /* Adjust based on how tall you want it */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.processing-card {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

html.dark .processing-card {
    background: #1f1f1f;
}

.job-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.job-status {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #666;
}

html.dark .job-status {
    color: #aaa;
}

.progress-bar {
    height: 10px;
    background: #ddd;
    border-radius: 5px;
    overflow: hidden;
}

html.dark .progress-bar {
    background: #333;
}

.progress-bar-fill {
    height: 100%;
    background-color: #4caf50;
    width: 0%;
    transition: width 0.4s ease;
}

.processing-card.error {
    border-left: 5px solid #e74c3c;
    background: #ffe5e5;
}

html.dark .processing-card.error {
    background: #2b1d1d;
    border-color: #e74c3c;
}

.processing-card.error .job-status {
    color: #c0392b;
    font-weight: bold;
}

.results-grid::-webkit-scrollbar,
.processing-list::-webkit-scrollbar {
    width: 6px;
}

.results-grid::-webkit-scrollbar-thumb,
.processing-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

html.dark .results-grid::-webkit-scrollbar-thumb,
html.dark .processing-list::-webkit-scrollbar-thumb {
    background: #555;
}

.no-jobs-msg {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 1rem;
}

html.dark .no-jobs-msg {
    color: #aaa;
}

.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
        height: 0;
        margin: 0;
        padding: 0;
    }
}

.view-progress-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 16px;
    background-color: var(--primary-color, #4caf50);
    color: white;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.view-progress-btn:hover {
    background-color: var(--primary-color-dark, #388e3c);
}

.view-progress-inline {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 10px;
    font-size: 0.9em;
    border-radius: 4px;
    background-color: var(--primary-color, #4caf50);
    color: white;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.view-progress-inline:hover {
    background-color: var(--primary-color-dark, #388e3c);
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: auto; /* Enable vertical scroll if needed */
    -webkit-overflow-scrolling: touch; /* Smooth scroll on mobile */
}

form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    word-wrap: break-word;
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.drop-zone,
.drop-box,
fieldset {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

@media screen and (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .help-icon {
        font-size: 0.9em;
    }

    button {
        font-size: 1em;
    }
}
