/*
    -----------------------------------------------------
    1. GENERAL STYLES, FONT, AND COLORS
    -----------------------------------------------------
*/

/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #2563eb; /* Blue */
    --primary-hover: #1d4ed8;
    --text-dark: #1e293b; /* Slate 800/900 */
    --text-medium: #475569; /* Slate 600 */
    --background-light: #f8fafc; /* Slate 50 */
    --card-background: #ffffff;
    --border-color: #e2e8f0; /* Slate 200/300 */
    --shadow-base: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

main {
    flex: 1;
}

/* --- Utility Classes (Tailwind Replacement for better control) --- */
.container-max-w {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.text-center { text-align: center; }
.hidden { display: none !important; }

/*
    -----------------------------------------------------
    2. HEADER (NAVBAR) DESIGN
    -----------------------------------------------------
*/
.header {
    background-color: var(--card-background);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header .nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.logo {
    font-size: 1.5rem; /* 2xl */
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.025em;
    z-index: 50;
}

.logo span {
    color: var(--text-dark);
}

.nav-links {
    display: none;
    gap: 2rem;
    font-size: 0.875rem; /* text-sm */
    font-weight: 500;
    color: var(--text-medium);
}

.nav-links a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    color: var(--text-medium);
    border: none;
    background: none;
    cursor: pointer;
    z-index: 50;
}

.mobile-menu-btn svg {
    width: 2rem;
    height: 2rem;
}

/* Mobile Menu Dropdown */
#mobileMenu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--card-background);
    box-shadow: var(--shadow-base);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    text-align: center;
    font-weight: 500;
    color: var(--text-medium);
}

#mobileMenu a {
    display: block;
    padding: 0.5rem 0;
    text-decoration: none;
    color: inherit;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

#mobileMenu a:hover {
    background-color: #f1f5f9; /* Slate 100 */
    color: var(--primary-color);
}

/* Show desktop navigation and hide mobile button on larger screens */
@media (min-width: 768px) {
    .nav-links {
        display: flex;
    }
    .mobile-menu-btn {
        display: none;
    }
}


/*
    -----------------------------------------------------
    3. MAIN PAGE DESIGN (TOOL AREA)
    -----------------------------------------------------
*/
.main-content-wrapper {
    max-width: 64rem; /* max-w-4xl */
    margin-left: auto;
    margin-right: auto;
    padding: 3rem 1rem;
}

.hero-text {
    margin-bottom: 3rem;
}

.hero-text h1 {
    font-size: 2.25rem; /* 3xl */
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.hero-text p {
    font-size: 1.125rem; /* lg */
    color: var(--text-medium);
}

.tool-card {
    background-color: var(--card-background);
    border-radius: 1rem; /* rounded-2xl */
    box-shadow: var(--shadow-base);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
}


/* --- Upload Area --- */
#uploadArea {
    border: 2px dashed #cbd5e1; /* Slate 300 */
    border-radius: 0.75rem; /* rounded-xl */
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    background-color: #f8fafc; /* Slate 50 */
    transition: all 0.3s ease;
}

#uploadArea:hover {
    background-color: #f1f5f9; /* Slate 100 */
}

/* Custom Drop Zone Active State */
.drop-zone.active {
    border-color: var(--primary-color) !important;
    background-color: #eff6ff !important; /* Blue 50 */
}

#uploadArea svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: #3b82f6; /* Blue 500 */
}

#uploadArea h3 {
    font-size: 1.25rem; /* xl */
    font-weight: 600;
    color: #334155; /* Slate 700 */
}

#uploadArea p {
    font-size: 0.875rem; /* sm */
    color: #64748b; /* Slate 500 */
    margin-top: 0.5rem;
}

/* Browse Button */
.btn-browse {
    margin-top: 1.5rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 9999px; /* rounded-full */
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-browse:hover {
    background-color: var(--primary-hover);
}


/* --- Settings Area (After Upload) --- */
#settingsArea {
    margin-top: 1rem;
}

.info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #eff6ff; /* Blue 50 */
    padding: 1rem;
    border-radius: 0.75rem; /* rounded-xl */
    margin-bottom: 2rem;
    border: 1px solid #bfdbfe; /* Blue 100 */
}

.info-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#previewThumb {
    height: 4rem;
    width: 4rem;
    object-fit: cover;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    background-color: var(--card-background);
}

.info-details p {
    font-size: 0.875rem; /* sm */
    font-weight: 700;
    color: #334155; /* Slate 700 */
}

.info-details span {
    color: var(--primary-color);
}

.info-details .original-dims {
    font-size: 0.75rem; /* xs */
    color: #64748b; /* Slate 500 */
    margin-top: 0.25rem;
}

.btn-change {
    color: #ef4444; /* Red 500 */
    font-size: 0.875rem; /* sm */
    font-weight: 500;
    background: none;
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-change:hover {
    background-color: var(--card-background);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- Controls Grid --- */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 3rem;
    }
}

.control-section-header {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.125rem; /* lg */
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
}

.control-section-header span {
    background-color: var(--text-dark);
    color: var(--card-background);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem; /* xs */
    margin-right: 0.5rem;
}

