przeadnalizuj poniższy kod pod kątem nie działającego buttonu. jest widoczny ale nie da się go kliknać: <!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Galeria Plik贸w Graficznych</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <nav class="navbar">
        <div class="nav-container">
            <h1 class="logo">馃摳 PhotoVault</h1>
            <ul class="nav-menu">
                <li><a href="#upload" class="nav-link active">Wrzu膰 pliki</a></li>
                <li><a href="#gallery" class="nav-link">Galeria</a></li>
            </ul>
        </div>
    </nav>

    <main>
        <!-- Sekcja uploadu -->
        <section id="upload" class="section active">
            <div class="upload-wrapper">
                <!-- Kontener g艂贸wny z dwoma kolumnami -->
                <div class="upload-columns">
                    <!-- Lewa kolumna - Upload -->
                    <div class="upload-container">
                        <h2>Prze艣lij pliki graficzne</h2>
                        <div class="dropzone" id="dropzone">
                            <div class="dropzone-content">
                                <svg class="upload-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                    <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                                    <polyline points="7 10 12 15 17 10"></polyline>
                                    <line x1="12" y1="15" x2="12" y2="3"></line>
                                </svg>
                                <p class="dropzone-text">Przeci膮gnij i upu艣膰 pliki tutaj</p>
                                <p class="dropzone-subtext">lub kliknij, aby wybra膰 pliki</p>
                                <p class="dropzone-info">Obs艂ugiwane formaty: TIFF + PNG (w parach)</p>
                                <input type="file" id="fileInput" multiple accept=".tiff,.tif,.png" hidden>
                            </div>
                        </div>

                        <div class="upload-progress" id="uploadProgress">
                            <div class="progress-header">
                                <h3>Post臋p przesy艂ania</h3>
                                <button class="btn-clear-status" id="clearStatusBtn" title="Wyczy艣膰 list臋">
                                    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <path d="M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2m3 0v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6h14zM10 11v6M14 11v6"/>
                                    </svg>
                                    <span>Wyczy艣膰</span>
                                </button>
                            </div>
                            <div class="progress-items" id="progressItems"></div>
                        </div>

                        <div class="upload-stats">
                            <div class="stat-item">
                                <span class="stat-label">艁膮cznie plik贸w:</span>
                                <span class="stat-value" id="totalFiles">0</span>
                            </div>
                            <div class="stat-item">
                                <span class="stat-label">Ca艂kowity rozmiar:</span>
                                <span class="stat-value" id="totalSize">0 MB</span>
                            </div>
                        </div>
                    </div>

                    <!-- Prawa kolumna - Wymagania -->
                    <div class="requirements-container">
                        <h2>Wymagania plik贸w</h2>
                        <div class="requirements-content">
                            <div class="requirement-item">
                                <div class="requirement-icon">
                                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
                                        <polyline points="14 2 14 8 20 8"/>
                                    </svg>
                                </div>
                                <div class="requirement-info">
                                    <h4>Format plik贸w</h4>
                                    <p>TIFF (produkcyjny) + PNG (podgl膮d)</p>
                                    <span class="requirement-detail">Pliki musz膮 by膰 w parach o tej samej nazwie</span>
                                </div>
                            </div>

                            <div class="requirement-item">
                                <div class="requirement-icon">
                                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <path d="M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"/>
                                    </svg>
                                </div>
                                <div class="requirement-info">
                                    <h4>Maksymalny rozmiar</h4>
                                    <p>Do 200 MB na plik</p>
                                    <span class="requirement-detail">Zalecane: TIFF < 200MB, PNG < 50MB</span>
                                </div>
                            </div>

                            <div class="requirement-item">
                                <div class="requirement-icon">
                                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
                                        <circle cx="8.5" cy="8.5" r="1.5"/>
                                        <polyline points="21 15 16 10 5 21"/>
                                    </svg>
                                </div>
                                <div class="requirement-info">
                                    <h4>Rozdzielczo艣膰</h4>
                                    <p>Minimalna: 1920x1080 px</p>
                                    <span class="requirement-detail">Zalecana: 300 DPI dla druku</span>
                                </div>
                            </div>

                            <div class="requirement-item">
                                <div class="requirement-icon">
                                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <path d="M12 2v20M17 5H9.5a3.5 3.5 0 100 7h5a3.5 3.5 0 110 7H6"/>
                                    </svg>
                                </div>
                                <div class="requirement-info">
                                    <h4>Ilo艣膰 plik贸w</h4>
                                    <p>Do 100 par jednocze艣nie</p>
                                    <span class="requirement-detail">艁膮cznie 200 plik贸w (100 TIFF + 100 PNG)</span>
                                </div>
                            </div>

                            <div class="requirement-item warning">
                                <div class="requirement-icon">
                                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
                                        <path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>
                                        <line x1="12" y1="9" x2="12" y2="13"/>
                                        <line x1="12" y1="17" x2="12.01" y2="17"/>
                                    </svg>
                                </div>
                                <div class="requirement-info">
                                    <h4>Wa偶ne</h4>
                                    <p>Nazwy plik贸w musz膮 by膰 identyczne</p>
                                    <span class="requirement-detail">Przyk艂ad: obraz1.tiff + obraz1.png</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Sekcja galerii -->
        <section id="gallery" class="section">
            <div class="gallery-container">
                <div class="gallery-header">
                    <h2>Galeria plik贸w</h2>
                    <div class="gallery-controls">
                        <input type="text" class="search-input" id="searchInput" placeholder="Szukaj plik贸w...">
                        <button class="btn btn-danger" id="clearAllBtn">Wyczy艣膰 galeri臋</button>
                    </div>
                </div>

                <div class="gallery-grid" id="galleryGrid">
                    <!-- Tutaj b臋d膮 wy艣wietlane obrazy -->
                </div>
            </div>
        </section>
    </main>

    <!-- Modal podgl膮du -->
    <div class="modal" id="previewModal">
        <div class="modal-content">
            <span class="modal-close">&times;</span>
            <img src="" alt="Podgl膮d" id="modalImage">
            <div class="modal-info">
                <h3 id="modalTitle"></h3>
                <p id="modalInfo"></p>
                <div class="modal-actions">
                    <button class="btn btn-primary" id="downloadTiffBtn">Pobierz TIFF</button>
                    <button class="btn btn-secondary" id="downloadPngBtn">Pobierz PNG</button>
                    <button class="btn btn-danger" id="deleteBtn">Usu艅</button>
                </div>
            </div>
        </div>
    </div>

    <script src="app.js"></script>
