/* ============================================
   JPEG XL Image Viewer - Modern Stylesheet
   Matching ConvertICO design system
   ============================================ */

/* CSS Variables */
:root {
    --primary: #8B5CF6;
    --primary-light: #DDD6FE;
    --primary-dark: #7C3AED;
    --accent: #FF6B6B;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --danger: #EF4444;
    --purple: #8B5CF6;
    --purple-light: #EDE9FE;
    --blue: #0EA5E9;
    --blue-light: #BAE6FD;
    
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
}

/* Base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, #f1f5f9 100%);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--bg) 0%, #1e293b 100%);
}

/* Container */
.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tool-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tool-icon-wrapper.jxl-theme {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.tool-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Main Tool Area */
.tool-main {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Upload Section */
.upload-section {
    padding: 3rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .upload-area {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(124, 58, 237, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .upload-area:hover,
[data-theme="dark"] .upload-area.dragover {
    background: linear-gradient(135deg, #2e1065 0%, #1e1b4b 100%);
}

.upload-area:hover::before,
.upload-area.dragover::before {
    opacity: 1;
}

.upload-content {
    position: relative;
    z-index: 1;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease;
}

.upload-area:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.upload-subtitle {
    color: var(--text-secondary);
    margin: 0 0 1rem;
    font-size: 1rem;
}

.upload-hint {
    display: inline-block;
    background: var(--bg);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

.file-types {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.file-type-badge {
    background: linear-gradient(135deg, var(--purple-light), #ddd6fe);
    color: var(--purple);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Browser Notice */
.browser-notice {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #fef3c7, #fef9c3);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: #92400e;
}

[data-theme="dark"] .browser-notice {
    background: linear-gradient(135deg, #422006, #451a03);
    color: #fcd34d;
}

.notice-icon {
    flex-shrink: 0;
    color: #d97706;
}

[data-theme="dark"] .notice-icon {
    color: #fbbf24;
}

.notice-content {
    line-height: 1.5;
}

.notice-content strong {
    color: #b45309;
}

[data-theme="dark"] .notice-content strong {
    color: #fcd34d;
}

/* Editor Section */
.editor-section {
    padding: 0;
    animation: fadeIn 0.4s ease;
}

/* File Info Bar */
.file-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border);
    align-items: center;
}

[data-theme="dark"] .file-info-bar {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.file-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.file-info-item svg {
    color: var(--primary);
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.file-info-item.format-badge span {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Toolbar */
.viewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

/* Toolbar Buttons */
.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

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

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

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.zoom-controls .toolbar-btn {
    border: none;
    width: 32px;
    height: 32px;
}

/* Viewer Content */
.viewer-content {
    display: flex;
    min-height: 450px;
    max-height: 65vh;
    position: relative;
    background: var(--bg);
}

.image-viewport {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    background: #1a1a1a;
}

.image-viewport.checkerboard {
    background-image: 
        linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #1f1f1f;
}

.image-container {
    transition: transform 0.1s ease-out;
    transform-origin: center;
}

.image-container img {
    display: block;
    max-width: none;
    user-select: none;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Background Pattern Toggle */
.bg-pattern-toggle {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.bg-pattern-toggle:hover,
.bg-pattern-toggle.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Info Panel */
.info-panel {
    width: 280px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}

.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.info-panel-header h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.info-panel-header h4 svg {
    color: var(--primary);
}

.close-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.close-panel:hover {
    background: var(--bg);
    color: var(--text);
}

.info-panel-content {
    padding: 1rem;
}

.info-group {
    margin-bottom: 1.5rem;
}

.info-group:last-child {
    margin-bottom: 0;
}

.info-group h5 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 2rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* Related Tools */
.related-tools {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    margin-top: 2rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.related-label {
    font-weight: 600;
    color: var(--text);
}

.related-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.related-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--purple-light);
}

.related-link svg {
    width: 16px;
    height: 16px;
}

/* Info Sections */
.info-sections {
    display: grid;
    gap: 2rem;
    margin-top: 3rem;
}

.info-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    color: var(--text);
    margin: 0 0 1.5rem;
}

.info-card h2 svg {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

/* Steps List */
.steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: step;
}

.steps-list li {
    position: relative;
    padding-left: 3.5rem;
    padding-bottom: 1.25rem;
    margin-left: 1rem;
    counter-increment: step;
}

.steps-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 0;
    top: 2rem;
    width: 2px;
    height: calc(100% - 1rem);
    background: var(--primary-light);
}

.steps-list li:last-child {
    padding-bottom: 0;
}

.steps-list li::before {
    content: counter(step);
    position: absolute;
    left: -1rem;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.feature-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.feature-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.feature-icon svg {
    width: 24px;
    height: 24px;
}

.feature-icon.blue { background: linear-gradient(135deg, var(--blue), #0284c7); }
.feature-icon.green { background: linear-gradient(135deg, var(--success), #059669); }
.feature-icon.purple { background: linear-gradient(135deg, var(--purple), #7C3AED); }
.feature-icon.orange { background: linear-gradient(135deg, var(--warning), #D97706); }

.feature-content h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.feature-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* About Card - Format Features */
.about-content p {
    margin: 0 0 1.25rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.format-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.format-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.feature-badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.feature-badge.compression {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
}

.feature-badge.lossless {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

.feature-badge.alpha {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.feature-badge.animation {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #9d174d;
}

.feature-badge.hdr {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #5b21b6;
}

.feature-badge.progressive {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #3730a3;
}

/* FAQ */
.faq-list {
    display: grid;
    gap: 0.75rem;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg);
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.faq-question:hover {
    background: var(--bg-elevated);
}

.faq-question svg {
    color: var(--primary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.faq-item.open .faq-question svg {
    transform: rotate(180deg);
}

.faq-answer {
    display: none;
    padding: 0 1.25rem 1rem;
    background: var(--bg-elevated);
}

.faq-item.open .faq-answer {
    display: block;
}

.faq-answer p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Responsive */
@media (max-width: 900px) {
    .viewer-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        justify-content: center;
    }
    
    .viewer-content {
        flex-direction: column;
        max-height: none;
    }
    
    .image-viewport {
        min-height: 350px;
    }
    
    .info-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 300px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }
    
    .upload-section {
        padding: 2rem 1.5rem;
    }
    
    .upload-area {
        padding: 3rem 1.5rem;
    }
    
    .file-info-bar {
        padding: 1rem;
        gap: 1rem;
        justify-content: center;
    }
    
    .viewer-toolbar {
        padding: 1rem;
    }
    
    .action-bar {
        flex-direction: column;
        padding: 1.5rem;
    }
    
    .btn-group {
        width: 100%;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .related-tools {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .related-links {
        width: 100%;
    }
    
    .related-link {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tool-title {
        font-size: 1.75rem;
    }
    
    .tool-title-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .file-info-bar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .zoom-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .feature-item {
        flex-direction: column;
    }
    
    .format-features {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Print Styles */
@media print {
    .upload-section,
    .viewer-toolbar,
    .action-bar,
    .info-panel,
    .info-sections,
    .related-tools {
        display: none !important;
    }
    
    .tool-main {
        box-shadow: none;
        border: none;
    }
    
    .image-viewport {
        background: white;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