.input-label {
    display: block;
    font-size: 0.75rem; /* xs */
    font-weight: 700;
    color: #64748b; /* Slate 500 */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.input-field-group {
    display: flex;
    gap: 1rem;
}

.input-field-group > div {
    width: 50%;
}

input[type="number"],
select {
    width: 100%;
    border: 1px solid #cbd5e1; /* Slate 300 */
    border-radius: 0.5rem; /* rounded-lg */
    padding: 0.75rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

input[type="number"]:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Aspect Ratio Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    background-color: #f8fafc; /* Slate 50 */
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.checkbox-container input[type="checkbox"] {
    height: 1.25rem;
    width: 1.25rem;
    color: var(--primary-color);
    border-radius: 0.25rem;
    cursor: pointer;
    margin-right: 0.75rem;
}

.checkbox-container label {
    font-size: 0.875rem; /* sm */
    font-weight: 500;
    color: #334155; /* Slate 700 */
    cursor: pointer;
}

/* Format Dropdown Custom Arrow */
.relative {
    position: relative;
}

.select-arrow {
    pointer-events: none;
    position: absolute;
    inset-y: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding-right: 0.75rem;
    color: #64748b; /* Slate 500 */
}

.select-arrow svg {
    fill: currentColor;
    height: 1rem;
    width: 1rem;
}

/* --- Action Button --- */
.action-area {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-process {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    font-size: 1.125rem; /* lg */
    padding: 1rem 2.5rem;
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3), 0 4px 6px -2px rgba(37, 99, 235, 0.1);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-process:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.5), 0 10px 10px -5px rgba(37, 99, 235, 0.2);
    transform: translateY(-2px);
}

@media (min-width: 768px) {
    .btn-process {
        width: auto;
    }
}

/* Status Message */
#statusMsg {
    margin-top: 1rem;
    font-size: 0.875rem; /* sm */
    font-weight: 700;
    color: #15803d; /* Green 600 */
    background-color: #f0fdf4; /* Green 50 */
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #dcfce7; /* Green 200 */
}

/* Loading Spinner (from your HTML) */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-left: 0.75rem;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/*
    -----------------------------------------------------
    4. QUICK TOOLS SECTION
    -----------------------------------------------------
*/
.quick-tools-section {
    max-width: 1200px; /* max-w-6xl */
    margin: 0 auto;
    padding: 2.5rem 1rem;
}

.quick-tools-section h2 {
    font-size: 1.5rem; /* 2xl */
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-dark);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 640px) {
    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .tool-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.tool-link {
    display: block;
    padding: 1rem;
    background-color: var(--card-background);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    text-decoration: none;
    text-align: center;
}

.tool-link:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    background-color: #eff6ff; /* Blue 50 */
    transform: translateY(-2px);
}

.tool-link p:first-child {
    font-size: 0.875rem; /* sm */
    font-weight: 700;
    color: #1d4ed8; /* Blue 700 */
}

.tool-link p:last-child {
    font-size: 0.75rem; /* xs */
    color: #64748b; /* Slate 500 */
    margin-top: 0.25rem;
}

/* --- Article/Content Section --- */
.article-section {
    max-width: 48rem; /* max-w-3xl */
    margin: 0 auto;
    padding: 2.5rem 1rem 5rem;
}

.article-section h2, .article-section h3 {
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.article-section h2 {
    font-size: 1.5rem; /* 2xl */
}

@media (min-width: 768px) {
    .article-section h2 {
        font-size: 1.875rem; /* 3xl */
    }
}

.article-section p {
    color: var(--text-medium);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.article-section strong {
    font-weight: 700;
    color: var(--text-dark);
}

.feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 2.5rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.feature-box {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
}

.feature-box h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    margin-top: 0;
    padding-bottom: 0;
    border: none;
}

.feature-box p {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0;
}

.how-to-list {
    list-style: decimal;
    padding-left: 1.5rem;
    color: var(--text-medium);
    margin-bottom: 1.5rem;
}

.how-to-list li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.how-to-list li strong {
    color: var(--primary-color);
}


/*
    -----------------------------------------------------
    5. FOOTER DESIGN
    -----------------------------------------------------
*/
.footer {
    background-color: #0f172a; /* Slate 900 */
    color: #94a3b8; /* Slate 400 */
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
    text-align: center;
}

.footer-content h3 {
    color: var(--card-background);
    font-weight: 700;
    font-size: 1.125rem; /* lg */
    margin-bottom: 1rem;
}

.footer-content p {
    font-size: 0.875rem; /* sm */
    margin-bottom: 1.5rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

.footer-links-wrapper {
    border-top: 1px solid #334155; /* Slate 800 */
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem; /* sm */
}

@media (min-width: 768px) {
    .footer-links-wrapper {
        flex-direction: row;
        gap: 2rem;
    }
}

.footer-links-wrapper a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links-wrapper a:hover {
    color: var(--card-background);
}

.copyright {
    margin-top: 2rem;
    font-size: 0.75rem; /* xs */
    color: #475569; /* Slate 600 */
}