</body>
</html>

-----------------

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #ed64a6;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --dark-color: #1a202c;
    --gray-dark: #2d3748;
    --gray-medium: #718096;
    --gray-light: #e2e8f0;
    --light-color: #f7fafc;
    --white: #ffffff;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.05);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    --gradient-dark: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    background-attachment: fixed;
}

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

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Navbar */
.navbar {
    background: var(--white);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideIn 0.5s ease-out;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1rem;
}

.nav-link {
    text-decoration: none;
    color: var(--gray-dark);
    font-weight: 500;
    transition: var(--transition);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

.nav-link:hover::before,
.nav-link.active::before {
    opacity: 0.1;
}

.nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Sections */
.section {
    display: none;
    padding: 3rem 2rem;
    animation: fadeIn 0.5s ease-out;
}

.section.active {
    display: block;
}

/* Upload Wrapper and Columns */
.upload-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

.upload-columns {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
}

/* Upload Section */
.upload-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.upload-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.05) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

.upload-container h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dropzone {
    border: 3px dashed var(--gray-light);
    border-radius: var(--border-radius);
    padding: 5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: linear-gradient(145deg, #f7fafc 0%, #e2e8f0 100%);
    position: relative;
    overflow: hidden;
}

.dropzone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.dropzone:hover::before,
.dropzone.dragover::before {
    opacity: 0.05;
}

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

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 6px rgba(102, 126, 234, 0.3));
    animation: pulse 2s ease-in-out infinite;
}

