:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fda5028f;
    min-height: 100vh;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.display-4 {
    font-weight: 300;
}

.upload-area {
    border: 3px dashed #dee2e6;
    border-radius: 15px;
    padding: 3rem 2rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: var(--success-color);
    background: #e8f5e8;
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    transition: all 0.3s ease;
    cursor: move;
    position: relative;
}

.file-item:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-item:last-child {
    border-bottom: none;
}

.file-item.sortable-ghost {
    opacity: 0.4;
    background-color: #e3f2fd;
}

.file-item.sortable-chosen {
    background-color: #e3f2fd;
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.file-item.sortable-drag {
    background-color: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transform: rotate(2deg);
    z-index: 1000;
}

.file-drag-handle {
    color: var(--secondary-color);
    margin-right: 0.5rem;
    cursor: move;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.file-item:hover .file-drag-handle {
    opacity: 1;
    color: var(--primary-color);
}

.file-order-number {
    position: absolute;
    top: 5px;
    left: 5px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-item:hover .file-order-number {
    opacity: 1;
}

.file-icon {
    font-size: 2rem;
    color: #dc3545;
    margin-right: 1rem;
    min-width: 40px;
}

.file-info {
    flex-grow: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.file-size {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
}

.file-pages-info {
    color: var(--primary-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.drag-handle {
    cursor: move;
    color: var(--secondary-color);
    margin-right: 0.5rem;
}

.drag-handle:hover {
    color: var(--primary-color);
}

.feature-card {
    padding: 2rem 1rem;
    height: 100%;
}

.feature-icon {
    font-size: 3rem;
}

.progress {
    height: 1rem;
    border-radius: 0.5rem;
}

.card {
    border-radius: 15px;
    overflow: hidden;
}

.card-header {
    border-bottom: 1px solid #dee2e6;
}

.btn {
    border-radius: 25px;
    padding: 0.75rem 2rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-lg {
    padding: 1rem 2.5rem;
}

.page-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.page-preview-item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.page-preview-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.page-preview-item.selected {
    border-color: var(--success-color);
    background-color: #e8f5e8;
}

.page-preview-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-number {
    margin-top: 8px;
    font-weight: 500;
    color: var(--dark-color);
}

.page-preview-item.selected .page-number {
    color: var(--success-color);
}

.selected-pages-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 120px;
    padding: 20px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    position: relative;
}

.selected-pages-preview.drag-active {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.selected-page-item {
    position: relative;
    border: 2px solid var(--success-color);
    border-radius: 8px;
    padding: 8px;
    background: white;
    text-align: center;
    min-width: 120px;
    cursor: move;
    transition: all 0.3s ease;
}

.selected-page-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.selected-page-item.sortable-ghost {
    opacity: 0.4;
    transform: rotate(5deg);
}

.selected-page-item.sortable-chosen {
    background-color: #e3f2fd;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.selected-page-item.sortable-drag {
    background-color: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transform: rotate(3deg);
    z-index: 1000;
}

.page-order-number {
    position: absolute;
    top: -8px;
    left: -8px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.drag-handle-selected {
    position: absolute;
    top: 5px;
    right: 25px;
    color: var(--secondary-color);
    cursor: move;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.selected-page-item:hover .drag-handle-selected {
    opacity: 1;
}

.reorder-instructions {
    background: #e3f2fd;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.drop-zone-indicator {
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin: 0 5px;
}

.drop-zone-indicator.active {
    opacity: 1;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.selected-page-canvas {
    max-width: 100px;
    height: auto;
    border-radius: 4px;
}

.selected-page-info {
    font-size: 0.75rem;
    margin-top: 5px;
    color: var(--dark-color);
}

.remove-selected-page {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-selection {
    width: 100%;
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
    padding: 40px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
}

.empty-selection i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.file-actions .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .page-order-number {
        top: -5px;
        left: -5px;
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }

    .drag-handle-selected {
        opacity: 1;
        position: relative;
        top: auto;
        right: auto;
        display: block;
        text-align: center;
        margin-bottom: 5px;
        background: var(--light-color);
        border: 1px solid #dee2e6;
    }

    .container {
        padding: 0 15px;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .file-drag-handle {
        position: absolute;
        top: 10px;
        right: 10px;
        opacity: 1;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .display-4 {
        font-size: 2rem;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .file-item {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .file-icon {
        font-size: 1.5rem;
        margin-right: 0.75rem;
    }

    .feature-card {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }

    .feature-icon {
        font-size: 2.5rem;
    }

    .page-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .selected-page-item {
        min-width: 100px;
        margin-bottom: 10px;
    }

    .selected-page-canvas {
        max-width: 80px;
    }

    .file-actions {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    .file-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-toolbar {
        justify-content: center;
        margin-top: 0.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card-header h5 {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    .upload-area {
        padding: 1.5rem 0.75rem;
    }

    .btn-lg {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .file-actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .file-actions .btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .page-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .modal-dialog {
        margin: 10px;
    }

    .selected-pages-preview {
        padding: 10px;
    }

    @media (pointer: coarse) {

        .file-item,
        .selected-page-item {
            padding: 12px;
            min-height: 60px;
        }

        .drag-handle-selected,
        .file-drag-handle {
            opacity: 1;
            font-size: 0.9rem;
            padding: 5px 8px;
        }
    }

    .selected-page-canvas {
        max-width: 100px;
        height: auto;
        border-radius: 4px;
        transition: transform 0.3s ease;
    }

    .selected-page-item:hover .selected-page-canvas {
        transform: scale(1.05);
    }

    /* Loading states */
    .sorting-indicator {
        display: inline-block;
        margin-left: 0.5rem;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sorting-indicator.active {
        opacity: 1;
    }

    /* Highlight sorted items */
    .file-item.sorted,
    .selected-page-item.sorted {
        animation: highlight 1s ease-out;
    }

    @keyframes highlight {
        0% {
            background-color: #fff3cd;
        }

        100% {
            background-color: transparent;
        }
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sortable-ghost {
    opacity: 0.5;
}

.sortable-chosen {
    background-color: #e3f2fd;
}

.file-list {
    max-height: 400px;
    overflow-y: auto;
}

.file-list.drag-active {
    background: #e3f2fd;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.file-item.newly-added,
.selected-page-item.newly-added {
    animation: slideIn 0.5s ease-out;
}

.btn-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.file-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}