/* tools/image-converter/image-converter.css */

/* --- Overall Tool Page Layout (consistent with other tools) --- */
.tool-page-main {
    padding: 4rem 0 5rem; 
    background-color: var(--bg-main);
    overflow-x: hidden; 
}

.tool-container {
    max-width: 80vw; /* Consistent with other tools */
    margin: 0 auto;
    padding: 0 var(--space-xl); 
}
@media (min-width: 1600px) { /* Cap max-width for very large screens */
    .tool-container {
        max-width: 1280px; 
    }
}


/* --- Tool Header (consistent with other tools) --- */
.tool-header {
    text-align: center;
    margin-top: 2rem; 
    margin-bottom: 4rem; 
}

.tool-icon-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem; 
    margin-bottom: 1.2rem; 
}

.tool-icon {
    font-size: 3.5rem; 
    color: var(--accent-color);
}

.tool-header h1 {
    font-size: clamp(2.5rem, 6vw, 4rem); 
    font-weight: 900; 
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 0;
    letter-spacing: -0.03em; 
}

.tool-description {
    font-size: clamp(1rem, 2.5vw, 1.25rem); 
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 700px;
    margin: 0.8rem auto 0 auto;
}

/* --- Error Message Container (consistent) --- */
.error-message-container {
    background-color: #fef2f2; 
    border: 1px solid #ef4444; 
    color: #b91c1c; 
    padding: 1rem 1.5rem; 
    border-radius: 10px; 
    margin-bottom: 2rem; 
    display: flex;
    align-items: center;
    gap: 0.75rem; 
    font-size: var(--fs-base); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    text-align: left; 
}
html[data-theme="dark"] .error-message-container {
    background-color: #3f0f0f;
    border-color: #dc2626;
    color: #ef4444;
}
.error-message-container p { 
    margin: 0;
}


/* --- Main Converter Card (.image-converter-card) --- */
.image-converter-card { 
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px; 
    box-shadow: 0 15px 50px rgba(0,0,0,0.1); 
    height: 85vh; /* Fixed height for larger screens */
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    margin-bottom: 4rem; 
    max-width: 1000px; /* A bit wider for image tool to see previews */
    margin-left: auto;
    margin-right: auto;
    transition: all 0.3s ease-out; 
}
html[data-theme="dark"] .image-converter-card {
    box-shadow: 0 15px 50px rgba(0,0,0,0.25);
}

/* Inner Grid for Converter Content (input vs results panels) */
.converter-grid-wrapper { /* Renamed from calculator-grid-wrapper for clarity */
    flex-grow: 1; 
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* Input panel is significantly bigger than result */
    gap: 0; 
    overflow: hidden; 
}

/* Input Panel (left side/top) */
.input-panel {
    display: flex;
    flex-direction: column;
    height: 100%; 
    position: relative;
    padding: var(--space-xl) var(--space-xxl) var(--space-xl) var(--space-xl); 
    border-right: 1px solid var(--border-color); 
    overflow-y: auto; 
    padding-bottom: var(--space-lg); 
    background-color: var(--bg-main); 
}
html[data-theme="dark"] .input-panel {
    border-right-color: var(--border-grid-gray-dark);
    background-color: var(--bg-card); 
}
.input-panel::-webkit-scrollbar { width: 6px; }
.input-panel::-webkit-scrollbar-track { background: var(--bg-highlight); border-radius: 10px; }
.input-panel::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 10px; }
.input-panel::-webkit-scrollbar-thumb:hover { background: var(--btn-primary-hover); }


/* Result Display Panel (right side/bottom) */
.results-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Push bottom element to bottom */
    height: 100%; 
    position: relative;
    overflow-y: auto; 
    padding: var(--space-xl); 
    background-color: var(--bg-card); 
}
.results-panel::-webkit-scrollbar { width: 6px; }
.results-panel::-webkit-scrollbar-track { background: var(--bg-highlight); border-radius: 10px; }
.results-panel::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 10px; }
.results-panel::-webkit-scrollbar-thumb:hover { background: var(--btn-primary-hover); }

/* Spacing for sections within results-panel, and pushing last item to bottom */
.results-panel > *:not(:last-child) {
    margin-bottom: var(--space-xl);
}
.results-panel > :last-child {
    margin-top: auto; /* Push the very last element to the bottom */
}


/* --- Section Titles within Panels/Cards (consistent) --- */
.section-title-within-tab {
    font-size: clamp(1.6rem, 3.5vw, 2.2rem); 
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: left; 
}