.dropzone-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.dropzone-subtext {
    color: var(--gray-medium);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.dropzone-info {
    font-size: 0.9rem;
    color: var(--gray-medium);
    font-weight: 500;
}

/* Progress */
.upload-progress {
    margin-top: 3rem;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.upload-progress.active {
    display: block;
}

/* Progress Header with Clear Button */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.progress-header h3 {
    font-size: 1.25rem;
    color: var(--dark-color);
}

.btn-clear-status {
    background: var(--gradient-dark);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.btn-clear-status:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--gradient-dark);
    filter: brightness(1.1);
}

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

.btn-clear-status span {
    display: inline-block;
}

.progress-items {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.progress-items::-webkit-scrollbar {
    width: 8px;
}

.progress-items::-webkit-scrollbar-track {
    background: var(--gray-light);
    border-radius: 4px;
}

.progress-items::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.progress-item {
    background: linear-gradient(145deg, #f7fafc 0%, #ffffff 100%);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: fadeIn 0.3s ease-out;
}

.progress-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.progress-item-info {
    flex: 1;
}

.progress-item-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.progress-bar {
    height: 8px;
    background: var(--gray-light);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-item-status {
    font-size: 0.875rem;
    color: var(--gray-medium);
    margin-top: 0.5rem;
}

/* Stats */
.upload-stats {
    display: flex;
    gap: 2rem;
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 2px solid var(--gray-light);
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(145deg, #f7fafc 0%, #ffffff 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    display: block;
    color: var(--gray-medium);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 0.5rem;
}

/* Requirements Container */
.requirements-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.requirements-container h2 {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    background: var(--gradient-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.requirements-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.requirement-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: linear-gradient(145deg, #f7fafc 0%, #ffffff 100%);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    border: 2px solid transparent;
}

.requirement-item:hover {
    transform: translateX(4px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.requirement-item.warning {
    background: linear-gradient(145deg, #fff5f5 0%, #fed7d7 100%);
    border-color: var(--danger-color);
}

.requirement-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: 50%;
    padding: 0.75rem;
}

.requirement-item.warning .requirement-icon {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.requirement-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.requirement-info {
    flex: 1;
}

.requirement-info h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.25rem;
}

.requirement-info p {
    color: var(--gray-dark);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.requirement-detail {
    font-size: 0.875rem;
    color: var(--gray-medium);
    display: block;
    font-style: italic;
}

/* Gallery */
.gallery-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.gallery-header h2 {
    font-size: 2rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gallery-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-input {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    width: 300px;
    transition: var(--transition);
    background: var(--light-color);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.gallery-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    cursor: pointer;
    background: var(--white);
    animation: fadeIn 0.5s ease-out;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
    z-index: 1;
}

.gallery-item:hover::before {
    opacity: 0.1;
}

.gallery-item img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: var(--transition);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item-info {
    padding: 1.5rem;
    background: var(--white);
    position: relative;
    z-index: 2;
}

.gallery-item-name {
    font-weight: 700;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dark-color);
    font-size: 1.1rem;
}

.gallery-item-meta {
    font-size: 0.875rem;
    color: var(--gray-medium);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--gradient-dark);
    color: white;
    box-shadow: 0 4px 15px rgba(45, 55, 72, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(45, 55, 72, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 101, 101, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 101, 101, 0.4);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    margin: 2% auto;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    gap: 2rem;
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    color: var(--gray-medium);
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
    transform: rotate(90deg);
}

#modalImage {
    max-width: 70%;
    max-height: 90vh;
    object-fit: contain;
    background: var(--light-color);
}

.modal-info {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    background: linear-gradient(145deg, #ffffff 0%, #f7fafc 100%);
}

.modal-info h3 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-info p {
    line-height: 2;
    color: var(--gray-dark);
}

.modal-info strong {
    color: var(--dark-color);
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}

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

::-webkit-scrollbar-track {
    background: var(--gray-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 1200px) {
    .upload-columns {
        grid-template-columns: 1fr;
    }
    
    .requirements-container {
        position: static;
        margin-top: 2rem;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .progress-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .btn-clear-status {
        width: 100%;
        justify-content: center;
    }
    
    .requirement-item {
        flex-direction: column;
        text-align: center;
    }
    
    .requirement-icon {
        margin: 0 auto;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }
    
    .modal-content {
        flex-direction: column;
        margin: 0;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    #modalImage {
        max-width: 100%;
        max-height: 50vh;
    }
    
    .upload-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .btn-clear-status span {
        display: none;
    }
    
    .btn-clear-status {
        padding: 0.5rem;
    }
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-medium);
}

.empty-state svg {
    width: 120px;
    height: 120px;
    margin-bottom: 2rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--gray-dark);
}

.empty-state p {
    font-size: 1.1rem;
}

-----------------

// Inicjalizacja IndexedDB
let db;
const DB_NAME = 'PhotoVaultDB';
const DB_VERSION = 1;
const STORE_NAME = 'photos';

// Stan aplikacji
const state = {
    files: [],
    currentModal: null
};

// Inicjalizacja bazy danych
function initDB() {
    return new Promise((resolve, reject) => {
        const request = indexedDB.open(DB_NAME, DB_VERSION);
        
        request.onerror = () => reject(request.error);
        request.onsuccess = () => {
            db = request.result;
            resolve(db);
        };
        
        request.onupgradeneeded = (event) => {
            db = event.target.result;
            if (!db.objectStoreNames.contains(STORE_NAME)) {
                const store = db.createObjectStore(STORE_NAME, { keyPath: 'id', autoIncrement: true });
                store.createIndex('name', 'name', { unique: false });
                store.createIndex('timestamp', 'timestamp', { unique: false });
            }
        };
    });
}

// Elementy DOM
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('fileInput');
const uploadProgress = document.getElementById('uploadProgress');
const progressItems = document.getElementById('progressItems');
const totalFiles = document.getElementById('totalFiles');
const totalSize = document.getElementById('totalSize');
const galleryGrid = document.getElementById('galleryGrid');
const searchInput = document.getElementById('searchInput');
const clearAllBtn = document.getElementById('clearAllBtn');
const clearStatusBtn = document.getElementById('clearStatusBtn');
const previewModal = document.getElementById('previewModal');
const modalClose = document.querySelector('.modal-close');

// Nawigacja
document.querySelectorAll('.nav-link').forEach(link => {
    link.addEventListener('click', (e) => {
        e.preventDefault();
        const targetId = link.getAttribute('href').substring(1);
        
        document.querySelectorAll('.section').forEach(section => {
            section.classList.remove('active');
        });
        document.querySelectorAll('.nav-link').forEach(navLink => {
            navLink.classList.remove('active');
        });
        
        document.getElementById(targetId).classList.add('active');
        link.classList.add('active');
        
        if (targetId === 'gallery') {
            loadGallery();
        }
    });
});

// Upload funkcjonalność
dropzone.addEventListener('click', () => fileInput.click());
fileInput.addEventListener('change', handleFileSelect);

dropzone.addEventListener('dragover', (e) => {
    e.preventDefault();
    dropzone.classList.add('dragover');
});

dropzone.addEventListener('dragleave', () => {
    dropzone.classList.remove('dragover');
});

dropzone.addEventListener('drop', (e) => {
    e.preventDefault();
    dropzone.classList.remove('dragover');
    handleFiles(e.dataTransfer.files);
});

function handleFileSelect(e) {
    handleFiles(e.target.files);
}

async function handleFiles(files) {
    const fileArray = Array.from(files);
    const pairs = organizePairs(fileArray);
    
    if (pairs.length === 0) {
        alert('Proszę wybrać pliki w parach TIFF + PNG');
        return;
    }
    
    uploadProgress.classList.add('active');
    
    let totalProcessed = 0;
    let totalSizeProcessed = 0;
    
    for (const pair of pairs) {
        const progressItem = createProgressItem(pair.name);
        // Dodaj nowy element na początek listy (najnowsze na górze)
        progressItems.insertBefore(progressItem, progressItems.firstChild);
        
        try {
            await processPair(pair, progressItem);
            totalProcessed++;
            totalSizeProcessed += pair.tiff.size + pair.png.size;
            
            updateStats(totalProcessed, totalSizeProcessed);
            progressItem.querySelector('.progress-item-status').textContent = 'Zakończono';
            progressItem.querySelector('.progress-bar-fill').style.width = '100%';
        } catch (error) {
            console.error('Błąd przetwarzania:', error);
            progressItem.querySelector('.progress-item-status').textContent = 'Błąd';
            progressItem.querySelector('.progress-bar-fill').style.background = 'var(--danger-color)';
        }
    }
}

function organizePairs(files) {
    const pairs = [];
    const fileMap = new Map();
    
    // Grupowanie plików według nazwy (bez rozszerzenia)
    files.forEach(file => {
        const nameParts = file.name.split('.');
        const extension = nameParts.pop().toLowerCase();
        const baseName = nameParts.join('.');
        
        if (!fileMap.has(baseName)) {
            fileMap.set(baseName, {});
        }
        
        if (extension === 'tiff' || extension === 'tif') {
            fileMap.get(baseName).tiff = file;
        } else if (extension === 'png') {
            fileMap.get(baseName).png = file;
        }
    });
    
    // Tworzenie par
    fileMap.forEach((value, key) => {
        if (value.tiff && value.png) {
            pairs.push({
                name: key,
                tiff: value.tiff,
                png: value.png
            });
        }
    });
    
    return pairs;
}

function createProgressItem(name) {
    const item = document.createElement('div');
    item.className = 'progress-item';
    item.innerHTML = `
        <div class="progress-item-info">
            <div class="progress-item-name">${name}</div>
            <div class="progress-bar">
                <div class="progress-bar-fill" style="width: 0%"></div>
            </div>
            <div class="progress-item-status">Przetwarzanie...</div>
        </div>
    `;
    return item;
}

async function processPair(pair, progressItem) {
    const progressBar = progressItem.querySelector('.progress-bar-fill');
    
    // Symulacja postępu dla dużych plików
    let progress = 0;
    const progressInterval = setInterval(() => {
        progress += Math.random() * 20;
        if (progress > 90) progress = 90;
        progressBar.style.width = progress + '%';
    }, 100);
    
    // Odczyt plików
    const tiffData = await readFileAsArrayBuffer(pair.tiff);
    const pngData = await readFileAsDataURL(pair.png);
    
    // Zapisanie do IndexedDB
    const photoData = {
        name: pair.name,
        tiffData: tiffData,
        tiffSize: pair.tiff.size,
        pngData: pngData,
        pngSize: pair.png.size,
        timestamp: Date.now()
    };
    
    await saveToDatabase(photoData);
    
    clearInterval(progressInterval);
    progressBar.style.width = '100%';
}

function readFileAsArrayBuffer(file) {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = (e) => resolve(e.target.result);
        reader.onerror = reject;
        reader.readAsArrayBuffer(file);
    });
}

function readFileAsDataURL(file) {
    return new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = (e) => resolve(e.target.result);
        reader.onerror = reject;
        reader.readAsDataURL(file);
    });
}

async function saveToDatabase(data) {
    return new Promise((resolve, reject) => {
        const transaction = db.transaction([STORE_NAME], 'readwrite');
        const store = transaction.objectStore(STORE_NAME);
        const request = store.add(data);
        
        request.onsuccess = () => resolve(request.result);
        request.onerror = () => reject(request.error);
    });
}

function updateStats(files, size) {
    totalFiles.textContent = files;
    totalSize.textContent = (size / 1024 / 1024).toFixed(2) + ' MB';
}

// Czyszczenie listy statusów
clearStatusBtn.addEventListener('click', () => {
    if (confirm('Czy na pewno chcesz wyczyścić listę statusów?')) {
        progressItems.innerHTML = '';
        uploadProgress.classList.remove('active');
    }
});

// Galeria
async function loadGallery() {
    const photos = await getAllPhotos();
    displayGallery(photos);
}

async function getAllPhotos() {
    return new Promise((resolve, reject) => {
        const transaction = db.transaction([STORE_NAME], 'readonly');
        const store = transaction.objectStore(STORE_NAME);
        const request = store.getAll();
        
        request.onsuccess = () => resolve(request.result);
        request.onerror = () => reject(request.error);
    });
}

function displayGallery(photos) {
    galleryGrid.innerHTML = '';
    
    if (photos.length === 0) {
        galleryGrid.innerHTML = '<p style="grid-column: 1/-1; text-align: center; padding: 2rem;">Brak zdjęć w galerii</p>';
        return;
    }
    
    photos.forEach(photo => {
        const item = createGalleryItem(photo);
        galleryGrid.appendChild(item);
    });
}

function createGalleryItem(photo) {
    const item = document.createElement('div');
    item.className = 'gallery-item';
    
    const totalSize = (photo.tiffSize + photo.pngSize) / 1024 / 1024;
    const date = new Date(photo.timestamp).toLocaleDateString('pl-PL');
    
    item.innerHTML = `
        <img src="${photo.pngData}" alt="${photo.name}">
        <div class="gallery-item-info">
            <div class="gallery-item-name">${photo.name}</div>
            <div class="gallery-item-meta">${totalSize.toFixed(2)} MB • ${date}</div>
        </div>
    `;
    
    item.addEventListener('click', () => openModal(photo));
    
    return item;
}

// Modal
function openModal(photo) {
    state.currentModal = photo;
    
    document.getElementById('modalImage').src = photo.pngData;
    document.getElementById('modalTitle').textContent = photo.name;
    
    const totalSize = (photo.tiffSize + photo.pngSize) / 1024 / 1024;
    const date = new Date(photo.timestamp).toLocaleString('pl-PL');
    
    document.getElementById('modalInfo').innerHTML = `
        <strong>Rozmiar TIFF:</strong> ${(photo.tiffSize / 1024 / 1024).toFixed(2)} MB<br>
        <strong>Rozmiar PNG:</strong> ${(photo.pngSize / 1024 / 1024).toFixed(2)} MB<br>
        <strong>Data dodania:</strong> ${date}
    `;
    
    previewModal.style.display = 'block';
}

modalClose.addEventListener('click', () => {
    previewModal.style.display = 'none';
    state.currentModal = null;
});

window.addEventListener('click', (e) => {
    if (e.target === previewModal) {
        previewModal.style.display = 'none';
        state.currentModal = null;
    }
});

// Akcje modala
document.getElementById('downloadTiffBtn').addEventListener('click', () => {
    if (state.currentModal) {
        downloadFile(state.currentModal.tiffData, state.currentModal.name + '.tiff', 'image/tiff');
    }
});

document.getElementById('downloadPngBtn').addEventListener('click', () => {
    if (state.currentModal) {
        const link = document.createElement('a');
        link.href = state.currentModal.pngData;
        link.download = state.currentModal.name + '.png';
        link.click();
    }
});

document.getElementById('deleteBtn').addEventListener('click', async () => {
    if (state.currentModal && confirm('Czy na pewno chcesz usunąć ten plik?')) {
        await deletePhoto(state.currentModal.id);
        previewModal.style.display = 'none';
        loadGallery();
    }
});

function downloadFile(arrayBuffer, filename, mimeType) {
    const blob = new Blob([arrayBuffer], { type: mimeType });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = filename;
    link.click();
    URL.revokeObjectURL(url);
}

async function deletePhoto(id) {
    return new Promise((resolve, reject) => {
        const transaction = db.transaction([STORE_NAME], 'readwrite');
        const store = transaction.objectStore(STORE_NAME);
        const request = store.delete(id);
        
        request.onsuccess = () => resolve();
        request.onerror = () => reject(request.error);
    });
}

// Wyszukiwanie
searchInput.addEventListener('input', async (e) => {
    const searchTerm = e.target.value.toLowerCase();
    const photos = await getAllPhotos();
    const filtered = photos.filter(photo => 
        photo.name.toLowerCase().includes(searchTerm)
    );
    displayGallery(filtered);
});

// Czyszczenie galerii
clearAllBtn.addEventListener('click', async () => {
    if (confirm('Czy na pewno chcesz usunąć wszystkie zdjęcia?')) {
        await clearDatabase();
        loadGallery();
        updateStats(0, 0);
    }
});

async function clearDatabase() {
    return new Promise((resolve, reject) => {
        const transaction = db.transaction([STORE_NAME], 'readwrite');
        const store = transaction.objectStore(STORE_NAME);
        const request = store.clear();
        
        request.onsuccess = () => resolve();
        request.onerror = () => reject(request.error);
    });
}

// Inicjalizacja aplikacji
document.addEventListener('DOMContentLoaded', async () => {
    try {
        await initDB();
        console.log('Baza danych zainicjalizowana');
    } catch (error) {
        console.error('Błąd inicjalizacji bazy danych:', error);
        alert('Błąd inicjalizacji aplikacji. Sprawdź konsolę.');
    }
});