/* ============================================
=== RESIZE IMAGE - MODERN STYLES ===
============================================
*/

/* Modal Z-Index & Styling (Copied from compress-image.css) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100; /* Higher than header (50) */
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.3s ease;
    visibility: visible;
}
.modal-overlay.ct-hidden { /* Use .ct-hidden */
    opacity: 0;
    visibility: hidden;
}


/* Modal Content */
#tool-modal .modal-content {
    max-width: 90%;
    width: 1400px;
    padding: 0;
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(248,250,252,0.98));
    border: 1px solid rgba(107,70,255,0.08);
    box-shadow: 0 40px 100px rgba(11,23,50,0.15), 0 0 0 1px rgba(255,255,255,0.5) inset;
    overflow: hidden;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
}
body.dark #tool-modal .modal-content {
    background: linear-gradient(145deg, rgba(15,23,42,0.98), rgba(8,10,14,0.95));
    border: 1px solid rgba(139,92,246,0.12);
    box-shadow: 0 40px 100px rgba(0,0,0,0.8), 0 0 0 1px rgba(107,70,255,0.1) inset;
    color: var(--text-dark);
}

/* Modal Header */
#tool-modal .modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
body.dark #tool-modal .modal-header {
    border-bottom-color: var(--border-dark);
}
#tool-modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
}
#tool-modal .modal-close-btn {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
body.dark #tool-modal .modal-close-btn {
    background: var(--bg-dark);
    color: var(--text-dark);
    border-color: var(--border-dark);
}
#tool-modal .modal-close-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: rotate(90deg);
}

/* Modal Body */
#tool-modal .modal-body {
    display: grid;
    /* FIX 1: Change to 70/30 split */
    grid-template-columns: 7fr 3fr;
    overflow: hidden;
    flex-grow: 1;
}

/* Preview Section */
#tool-modal .preview-section {
    padding: 1.5rem;
    overflow-y: auto;
}
#tool-modal .preview-container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Options Container */
#tool-modal .options-container {
    padding: 1.5rem;
    border-left: 1px solid var(--border-light);
    background: rgba(0,0,0,0.01);
    overflow-y: auto;
}
body.dark #tool-modal .options-container {
    border-left-color: var(--border-dark);
    background: rgba(0,0,0,0.1);
}

/* Modal Footer */
#tool-modal .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background: rgba(255,255,255,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}
body.dark #tool-modal .modal-footer {
    border-top-color: var(--border-dark);
    background: rgba(15,23,42,0.5);
}
#tool-modal .status-text {
    flex-grow: 1;
    text-align: left;
    display: none;
}
/* Desktop footer buttons */
#tool-modal .btn-compress,
#tool-modal .download-options {
    flex-shrink: 0;
    flex-grow: 0;
    width: auto;
    min-width: 200px;
    padding: 0.75rem 1.5rem;
}
#tool-modal .download-options {
    display: flex;
    gap: 1rem;
}
#tool-modal .btn-download {
    width: 100%;
}


/* Preview Card (Copied from compress-image.css) */
.image-card {
    background: var(--card-light);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}
body.dark .image-card {
    background: var(--card-dark);
    border-color: var(--border-dark);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.image-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}
