:root {
    --primary-color: #4361ee;
    --primary-dark: #3a56d4;
    --secondary-color: #f8f9fa;
    --text-color: #333;
    --text-light: #6c757d;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f5f7ff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 3.5rem;
    background: linear-gradient(45deg, #4361ee, #3a0ca3);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
    font-weight: 700;
    letter-spacing: -1px;
    position: relative;
    display: inline-block;
}

header h1::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #4361ee, #3a0ca3);
    border-radius: 3px;
}

header p {
    color: var(--text-light);
    font-size: 1.3rem;
    margin: 0.3rem 0 0;
    font-weight: 400;
    letter-spacing: 0.5px;
}

header .subtitle {
    color: var(--text-light);
    font-size: 1rem;
    margin-top: 0.5rem;
    font-weight: 300;
    font-style: italic;
    opacity: 0.8;
}

.upload-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Make the drop zone more touch-friendly on mobile */
@media (max-width: 768px) {
    .drop-zone {
        padding: 2.5rem 1rem;
        min-height: 200px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .drop-zone i {
        font-size: 2.5rem;
    }
    
    .btn {
        padding: 0.9rem 1.8rem;
        font-size: 1.1rem;
        min-width: 180px;
    }
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background-color: rgba(67, 97, 238, 0.05);
}

.drop-zone i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.drop-zone h3 {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.drop-zone p {
    color: var(--text-light);
    margin: 0.5rem 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    margin-top: 1rem;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* Add touch feedback for buttons */
.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Make file input cover the entire drop zone on mobile */
#fileInput {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.btn i {
    margin-left: 0.5rem;
}

.btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-shuffle {
    background-color: #6c757d;
    padding: 0.5rem 1rem;
}

.btn-shuffle:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

.btn-shuffle:active {
    transform: translateY(0);
}

.btn-clear {
    background-color: var(--danger-color);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-clear:hover {
    background-color: #c82333;
}

.btn-download {
    background-color: var(--success-color);
    margin-top: 1.5rem;
}

.btn-download:hover {
    background-color: #218838;
}

.file-info {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 1rem;
}

.preview-container {
    margin-top: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-header h3 {
    font-weight: 500;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
    min-height: 100px;
}

.image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    background: white;
    border: 1px solid #e9ecef;
    cursor: move;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 6px;
    background-color: #f8f9fa;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-container:hover {
    transform: scale(1.02);
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.page-number {
    text-align: center;
    font-size: 0.85rem;
    color: #495057;
    font-weight: 500;
    margin: 0.25rem 0;
}

.file-name {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.25rem;
    margin-bottom: 0.5rem;
}

.move-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-direction: row;
}

/* Image preview modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Move controls */
.move-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-direction: row;
}

.move-btn {
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: #495057;
    padding: 0;
    font-weight: bold;
}

.move-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.move-btn:active {
    background: #dee2e6;
}

.move-left::before {
    content: '◀';
}

.move-right::before {
    content: '▶';
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-container:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    background: #c82333;
}

/* Drag and drop styles */
.image-item.dragging {
    opacity: 0.5;
    border: 2px dashed #4dabf7;
}

.image-item.drag-over {
    border: 2px solid #4dabf7;
    background-color: #e7f5ff;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-container {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-container.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
}

.page-number {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    pointer-events: none;
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.image-item:hover .remove-btn {
    opacity: 1;
}

.actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.progress-container {
    display: none;
    text-align: center;
    margin: 2rem 0;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress {
    height: 100%;
    width: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-light);
    font-size: 0.9rem;
}

.result-container {
    display: none;
    text-align: center;
    padding: 2rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-top: 2rem;
}

.success-message i {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.success-message h3 {
    margin-bottom: 0.5rem;
    color: var(--success-color);
}

.empty-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 2rem 0;
}

footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-container {
        padding: 1.5rem;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 480px) {
    .drop-zone {
        padding: 2rem 1rem;
    }
    
    .btn {
        width: 100%;
        padding: 0.75rem;
    }
    
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .preview-header h3 {
        margin-bottom: 0;
    }
    
    .btn-clear {
        align-self: flex-end;
    }
}
