/* RAW File Viewer - CSS */
/* CSS Variables - Light Mode */
:root {
    --transition-speed: 0.25s;
    
    /* Primary Colors */
    --primary: #3b82f6;
    --primary-light: #dbeafe;
    --primary-dark: #2563eb;
    --accent: #60a5fa;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --danger: #EF4444;
    --purple: #8B5CF6;
    --purple-light: #EDE9FE;
    --teal: #14B8A6;
    --orange: #F97316;
    
    /* Background Colors */
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    
    /* Text Colors */
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadows */
    --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);
    --shadow-primary: 0 4px 14px rgba(59, 130, 246, 0.35);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Checker pattern */
    --checker-color: #e5e7eb;
    
    /* Error */
    --error-bg: #fef2f2;
    --error-border: #fecaca;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-light: rgba(96, 165, 250, 0.15);
    --primary-dark: #3b82f6;
    --accent: #93c5fd;
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --danger: #f87171;
    --purple: #a78bfa;
    --purple-light: rgba(167, 139, 250, 0.15);
    --teal: #2dd4bf;
    
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: #334155;
    --border-light: #475569;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5);
    --shadow-primary: 0 4px 14px rgba(96, 165, 250, 0.25);
    
    --checker-color: #374151;
    
    --error-bg: rgba(239, 68, 68, 0.15);
    --error-border: rgba(248, 113, 113, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* 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: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
    transition: background-color var(--transition-speed);
}

.tool-icon-wrapper svg {
    width: 28px;
    height: 28px;
}

.tool-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin: 0;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 800px;
    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);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* 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: var(--bg-secondary);
    position: relative;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(96, 165, 250, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.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;
}

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

.file-type-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.upload-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-elevated);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    border: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Progress */
.progress-container {
    margin-top: 1.5rem;
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Error */
.error-display {
    margin-top: 1.5rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--danger);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
}

/* Viewer Section */
.viewer-section {
    padding: 0;
}

/* File Header */
.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-info svg {
    color: var(--primary);
}

.file-name {
    font-weight: 600;
    color: var(--text);
}

.file-badge {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: background-color var(--transition-speed);
}

.file-badge.format {
    background: var(--primary-light);
    color: var(--primary);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

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

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

/* Preview Section */
.preview-section {
    padding: 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.preview-wrapper {
    max-width: 500px;
    max-height: 400px;
    margin: 0 auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: repeating-conic-gradient(var(--checker-color) 0% 25%, transparent 0% 50%) 
                50% / 20px 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.preview-wrapper img {
    max-width: 100%;
    max-height: 400px;
    display: block;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    text-align: center;
}

.preview-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-placeholder p {
    margin: 0;
}

.no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.no-preview svg {
    opacity: 0.5;
}

.no-preview p {
    margin: 0;
    font-weight: 500;
}

.no-preview span {
    font-size: 0.85rem;
    color: var(--success);
}

/* Quick Info */
.quick-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.quick-info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quick-info-item > svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.quick-info-content {
    display: flex;
    flex-direction: column;
}

.quick-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quick-value {
    font-weight: 600;
    color: var(--text);
}

/* Tabs */
.tabs-container {
    background: var(--bg-elevated);
    transition: background-color var(--transition-speed);
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    gap: 0.5rem;
    overflow-x: auto;
    transition: border-color var(--transition-speed);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.tab-btn.active::after {
    transform: scaleX(1);
}

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

/* Tab Content */
.tabs-content {
    min-height: 300px;
}

.tab-content {
    display: none;
    padding: 2rem;
}

.tab-content.active {
    display: block;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.info-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: background-color var(--transition-speed);
}

.info-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary);
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.info-section h4 svg {
    width: 16px;
    height: 16px;
}

.info-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    color: var(--text);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

/* EXIF Table */
.exif-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.exif-table {
    width: 100%;
    border-collapse: collapse;
}

.exif-table th,
.exif-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.exif-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text);
    position: sticky;
    top: 0;
}

.exif-table td:first-child {
    color: var(--text-muted);
    width: 40%;
}

.exif-table td:last-child {
    color: var(--text);
    word-break: break-word;
}

.exif-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Hex Viewer */
.hex-viewer {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

.hex-header {
    display: grid;
    grid-template-columns: 80px 1fr 150px;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.hex-content {
    max-height: 400px;
    overflow-y: auto;
}

.hex-row {
    display: grid;
    grid-template-columns: 80px 1fr 150px;
    gap: 1rem;
    padding: 0.25rem 1rem;
    transition: background-color 0.1s ease;
}

.hex-row:hover {
    background: var(--bg-secondary);
}

.hex-offset {
    color: var(--primary);
}

.hex-bytes {
    color: var(--text);
    letter-spacing: 0.05em;
}

.hex-ascii {
    color: var(--text-muted);
}

.hex-more {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Structure Analysis */
.structure-analysis {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.structure-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    transition: background-color var(--transition-speed);
}

.structure-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.structure-header svg {
    width: 16px;
    height: 16px;
}

.structure-value {
    color: var(--text);
}

.structure-markers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.marker-row {
    display: flex;
    gap: 1rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
}

.marker-offset {
    color: var(--primary);
    font-weight: 500;
}

.marker-name {
    color: var(--text);
}

/* Export Actions */
.export-actions {
    display: flex;
    gap: 1rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    justify-content: flex-end;
    flex-wrap: wrap;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

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

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

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

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

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

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

.related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.related-label svg {
    color: var(--primary);
}

.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-secondary);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.related-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.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);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.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;
}

.info-intro {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

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

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

.feature-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
    transition: background-color var(--transition-speed);
}

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

.feature-content h4 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    color: var(--text);
}

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

/* Formats Grid */
.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.format-group {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    transition: background-color var(--transition-speed);
}

.format-group h4 {
    margin: 0 0 0.5rem;
    color: var(--primary);
    font-size: 0.95rem;
}

.format-group span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

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

.faq-question {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    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);
}

.faq-question svg {
    color: var(--primary);
    transition: transform 0.3s ease;
    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);
    transition: background-color var(--transition-speed);
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }
    
    .upload-section {
        padding: 2rem 1.5rem;
    }
    
    .upload-area {
        padding: 2.5rem 1.5rem;
    }
    
    .file-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .preview-section,
    .tab-content {
        padding: 1.5rem;
    }
    
    .quick-info {
        grid-template-columns: repeat(2, 1fr);
        padding: 1.5rem;
    }
    
    .export-actions {
        flex-direction: column;
        padding: 1.5rem;
    }
    
    .btn {
        width: 100%;
    }
    
    .related-tools {
        flex-direction: column;
        text-align: center;
    }
    
    .related-links {
        justify-content: center;
    }
    
    .hex-header,
    .hex-row {
        grid-template-columns: 60px 1fr;
    }
    
    .hex-ascii {
        display: none;
    }
}

@media (max-width: 480px) {
    .quick-info {
        grid-template-columns: 1fr;
    }
    
    .file-info {
        flex-wrap: wrap;
    }
    
    .tabs-header {
        padding: 0;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .tab-btn span {
        display: none;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

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