/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --success-hover: #059669;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Purple-blue gradient background with shading */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #6b46c1, #4338ca, #3b82f6);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.4;
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 16px;
    height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Header */
.header {
    text-align: center;
    padding: 6px;
    color: white;
    flex-shrink: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* Main Content */
.main-content {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 15px;
    margin: 10px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    gap: 10px;
}

/* Upload Section */
.upload-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 400px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--bg-color);
    width: 100%;
    max-width: 500px;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f3f4f6;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 15px;
    color: var(--primary-color);
}

.upload-content h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.upload-content p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 0.9rem;
}

/* Resize Section - Two Column Layout */
.resize-section {
    display: grid;
    grid-template-columns: 1.4fr 320px;
    gap: 15px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Left Column */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding-right: 10px;
    min-height: 0;
}

.images-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

.left-column > * {
    flex-shrink: 0;
}

.left-column::-webkit-scrollbar {
    width: 6px;
}

.left-column::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.left-column::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.preview-box {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 12px;
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.preview-box h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    text-align: center;
    font-weight: 600;
}

.image-wrapper {
    flex: 1;
    overflow: hidden;
    border-radius: 6px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    min-height: 200px;
    max-height: 320px;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.file-info {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 4px;
    font-size: 0.95rem;
    margin-top: auto;
}

.file-size-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 6px;
}

.file-size-value {
    font-weight: 700;
    color: var(--text-primary);
}

.reduction-info {
    text-align: center;
    padding: 8px;
    background: #d1fae5;
    border-radius: 4px;
    border: 2px solid var(--success-color);
    margin-top: 8px;
}

.reduction-value {
    font-weight: 700;
    color: var(--success-color);
    font-size: 0.95rem;
}

/* Progress Bar */
.progress-container {
    margin-top: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    position: relative;
    z-index: 10;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 12px;
}

.progress-text {
    text-align: center;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Right Column */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 6px; /* less gap so buttons fit */
    overflow-y: auto;
    padding-left: 8px;
}

/* Smaller buttons so top three fit on screen */
.btn {
    padding: 0.4em 0.8em;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    min-height: 2.8rem;
    box-sizing: border-box;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1.5px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1.5px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1.5px);
    box-shadow: var(--shadow-lg);
}

/* Adjusted large and vertical buttons */
.btn-large,
.btn-vertical {
    padding: 0.6em 1em;
    font-size: 1rem;
    min-height: 3.4rem;
}

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* Control Groups */
.control-group {
    background: var(--bg-color);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.control-group h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 700;
}

/* Custom Size Input */
.custom-size {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.custom-size input {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
}

.custom-size input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.custom-size select {
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    background: white;
    cursor: pointer;
    min-width: 80px;
}

.custom-size select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.size-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: center;
}

/* Quality Control */
.control-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

/* Donation Group */
.donation-group {
    margin-top: auto;
}

.donation-buttons {
    display: flex;
    gap: 8px;
}

.btn-donate {
    flex: 1;
    background: #f59e0b;
    color: white;
    padding: 10px;
    font-size: 0.9rem;
}

.btn-donate:hover {
    background: #d97706;
    transform: translateY(-2px);
}

/* Ad Group */
.ad-group {
    margin-top: 0;
}

.ad-placeholder {
    text-align: center;
    padding: 20px;
    background: white;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
}

.ad-placeholder small {
    font-size: 0.8rem;
}

/* Footer */
.footer {
    flex-shrink: 0;
    padding: 6px;
    color: white;
    text-align: center;
}

.copyright {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .resize-section {
        grid-template-columns: 1fr 300px;
    }
}

@media (max-width: 1024px) {
    .resize-section {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .images-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .left-column {
        max-height: 500px;
    }
    
    .right-column {
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 5px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .resize-section {
        gap: 15px;
    }
    
    .left-column {
        max-height: 300px;
    }
    
    .preview-box {
        min-width: 250px;
    }
    
    .size-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .custom-size {
        flex-direction: column;
    }
    
    .custom-size input,
    .custom-size select {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 5px;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .resize-section {
        gap: 10px;
    }
    
    .left-column {
        max-height: 250px;
    }
    
    .preview-box {
        min-width: 200px;
        padding: 10px;
    }
    
    .image-wrapper {
        min-height: 150px;
    }
    
    .btn-vertical {
        padding: 14px 16px;
        font-size: 1rem;
    }
}

/* Prevent body scrolling */
html, body {
    height: 100%;
    overflow: hidden;
}

.container {
    height: 100vh;
}
/* Smaller button styles for fitting top buttons on the screen */
.btn {
    padding: 0.4em 0.8em;        /* Adjust padding for smaller size */
    font-size: 0.9rem;          /* Slightly smaller font size */
    min-height: 2.8rem;         /* Height to keep buttons at a compact size */
    border-radius: 4px;         /* Slightly smaller rounded corners */
    gap: 6px;                   /* Smaller gap between icon and text */
}

/* Optional: specifically target top buttons if they have a unique class (like 'top-btn') */
/* .top-btn {
    padding: 0.4em 0.8em;
    font-size: 0.9rem;
    min-height: 2.8rem;
} */
