/* Variables for brand colors */
:root {
    --brand-primary: #00524B; /* Main dark green */
    --brand-secondary: #61CE70; /* Bright green */
    --white: #ffffff;
    --dark-text: #303234; /* Dark grey for text */
    --light-grey: #f0f0f0; /* Light background for settings/previews */
    --medium-grey: #dee2e6; /* Border colors */
    --red: #dc3545; /* Danger/error */
    --green: #28a745; /* Success */
    --blue: #007bff; /* General info/links */
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

/* Basic Resets & Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--white); /* Main website background */
    min-height: 100vh;
    display: flex;
    flex-direction: column; /* For sticky footer */
    overflow-x: hidden; /* Prevent horizontal scroll on small screens */
    /* overflow-y: scroll; Always show scrollbar to prevent layout shifts */
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    flex-grow: 1; /* Allows main content to expand */
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.main-header {
    background-color: var(--white);
    color: var(--dark-text);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap; /* Allows wrapping on small screens */
    border-bottom: 1px solid var(--medium-grey);
    position: sticky; /* Sticky header */
    top: 0;
    z-index: 100; /* Ensure header is above other content */
}

.main-header .logo img {
    height: 50px;
    width: auto;
    border-radius: 8px; /* Added for placeholder image */
}

.main-header .header-text {
    text-align: center;
    flex-grow: 1;
    margin: 0 20px;
    min-width: 200px; /* Ensure text doesn't collapse too much */
}

.main-header .header-text h2 {
    font-size: 1.6em;
    color: var(--brand-primary);
    margin-bottom: 3px;
}

.main-header .header-text p {
    font-size: 0.9em;
    color: var(--dark-text);
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: flex-end; /* Align menu to the right */
}

.main-nav ul li a {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.main-nav ul li a:hover,
.main-nav ul li a.active {
    background-color: var(--brand-primary);
    color: var(--white);
}

/* --- Buttons --- */
.btn {
    display: inline-flex; /* Use inline-flex to center content easily */
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none; /* For links styled as buttons */
    margin: 5px; /* Added for general spacing */
}

.btn i {
    margin-right: 8px;
}

.primary-btn {
    background-color: var(--brand-primary);
    color: var(--white);
}
.primary-btn:hover:not(:disabled) {
    background-color: #003d38; /* Slightly darker primary */
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.secondary-btn {
    background-color: var(--brand-secondary);
    color: var(--dark-text);
}
.secondary-btn:hover:not(:disabled) {
    background-color: #4CAF50; /* A darker shade of secondary */
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.success-btn {
    background-color: var(--green);
    color: var(--white);
}
.success-btn:hover:not(:disabled) {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.danger-btn {
    background-color: var(--red);
    color: var(--white);
}
.danger-btn:hover:not(:disabled) {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.google-btn {
    background-color: #DB4437; /* Google red */
    color: var(--white);
}
.google-btn:hover:not(:disabled) {
    background-color: #C33B2E;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(50%);
}

/* --- Section Styling --- */
section {
    background-color: var(--white);
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    flex-grow: 1; /* Make sections fill container height */
}

h1, h2 {
    color: var(--brand-primary);
    margin-bottom: 20px;
    text-align: center;
}

/* --- Home Section --- */
.hero-section {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, var(--brand-secondary) 0%, var(--brand-primary) 100%);
    color: var(--white);
    border-radius: 10px;
    margin-bottom: 30px;
}

.hero-section h1 {
    font-size: 3em;
    margin-bottom: 15px;
    color: var(--white);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.hero-description {
    font-size: 1.3em;
    max-width: 700px;
    margin: 0 auto 30px auto;
    line-height: 1.5;
}

.hero-cta .btn {
    font-size: 1.2em;
    padding: 15px 30px;
    background-color: var(--white);
    color: var(--brand-primary);
    font-weight: bold;
}
.hero-cta .btn:hover {
    background-color: var(--light-grey);
    transform: scale(1.05);
}


/* --- Forms and Inputs --- */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--medium-grey);
    border-radius: 5px;
    font-size: 1em;
}

.message-status {
    padding: 10px;
    border-radius: 5px;
    margin-top: 15px;
    text-align: center;
    font-weight: bold;
}
.message-status.success { background-color: #d4edda; color: var(--green); }
.message-status.error { background-color: #f8d7da; color: var(--red); }

/* --- Modals --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1001; /* Sit on top of other content */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--white);
    margin: auto;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    position: relative;
    width: 90%;
    max-width: 450px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content h2 {
    margin-bottom: 25px;
    color: var(--brand-primary);
}

.close-button {
    color: var(--dark-text);
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-button:hover,
.close-button:focus {
    color: var(--red);
    text-decoration: none;
    cursor: pointer;
}

.auth-switch-text {
    margin-top: 15px;
    text-align: center;
    font-size: 0.9em;
}
.auth-switch-text a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: bold;
}
.auth-switch-text a:hover {
    text-decoration: underline;
}

.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
    color: var(--medium-grey);
}
.divider::before, .divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background-color: var(--medium-grey);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* API Key in User Profile Modal */
.api-key-setting {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    background-color: var(--light-grey);
}

.api-key-setting label {
    font-weight: bold;
    margin-bottom: 8px;
}

.api-key-setting input[type="password"] {
    margin-bottom: 10px;
}

.api-key-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.api-key-warning {
    color: var(--red);
    font-size: 0.85em;
    margin-top: 10px;
}

/* --- Metadata Generate Section Layout --- */
.metadata-layout {
    display: flex;
    gap: 25px;
}

.left-sidebar {
    flex: 0 0 25%; /* 25% width */
    background-color: var(--white);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 250px; /* Prevent it from getting too narrow */
}

.left-sidebar h2 {
    font-size: 1.5em;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--brand-secondary);
    padding-bottom: 10px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Customizing Range Sliders */
.setting-group input[type="range"] {
    -webkit-appearance: none; /* Remove default styling for Chrome/Safari */
    appearance: none; /* Remove default styling for Firefox */
    width: 100%;
    height: 8px;
    background: var(--light-grey);
    border-radius: 5px;
    outline: none;
    transition: background-color .2s;
    margin-top: 5px;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: grab;
    border: 2px solid var(--white);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    margin-top: -6px; /* Adjust thumb position */
}

.setting-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: grab;
    border: 2px solid var(--white);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

.setting-group small {
    display: block;
    font-size: 0.8em;
    color: var(--dark-text);
    margin-top: 5px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}
.checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}
.checkbox-item label {
    margin-bottom: 0;
}

.right-working-section {
    flex: 1; /* Takes remaining 75% */
    background-color: var(--white);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.right-working-section h2 {
    font-size: 1.8em;
    margin-bottom: 25px;
}

.platforms {
    background-color: var(--light-grey);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 0.95em;
    line-height: 1.5;
}

/* Metadata Upload Area */
.upload-area {
    border: 2px dashed var(--brand-secondary);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 25px;
    transition: background-color 0.3s ease;
}

.upload-area:hover {
    background-color: #f7fff7; /* Lighter shade of brand-secondary */
}

.upload-area input[type="file"] {
    display: none;
}

.upload-button {
    display: inline-block;
    background-color: var(--brand-primary);
    color: var(--white);
    padding: 12px 25px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    font-weight: bold;
    font-size: 1.1em;
}

.file-type-boxes {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 15px;
}

.file-type-box {
    background-color: var(--brand-secondary);
    color: var(--dark-text);
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9em;
}

.upload-hint {
    color: var(--dark-text);
    font-size: 0.9em;
}

.top-action-buttons, .bottom-action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
}

.bottom-action-buttons {
    margin-top: 30px; /* More space for bottom buttons */
    border-top: 1px solid var(--medium-grey);
    padding-top: 20px;
}

/* Overall Progress Bar for Upload/Process */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background-color: var(--light-grey);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 15px;
    margin-bottom: 25px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--brand-secondary);
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* File Grid Display */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Default desktop 5-column or flexible */
    gap: 20px;
    padding: 10px;
    border-top: 1px solid var(--medium-grey);
    padding-top: 20px;
}

.file-card {
    background-color: var(--white);
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes metadata/progress to bottom */
}

.file-card img {
    max-width: 100%;
    height: 100px; /* Fixed height for image previews */
    object-fit: contain;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid var(--light-grey);
}

.file-card p {
    font-size: 0.85em;
    word-break: break-all; /* Break long file names */
    margin-bottom: 10px;
    font-weight: 500;
}

/* Individual File Card Progress */
.file-card .metadata-progress-text {
    font-size: 0.9em;
    color: var(--brand-primary);
    margin-top: 5px;
    font-weight: bold;
    min-height: 1.2em; /* Prevent text jumps */
}

.file-card .individual-progress-bar-container {
    width: 100%;
    height: 5px;
    background-color: var(--light-grey);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
    margin-bottom: 10px;
}

.file-card .individual-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--brand-secondary);
    border-radius: 3px;
    transition: width 0.3s ease;
}


