:root {
    /* Light theme colors */
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #495057;
    --border-color: #dee2e6;
    --drop-zone-bg: #f1f3f5;
    --success-color: #2b8a3e;
    --error-color: #c92a2a;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dark-theme {
    /* Dark theme colors */
    --primary-color: #5a7dff;
    --primary-hover: #4a6cef;
    --background: #121212;
    --surface: #1e1e1e;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #343a40;
    --drop-zone-bg: #2b2b2b;
    --success-color: #40c057;
    --error-color: #ff6b6b;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-display: swap;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
}

h1 span {
    color: var(--primary-color);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.theme-toggle button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 50%;
    width: 2.8rem;
    height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.dark-theme .theme-toggle button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.moon {
    display: none;
}

.dark-theme .sun {
    display: none;
}

.dark-theme .moon {
    display: inline;
}

.upload-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .upload-container {
        flex-direction: row;
    }
    
    .settings-panel {
        flex: 0 0 300px;
    }
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background-color: var(--drop-zone-bg);
    cursor: pointer;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.drop-zone:hover {
    border-color: var(--primary-color);
}

.drop-zone.active {
    border-color: var(--primary-color);
    background-color: rgba(67, 97, 238, 0.1);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    fill: var(--primary-color);
}

.file-types {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.or {
    color: var(--text-secondary);
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.browse-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.browse-btn:hover {
    background-color: var(--primary-hover);
}

#file-input {
    display: none;
}

.settings-panel {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 500;
    color: var(--text-primary);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

select {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1rem;
    width: 100%;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.primary-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.results-container {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.results-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .results-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.summary {
    display: flex;
    gap: 1.5rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-item.highlight {
    color: var(--success-color);
    font-weight: 600;
}

.label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.image-card {
    background-color: var(--background);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.image-preview {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.image-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.image-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.image-savings {
    color: var(--success-color);
    font-weight: 600;
}

.download-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
    width: 100%;
}

.download-btn:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

.hidden {
    display: none !important;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    will-change: opacity;
}

.loading-content {
    background-color: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-container {
    margin-top: 1.5rem;
    background-color: var(--border-color);
    height: 8px;
    border-radius: 4px;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s;
}

#progress-text {
    position: absolute;
    right: 0;
    top: -25px;
    font-size: 0.9rem;
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer .disclaimer {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

.seo-content {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media print {
    .app-container {
        padding: 0;
    }
    
    .drop-zone, .theme-toggle, .compress-btn, .download-btn {
        display: none !important;
    }
    
    .results-container {
        box-shadow: none;
        padding: 0;
    }
    
    body, .dark-theme {
        background: white !important;
        color: black !important;
    }
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

main {
    display: block;
}