/* --- Form/Control Styles (consistent) --- */
.form-group {
    margin-bottom: 1.5rem; 
}
.form-group label {
    font-size: var(--fs-md); 
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem; 
}
.form-control {
    width: 100%;
    padding: 0.85rem 1.2rem; 
    font-size: var(--fs-base); 
    border: 1px solid var(--border-color);
    border-radius: 10px; 
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(76, 81, 191, 0.2); 
}
html[data-theme="dark"] .form-control {
    background-color: var(--bg-card);
}
html[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.form-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: 0.6rem; 
    display: block;
    line-height: 1.5;
}

/* Divider for sections */
.divider {
    border-top: 1px dashed var(--border-color);
    margin: 2rem 0;
}
html[data-theme="dark"] .divider {
    border-top-color: var(--text-secondary);
}


.form-actions {
    display: flex;
    gap: 1rem; 
    margin-top: 2rem; 
    flex-wrap: wrap;
}
.form-actions .btn {
    flex-grow: 1;
    max-width: 250px; 
    font-size: var(--fs-base); 
    padding: 0.9rem 1.5rem; 
    border-radius: 10px; 
}
.form-actions.full-width .btn {
    max-width: none; 
}

/* --- Upload Area Specific Styles --- */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px; /* Ensure enough height for drag area */
    position: relative;
}
html[data-theme="dark"] .upload-area {
    border-color: var(--border-grid-gray-dark);
}
.upload-area:hover {
    border-color: var(--accent-color);
    background-color: var(--bg-highlight);
}
.upload-area.highlight { /* Class for drag-over effect */
    border-color: var(--accent-color);
    background-color: color-mix(in srgb, var(--accent-color) 8%, var(--bg-highlight) 92%);
}
.upload-area .drag-text {
    font-size: var(--fs-lg);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.upload-area .or-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.upload-area .btn-primary {
    margin-top: 0.5rem; /* Space between "OR" and button */
}
.upload-area .form-text { /* Small text below upload button */
    margin-top: 1rem;
}

.uploaded-file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-highlight);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    width: 100%;
    justify-content: space-between;
}
html[data-theme="dark"] .uploaded-file-info {
    background-color: var(--bg-main);
}
.uploaded-file-info i {
    color: var(--accent-color);
    font-size: var(--fs-md);
}
.uploaded-file-info span {
    flex-grow: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.uploaded-file-info .clear-image-btn {
    flex-shrink: 0;
    font-size: var(--fs-base);
    color: var(--text-secondary);
    padding: 0.2rem;
}

/* --- Conversion Options Specific Styles --- */
.conversion-options {
    margin-top: var(--space-xxl); /* Space after upload area */
}
.conversion-options h3 {
    margin-bottom: 1.5rem;
}
.form-group #imageQuality { /* Style for range input */
    padding: 0; /* Remove default input padding */
    height: auto;
    -webkit-appearance: none; /* Override default browser styles for range input */
    appearance: none;
    background: transparent; /* Hide the default track */
    cursor: pointer;
}

/* Custom styling for Webkit browsers (Chrome, Safari) */
.form-group #imageQuality::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: var(--bg-highlight);
    border-radius: 4px;
}
.form-group #imageQuality::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    border: 2px solid var(--text-light);
    margin-top: -6px; /* Adjust thumb position */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
/* Custom styling for Firefox */
.form-group #imageQuality::-moz-range-track {
    width: 100%;
    height: 8px;
    background: var(--bg-highlight);
    border-radius: 4px;
}
.form-group #imageQuality::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    border: 2px solid var(--text-light);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- Preview & Download Section --- */
.image-preview-area {
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
html[data-theme="dark"] .image-preview-area {
    border-color: var(--border-grid-gray-dark);
}

.image-preview-area img, .image-preview-area canvas {
    max-width: 100%;
    max-height: 280px; /* Limit image height to fit within panel */
    object-fit: contain;
    display: block; /* To remove extra space below img */
}
.image-preview-area .preview-placeholder-text {
    color: var(--text-secondary);
    font-size: var(--fs-md);
    text-align: center;
    margin: 0;
}

.download-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: auto; /* Push to bottom of results-panel */
    padding-top: var(--space-xl); /* Space from preview */
    border-top: 1px solid var(--border-color); /* Separator */
}
html[data-theme="dark"] .download-section {
    border-top-color: var(--border-grid-gray-dark);
}

