* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --secondary-color: #06B6D4;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section Title */
.section-title {
    margin: 30px 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.section-title h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.section-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--surface);
    margin-bottom: 30px;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.upload-area h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
}

/* Image Preview Container */
.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.image-item {
    position: relative;
    cursor: move;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.image-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.image-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(79, 70, 229, 0.5);
    z-index: 1000;
}

.image-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.image-item-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 5px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-item:hover .image-item-controls {
    opacity: 1;
}

/* Mobile: Always show controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .image-item-controls {
        opacity: 1;
    }
}

.image-item-controls button {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s ease;
}

.image-item-controls button:hover {
    background: #DC2626;
}

.image-item-info {
    padding: 8px;
    background: var(--surface);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Options */
.pdf-options,
.compress-options,
.batch-options,
.pdf-conversion-options {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid var(--border-color);
}

.pdf-options h3,
.compress-options > div:first-child,
.batch-options > div:first-child,
.pdf-conversion-options > div:first-child {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.option-group input[type="text"],
.option-group input[type="number"],
.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.option-group input[type="text"]:focus,
.option-group input[type="number"]:focus,
.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.option-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: background 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-dark);
}

#qualityValue {
    min-width: 40px;
    text-align: right;
    font-weight: 500;
    color: var(--primary-color);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
    width: auto;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.button-group input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background-color: #D1D5DB;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #DC2626;
}

/* Compress Preview */
.compress-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.compress-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.compress-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.compress-item img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.compress-item-info {
    padding: 12px;
    font-size: 0.85rem;
}

.compress-item-info p {
    margin: 4px 0;
    color: var(--text-secondary);
}

.compress-item-info .size-comparison {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.size-before,
.size-after {
    text-align: center;
}

.size-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

.size-value {
    font-weight: 600;
    color: var(--text-primary);
}

.size-after .size-value {
    color: var(--success-color);
}

/* Progress Bar */
.progress-bar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 400px;
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.progress-fill {
    width: 0%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 0.3s ease;
    margin-bottom: 10px;
}

#progressText {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
    border-left: 4px solid var(--primary-color);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 30px 20px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .nav-tabs {
        gap: 5px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .image-preview-container,
    .compress-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group input[type="text"],
    .btn {
        width: 100%;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 2.5rem;
    }

    .upload-area h3 {
        font-size: 1.1rem;
    }

    .slider-container {
        flex-direction: column;
        align-items: flex-start;
    }

    #qualityValue {
        text-align: left;
    }

    .progress-bar {
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-width: 100%;
    }

    .toast {
        left: 10px;
        right: 10px;
        max-width: 100%;
    }

    .radio-group {
        flex-direction: column;
        gap: 10px;
    }

    /* Mobile Touch Improvements */
    .image-item {
        touch-action: none;
        user-select: none;
    }
    
    .image-item.dragging {
        opacity: 0.7;
        transform: scale(1.05);
        box-shadow: var(--shadow-lg), 0 0 25px rgba(79, 70, 229, 0.6);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .section-title h2 {
        font-size: 1.2rem;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .image-preview-container,
    .compress-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.opacity-50 {
    opacity: 0.5;
}

/* Disable text selection during drag */
.image-preview-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
