/* ==========================================================================
   Image Compressor - Tool-specific styles
   Extends the Atelier Design System for compression-specific features
   ========================================================================== */

/* === REQUIRED BODY BACKGROUND === */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #0a0a0a;
    color: #e5e7eb;
    line-height: 1.6;
    min-height: 100vh;
}

/* ---------- Hero Features ---------- */
.hero-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.hero-features span {
    font-size: 14px;
    color: var(--success);
    font-weight: 500;
}

/* ---------- Compression Controls ---------- */
.compression-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.compression-controls label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#qualityValue {
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 40px;
    text-align: right;
}

/* Quality Presets */
.quality-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.preset-quality-btn {
    padding: 8px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.preset-quality-btn:hover {
    background-color: var(--border-default);
    color: var(--text-primary);
}

.preset-quality-btn.active {
    background-color: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Format Selector */
.format-selector {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 15px;
    color: var(--text-secondary);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.radio-label:hover {
    background-color: var(--bg-tertiary);
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

/* ---------- Compression Stats ---------- */
.compression-stats {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
    flex-wrap: wrap;
    margin-top: var(--space-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-savings .stat-value {
    color: var(--success);
}

/* ---------- Preview Area ---------- */
.preview-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 300px;
    position: relative;
}

/* Ensure hidden attribute works */
[hidden] {
    display: none !important;
}

.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-2xl);
    color: var(--text-muted);
    text-align: center;
    min-height: 300px;
}

.preview-empty[hidden] {
    display: none !important;
}

.preview-icon {
    opacity: 0.3;
}

.preview-empty p {
    font-size: 15px;
    color: var(--text-disabled);
}

/* Image Comparison */
.image-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 300px;
}

.comparison-item {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
}

.comparison-item:first-child {
    border-right: 1px solid var(--border-default);
}

.comparison-item h4 {
    padding: var(--space-md);
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-item img {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

.image-details {
    padding: var(--space-sm) var(--space-md);
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.image-details span {
    white-space: nowrap;
}

/* ---------- Pro Features ---------- */
.pro-features {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border-default);
}

.pro-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.pro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
}

.pro-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.pro-badge {
    background: var(--pro-gradient);
    color: var(--pro-text);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pro-badge-inline {
    background: var(--pro-gradient);
    color: var(--pro-text);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: var(--space-xs);
}

.pro-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    padding: var(--space-lg);
}

.pro-locked {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.pro-locked:hover {
    opacity: 0.8;
}

/* Unlock styles for Pro users */
body.is-pro .pro-locked {
    opacity: 1;
    cursor: pointer;
}

/* ---------- Loading States ---------- */
.button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.processing .button-text {
    display: none;
}

.processing .button-spinner {
    display: block;
}

/* ---------- Upload Zone Styles ---------- */
.file-upload-zone {
    background-color: var(--bg-secondary);
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.file-upload-zone:hover,
.file-upload-zone:focus {
    border-color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.file-upload-zone.drag-over {
    border-color: var(--accent-primary);
    background-color: var(--accent-ring);
    transform: scale(1.02);
}

.upload-icon {
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    opacity: 0.7;
}

.upload-primary {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.upload-secondary {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

/* ---------- Responsive Design ---------- */
@media (max-width: 768px) {
    .image-comparison {
        grid-template-columns: 1fr;
    }
    
    .comparison-item:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border-default);
    }
    
    .compression-stats {
        justify-content: center;
        gap: var(--space-md);
    }
    
    .quality-presets {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pro-feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero-features {
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }
    
    .quality-presets {
        grid-template-columns: 1fr;
    }
    
    .compression-stats {
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }
}

/* ---------- Enhanced Pro Features ---------- */

/* Pro Feature Groups */
.pro-feature-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-default);
}

.pro-feature-group:last-child {
    border-bottom: none;
}

.pro-feature-group h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-default);
    padding-bottom: var(--space-sm);
}

/* Advanced Settings */
.advanced-settings {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
}

.setting-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.setting-row select {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    min-width: 150px;
    cursor: pointer;
}

/* Batch Processing Results */
.batch-results {
    margin-top: var(--space-xl);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    flex-wrap: wrap;
}

.batch-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.batch-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.batch-progress {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-default);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

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

.progress-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.batch-progress.complete .progress-text {
    color: var(--success);
    font-weight: 600;
}

.batch-list {
    max-height: 300px;
    overflow-y: auto;
}

.batch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-default);
    transition: background-color var(--transition-fast);
}

.batch-item:last-child {
    border-bottom: none;
}

.batch-item:hover {
    background-color: var(--bg-tertiary);
}

.batch-item.error {
    background-color: rgba(239, 68, 68, 0.05);
    border-left: 4px solid var(--error);
}

.batch-item-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex: 1;
}

.batch-filename {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.batch-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.batch-error {
    font-size: 13px;
    color: var(--error);
    font-weight: 500;
}

.batch-item-download {
    background-color: var(--accent-primary);
    color: var(--text-on-accent);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.batch-item-download:hover {
    background-color: var(--accent-secondary);
}

.batch-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-lg);
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-default);
    flex-wrap: wrap;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-lg);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-default);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-default);
    background-color: var(--bg-secondary);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-lg);
    border-top: 1px solid var(--border-default);
    background-color: var(--bg-secondary);
}

/* Watermark Settings */
.watermark-settings {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.setting-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.radio-group {
    display: flex;
    gap: var(--space-lg);
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
    font-weight: normal;
}

.setting-group input[type="text"],
.setting-group input[type="file"],
.setting-group select {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.setting-group input[type="text"]:focus,
.setting-group input[type="file"]:focus,
.setting-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
}

/* Analytics Dashboard */
.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background-color: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    text-align: center;
    transition: transform var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h4 {
    margin: 0 0 var(--space-sm) 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
}

.analytics-chart {
    background-color: var(--bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 16px;
}

.analytics-recommendations {
    background-color: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.analytics-recommendations h4 {
    margin: 0 0 var(--space-md) 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.analytics-recommendations ul {
    margin: 0;
    padding-left: var(--space-lg);
    list-style-type: disc;
}

.analytics-recommendations li {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.analytics-recommendations li:last-child {
    margin-bottom: 0;
}

/* Enhanced Pro status */
body.is-pro .pro-feature {
    opacity: 1;
    cursor: pointer;
}

/* Responsive Enhancements for Pro Features */
@media (max-width: 768px) {
    .batch-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .batch-stats {
        justify-content: center;
    }
    
    .batch-actions {
        justify-content: center;
    }
    
    .analytics-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        margin: var(--space-md);
    }
    
    .modal-large {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .setting-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }
    
    .batch-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }
    
    .batch-item-download {
        align-self: flex-end;
    }
    
    .analytics-summary {
        grid-template-columns: 1fr;
    }
    
    .radio-group {
        flex-direction: column;
        gap: var(--space-sm);
    }
}