.file-card .metadata-display {
    text-align: left;
    font-size: 0.8em;
    margin-top: 10px;
    background-color: var(--light-grey);
    padding: 8px;
    border-radius: 5px;
    display: none; /* Hidden until generated */
    overflow-y: auto; /* Allow scrolling if metadata is long */
    max-height: 120px; /* Limit height of metadata display */
    flex-grow: 1; /* Allow it to take available space */
}
.file-card .metadata-display strong {
    color: var(--brand-primary);
}
.file-card .metadata-display p {
    margin-bottom: 5px;
    word-break: break-word;
}
.file-card .metadata-display p:last-child {
    margin-bottom: 0;
}

/* --- Image to Prompt Section --- */
.prompt-upload-area {
    border: 2px dashed var(--brand-secondary);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 25px;
    transition: background-color 0.3s ease;
}
.prompt-upload-area:hover {
    background-color: #f7fff7;
}
.prompt-upload-area input[type="file"] {
    display: none;
}
.prompt-image-preview {
    margin-top: 20px;
    max-width: 300px;
    height: 200px; /* Fixed height for consistency */
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--light-grey); /* Placeholder background */
}
.prompt-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#generatePromptBtn {
    display: block;
    margin: 20px auto;
}

.generated-output {
    background-color: var(--light-grey);
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    padding: 20px;
    margin-top: 25px;
}
.generated-output p {
    font-size: 1.1em;
    line-height: 1.8;
    margin-bottom: 15px;
    word-break: break-word;
}
.generated-output .btn {
    display: block;
    margin: 10px auto 0 auto;
}