.download-section .converted-file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.download-section .converted-file-info i {
    color: var(--accent-color);
}
.download-section .btn-primary {
    width: 100%;
    max-width: 250px; /* Limit button width */
}


/* --- Info, FAQ, CTA sections (consistent) --- */
.info-section, .faq-section, .support-tool-cta { 
    padding: var(--space-xxl); 
    margin-top: 4rem;
    margin-bottom: 4rem;
    border-radius: 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); 
}

.info-section .column-title, .faq-section .column-title, .support-tool-cta h3 { 
    font-size: var(--fs-xl); 
    font-weight: 700;
    margin-bottom: 1rem; 
    text-align: left;
}
.info-section p, .faq-section p, .support-tool-cta p { 
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem; 
    padding: 0 0.5rem; 
}
.info-section p:last-of-type { 
    margin-bottom: 0;
}
.info-section .info-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}
.info-section .info-list li {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
    padding-right: 0.5rem;
}
.info-section .info-list li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.how-to-list { 
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-top: 1rem;
}
.how-to-list li {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.6;
    padding-right: 0.5rem;
}
.how-to-list li strong {
    color: var(--text-primary);
}


/* Support Tool CTA (consistent) */
.support-tool-cta { 
    text-align: center;
}
.support-tool-cta .support-tool-icon {
    font-size: 4rem; 
    color: var(--accent-color);
    margin-bottom: 1.5rem; 
}
.support-tool-cta p {
    max-width: 600px; 
    margin-left: auto;
    margin-right: auto;
}
.support-tool-cta .coffee-btn-small {
    font-size: var(--fs-base); 
    padding: 0.9rem 1.8rem; 
    border-radius: 10px; 
}

/* --- Responsive Adjustments (consistent) --- */
@media (max-width: 992px) { 
    .tool-page-main { padding: 2.5rem 0 3.5rem; }
    .tool-header { margin-bottom: 2.5rem; }
    .tool-icon { font-size: 2.5rem; }
    .tool-header h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); }
    .tool-description { font-size: var(--fs-base); }

    .image-converter-card {
        padding: var(--space-lg); 
        height: auto; 
        min-height: 70vh; 
    }
    .converter-grid-wrapper { /* Use specific class for consistency */
        grid-template-columns: 1fr; 
        gap: var(--space-xl); 
        padding: var(--space-md); 
    }
    .input-panel {
        padding-right: 0;
        border-right: none; 
        padding-bottom: var(--space-lg); 
        border-bottom: 1px solid var(--border-color); 
    }
    html[data-theme="dark"] .input-panel { border-bottom-color: var(--border-grid-gray-dark); border-right-color: transparent; }
    .results-panel {
        padding-left: 0;
        padding-top: var(--space-lg); 
        margin-top: 0; 
        border-top: 1px solid var(--border-color); 
    }
    html[data-theme="dark"] .results-panel { border-top-color: var(--border-grid-gray-dark); }
    
    .results-panel > *:not(:last-child) { margin-bottom: var(--space-lg); } 
    .results-panel > :last-child { margin-top: var(--space-lg); } 

    .upload-area {
        padding: 1.5rem;
        min-height: 180px;
    }
    .upload-area .drag-text {
        font-size: var(--fs-base);
    }
    .upload-area .or-text {
        font-size: var(--fs-sm);
    }
    .upload-area .btn-primary {
        font-size: var(--fs-sm);
        padding: 0.7rem 1.2rem;
    }
    .upload-area .form-text {
        font-size: var(--fs-xs);
    }
    .uploaded-file-info {
        font-size: var(--fs-xs);
        padding: 0.5rem 0.8rem;
    }
    .uploaded-file-info i {
        font-size: var(--fs-base);
    }
    .uploaded-file-info .clear-image-btn {
        font-size: var(--fs-sm);
    }

    .conversion-options {
        margin-top: var(--space-xl);
    }
    .conversion-options h3 {
        font-size: var(--fs-base);
        margin-bottom: 1rem;
    }
    .form-group label {
        font-size: var(--fs-sm);
    }
    .form-control {
        font-size: var(--fs-sm);
        padding: 0.7rem 1rem;
    }
    .form-text {
        font-size: var(--fs-xs);
    }
    .form-actions {
        margin-top: 1.5rem;
    }
    .form-actions .btn {
        font-size: var(--fs-sm);
        padding: 0.7rem 1.2rem;
    }

    .image-preview-area {
        min-height: 200px;
        max-height: 250px;
    }
    .image-preview-area img, .image-preview-area canvas {
        max-height: 200px;
    }
    .image-preview-area .preview-placeholder-text {
        font-size: var(--fs-base);
    }

    .download-section {
        padding-top: var(--space-lg);
    }
    .download-section .converted-file-info {
        font-size: var(--fs-xs);
    }
    .download-section .btn-primary {
        font-size: var(--fs-sm);
        padding: 0.7rem 1.2rem;
    }

    .info-section, .faq-section, .support-tool-cta {
        padding: 2.5rem; 
        margin-top: 3rem;
        margin-bottom: 3rem;
    }
    .info-section .column-title, .faq-section .column-title, .support-tool-cta h3 { font-size: var(--fs-lg); }
    .info-section p, .faq-section p, .support-tool-cta p { font-size: var(--fs-sm); }
    .how-to-list li { font-size: var(--fs-sm); }
    .support-tool-cta .tool-icon { font-size: 3rem; } 
    .support-tool-cta .coffee-btn-small { font-size: var(--fs-sm); }
}

