/* General Body and Container Styling */
body {
    background-color: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
    background-color: #f0f2f5;
}

.centered-container {
    text-align: center;
}

.centered-heading {
    color: #1a237e;
    margin-bottom: 20px;
    font-size: 2.5rem;
}

.centered-text {
    color: #555;
    margin-bottom: 20px;
}

/* Flashed Messages */
.flashes {
    list-style: none;
    padding: 15px;
    margin: 20px auto;
    width: fit-content;
    font-weight: bold;
}
.flashes li {
    padding: 0;
    margin: 0;
}
.flashes.centered-flashes {
    text-align: center;
}
.error {
    background-color: #f8d7da;
    color: #721c24;
}
.success {
    background-color: #d4edda;
    color: #155724;
}
.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Custom File Input */
.custom-file-input {
    display: inline-block;
    padding: 12px 24px;
    cursor: pointer;
    background-color: #1a237e;
    color: #fff;
    transition: background-color 0.3s;
    font-weight: bold;
    font-size: 1rem;
    border-radius: 8px; /* Apply rounded corners here */
}

.custom-file-input:hover {
    background-color: #0d1248;
}

#pdf_file {
    display: none;
}

/* Preview Grid and Cards */
.controls-section {
    margin-top: 30px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    padding: 20px 0;
    justify-items: center;
    background-color: #f0f2f5;
}

.preview-card {
    position: relative;
    width: 150px;
    height: 200px;
    overflow: hidden;
    cursor: grab;
    background-color: #fff;
}

.preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s;
}

.preview-card:hover .card-overlay {
    opacity: 1;
}

.page-number {
    font-size: 1rem;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
}

.delete-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.delete-btn:hover {
    color: #ff4d4f;
}

.ghost-card {
    opacity: 0.4;
    background-color: #f0f0f0;
}

/* Add Pages Section */
.add-pages-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f0f2f5;
}

.add-pages-section h3 {
    margin-top: 0;
    color: #333;
}

.add-pages-section label,
.add-pages-section input {
    margin: 0 10px;
}

#insert-position {
    width: 60px;
    padding: 8px;
    text-align: center;
}

/* Action Buttons */
.action-buttons {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.submit-btn,
.download-button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    border-radius: 8px; /* Apply rounded corners here */
}

.submit-btn {
    background-color: #1e88e5;
    color: #fff;
}

.submit-btn:hover {
    background-color: #1976d2;
}

.download-button {
    background-color: #4CAF50;
    color: #fff;
    text-decoration: none;
    display: inline-block;
}

.download-button:hover {
    background-color: #45a049;
}

/* Download Section */
.download-section {
    margin-top: 40px;
    padding: 30px;
    background-color: #f0f2f5;
}

/* ---------------------------------- */
/* Responsive Design for Small Screens */
/* ---------------------------------- */
@media (max-width: 768px) {
    /* Main container adjustments */
    .container {
        margin: 20px 10px;
        padding: 15px;
    }

    .centered-heading {
        font-size: 2rem;
    }

    /* Adjust preview grid for smaller screens */
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
        padding: 15px;
    }

    .preview-card {
        width: 120px;
        height: 160px;
    }

    .page-number {
        font-size: 0.9rem;
    }

    /* Stack buttons vertically */
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .submit-btn,
    .download-button {
        width: 100%;
        padding: 10px;
    }

    /* Adjustments for add pages section */
    .add-pages-section {
        padding: 15px;
    }
    
    .add-pages-section h3 {
        font-size: 1.2rem;
    }

    /* Align elements in add pages section */
    .add-pages-section label,
    .add-pages-section input {
        display: block;
        margin: 10px 0;
    }
}