/* --- Contact Form --- */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.contact-form .form-group {
    margin-bottom: 20px;
}
.contact-form .btn {
    display: block;
    width: 100%;
    max-width: 200px;
    margin: 20px auto 0 auto;
}


/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Higher than modals */
    display: none; /* Hidden by default */
}

.spinner {
    border: 8px solid var(--light-grey);
    border-top: 8px solid var(--brand-primary);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 1.2em;
    color: var(--dark-text);
}

/* --- Footer --- */
.main-footer {
    background-color: var(--dark-text);
    color: var(--white);
    text-align: center;
    padding: 15px;
    font-size: 0.9em;
    margin-top: auto; /* Pushes footer to the bottom */
}


/* --- Responsive Design --- */
@media (max-width: 1024px) {
    .metadata-layout {
        flex-direction: column;
    }
    .left-sidebar {
        flex: auto;
        min-width: unset;
        width: 100%;
    }
    .right-working-section {
        flex: auto;
        width: 100%;
    }
    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Adjust for tablets */
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .main-header .header-text {
        text-align: left;
        margin-left: 0;
        margin-top: 10px;
    }
    .main-nav ul {
        flex-direction: column;
        width: 100%;
        gap: 5px;
        align-items: flex-start;
        margin-top: 10px;
    }
    .main-nav ul li {
        width: 100%;
    }
    .main-nav ul li a {
        padding: 10px;
        justify-content: flex-start;
    }

    .hero-section h1 {
        font-size: 2.2em;
    }
    .hero-description {
        font-size: 1.1em;
    }

    .container {
        margin: 10px auto;
        padding: 0 10px;
    }

    section {
        padding: 20px;
    }

    .top-action-buttons, .bottom-action-buttons {
        flex-direction: column;
        gap: 15px;
    }
    .btn {
        width: 100%;
        max-width: 300px; /* Constrain width even when full-width */
        margin-left: auto;
        margin-right: auto;
    }

    .files-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet 2-column */
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .main-header .header-text h2 {
        font-size: 1.4em;
    }
    .main-header .header-text p {
        font-size: 0.8em;
    }
    .hero-section {
        padding: 40px 15px;
    }
    .hero-section h1 {
        font-size: 1.8em;
    }
    .hero-description {
        font-size: 1em;
    }
    .modal-content {
        padding: 20px;
    }
    .files-grid {
        grid-template-columns: 1fr; /* Mobile single-column */
    }
    .file-type-boxes {
        flex-direction: column;
    }
    .file-type-box {
        width: 100%;
    }
}

/* Keyframe animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}