@media (max-width: 576px) { 
    .tool-page-main { padding: 1.5rem 0 2rem; }
    .tool-header { margin-bottom: 1.5rem; }
    .tool-icon { font-size: 2rem; }
    .tool-header h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
    .tool-description { font-size: var(--fs-sm); }

    /* Mobile: Card 100% width, 5px padding left/right */
    .image-converter-card {
        width: calc(100% - 10px); /* 100% of viewport width minus 5px left + 5px right padding */
        margin-left: 5px; 
        margin-right: 5px;
        padding: 1rem 10px; /* Adjust internal padding to be consistent and avoid breaking layout */
        border-radius: 16px;
        height: auto; 
        min-height: 60vh; 
        box-sizing: border-box; /* Include padding in the width calculation */
    }
    /* Adjust input and results panels within the tighter card padding */
    .input-panel, .results-panel {
        padding: var(--space-md) var(--space-sm); /* Reduced internal padding for very small screens */
    }

    .section-title-within-tab { font-size: 1.3rem; margin-bottom: 1rem; }

    .upload-area {
        padding: 1rem;
        min-height: 150px;
    }
    .upload-area .drag-text {
        font-size: var(--fs-base);
    }
    .upload-area .or-text {
        font-size: var(--fs-xs);
    }
    .upload-area .btn-primary {
        font-size: var(--fs-xs);
        padding: 0.6rem 1rem;
    }
    .uploaded-file-info {
        font-size: var(--fs-xs);
        padding: 0.4rem 0.6rem;
    }
    .uploaded-file-info i {
        font-size: var(--fs-base);
    }
    .uploaded-file-info .clear-image-btn {
        font-size: var(--fs-xs);
    }

    .conversion-options {
        margin-top: var(--space-lg);
    }
    .conversion-options h3 {
        font-size: var(--fs-sm);
        margin-bottom: 0.8rem;
    }
    .form-group label {
        font-size: var(--fs-sm);
    }
    .form-control {
        font-size: var(--fs-sm);
        padding: 0.5rem 0.75rem;
    }
    .form-text {
        font-size: 0.7rem;
    }
    .form-actions {
        margin-top: 0.8rem;
    }
    .form-actions .btn {
        font-size: var(--fs-xs);
        padding: 0.5rem 0.8rem;
    }

    .image-preview-area {
        min-height: 180px;
        max-height: 200px;
    }
    .image-preview-area img, .image-preview-area canvas {
        max-height: 180px;
    }
    .image-preview-area .preview-placeholder-text {
        font-size: var(--fs-sm);
    }

    .download-section {
        padding-top: var(--space-lg);
    }
    .download-section .converted-file-info {
        font-size: var(--fs-xs);
    }
    .download-section .btn-primary {
        font-size: var(--fs-xs);
        padding: 0.6rem 1rem;
    }
    
    .info-section, .faq-section, .support-tool-cta {
        padding: 1.5rem; 
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
    }
    .info-section .column-title, .faq-section .column-title, .support-tool-cta h3 { font-size: var(--fs-sm); }
    .info-section p, .faq-section p, .support-tool-cta p { font-size: var(--fs-xs); }
    .how-to-list li { font-size: var(--fs-xs); }
    .support-tool-cta .tool-icon { font-size: 2.2rem; } 
    .support-tool-cta .coffee-btn-small { font-size: var(--fs-xs); }
}