body.dark .image-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.image-card-header, .image-card-footer {
    padding: 0.5rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.image-card-header {
    background: var(--bg-light);
    flex-wrap: wrap; /* Allow wrapping if needed */
    gap: 0.25rem;
}
body.dark .image-card-header {
    background: var(--bg-dark);
}
.image-size {
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background: rgba(0,0,0,0.05);
}
body.dark .image-size {
    background: rgba(255,255,255,0.05);
}
.original-size { color: var(--text-secondary); }
.original-file-size { color: var(--text-secondary); }
.resized-size { color: #10b981; }

.image-preview {
    height: 150px;
    padding: 0.5rem;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    overflow: hidden;
}
body.dark .image-preview { background: var(--bg-dark); }
.preview-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.image-card-footer {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-align: center;
}
.image-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.download-single-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
    border-radius: 6px;
    background: var(--brand-primary);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.download-single-btn:hover {
    opacity: 0.8;
}
.download-placeholder {
    padding: 0.5rem 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 36px;
    border-top: 1px solid var(--border-light);
}
body.dark .download-placeholder {
    border-top-color: var(--border-dark);
}


/* === OPTIONS & TABS (RESIZE) === */
.option-tabs {
    display: flex;
    background-color: var(--bg-light);
    border-radius: 10px;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}
body.dark .option-tabs {
    background-color: var(--bg-dark);
    border-color: var(--border-dark);
}
.tab-btn {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    gap: 0.5rem;
}
.tab-btn:hover:not(.active) {
    color: var(--text-light);
}
body.dark .tab-btn:hover:not(.active) {
    color: var(--text-dark);
}
.tab-btn.active {
    background: var(--card-light);
    color: var(--brand-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}
body.dark .tab-btn.active {
    background: var(--card-dark);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeInTab 0.3s ease;
}
.tab-panel.active {
    display: block;
}
@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Option Groups */
.option-group { margin-bottom: 1.25rem; }
.option-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.option-group-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.option-group-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.option-group-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-primary);
}
.option-group-checkbox label {
    margin-bottom: 0;
    font-weight: 500;
}

.option-input,
.option-group input[type="number"],
.option-group select {
    width: 100%;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-light);
    color: var(--text-light);
    transition: all 0.2s ease;
}
body.dark .option-input,
body.dark .option-group input[type="number"],
body.dark .option-group select {
    background: var(--bg-dark);
    border-color: var(--border-dark);
    color: var(--text-dark);
}
.option-input:focus,
.option-group input[type="number"]:focus,
.option-group select:focus {
    outline: none;
    border-color: var(--brand-primary);
    background-color: var(--card-light);
}
body.dark .option-input:focus,
body.dark .option-group input[type="number"]:focus,
body.dark .option-group select:focus {
    background-color: var(--card-dark);
}

/* Adjustment Section */
.adjustment-section {
    border-top: 1px solid var(--border-light);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}
/* First section no border */
.options-container > .adjustment-section:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

body.dark .adjustment-section { border-top-color: var(--border-dark); }
.adjustment-section .section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Sliders */
.slider-group { display: flex; align-items: center; gap: 0.75rem; }
.slider-group input[type="range"] { flex: 1; }
.slider-value {
    display: inline-block;
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--brand-primary);
    font-size: 0.9rem;
}

/* Small Reset Button */
.btn-reset {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem 1rem; /* Smaller padding */
    font-size: 0.85rem;
}

/* Status Text */
.status-text {
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}
.status-text.success { color: #10b981; }
.status-text.error { color: #ef4444; }
.status-text .loader {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 1024px) {
    #tool-modal .modal-body {
        grid-template-columns: 1fr;
        max-height: 60vh;
    }
    #tool-modal .options-container {
        border-left: none;
        border-top: 1px solid var(--border-light);
    }
    body.dark #tool-modal .options-container {
        border-top-color: var(--border-dark);
    }
}
@media (max-width: 768px) {
    #tool-modal .modal-content {
        border-radius: 18px;
        max-height: calc(100vh - 40px);
        width: 100%;
    }
    #tool-modal .modal-header { padding: 1.25rem 1.5rem; }
    
    #tool-modal h2 {
        font-size: 1.15rem; 
    }
    #tool-modal .modal-body {
        max-height: calc(100vh - 200px);
    }
    #tool-modal .preview-container-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    /* FIX 3: Mobile Footer Buttons */
    #tool-modal .modal-footer {
        flex-direction: column;
        align-items: center;
    }
    #tool-modal .btn-compress,
    #tool-modal .download-options {
        flex-basis: auto;
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    #tool-modal .download-options {
        flex-direction: column;
    }
    #tool-modal .status-text {
        text-align: center;
        margin-bottom: 0.5rem;
        width: 100%;
        justify-content: center;
    }
}
@media (max-width: 480px) {
    #tool-modal .preview-container-grid {
        grid-template-columns: 1fr 1fr;
    }
}