body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

header {
    background-color: #0056b3;
    color: #fff;
    padding: 10px 0;
    text-align: center;
    border-bottom: 5px solid #004085;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.logo {
    max-height: 80px;
    margin-right: 20px;
}

header h1 {
    margin: 0;
    font-size: 2em;
}

h2 {
    color: #0056b3;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 30px;
}

form {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

/* Base style for all input and select elements in forms */
form input[type="text"],
form input[type="password"],
form input[type="file"],
form select {
    width: calc(100% - 22px); /* Account for padding and border */
    padding: 10px;
    margin-bottom: 15px; /* Keep consistent spacing for these elements in deposit/edit forms */
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Crucial for consistent sizing */
    height: 40px; /* Force consistent height for alignment */
}

/* Style for the "Déposer" button inside the upload form */
form button[name="upload"] { /* Targeted specifically for deposit button */
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

form button[name="upload"]:hover {
    background-color: #218838;
}

/* Style for the "Mettre à jour" button inside the edit form */
form button[name="update_document"] { /* Targeted specifically for update button */
    background-color: #007bff; /* Blue like other primary actions */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

form button[name="update_document"]:hover {
    background-color: #0056b3;
}


.message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #badbcc;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.document-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Style for the document title (filename) */
.document-title {
    margin-top: 0;
    background-color: #0056b3; /* Blue background */
    color: white; /* White text */
    padding: 10px;
    border-radius: 5px;
    word-break: break-word; /* Prevent long file names from overflowing */
    text-align: center;
}

.document-item p {
    margin: 5px 0;
    font-size: 0.9em;
}

/* Style for the current file display in edit mode */
.current-file-display {
    background-color: #0056b3; /* Blue background */
    color: white; /* White text */
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px; /* Keep consistent spacing */
    font-weight: bold;
}


.document-actions { /* New style to align action buttons */
    display: flex;
    justify-content: flex-end; /* Align to the right */
    gap: 10px; /* Space between buttons */
    margin-top: 15px;
}

/* Common button style (blue) */
.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    text-align: center;
    font-size: 16px;
    cursor: pointer;
    background-color: #007bff; /* Blue color */
    color: white;
    border: none;
}

.button:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

.view-button {
    /* Inherits from .button, can override if needed */
}

.edit-button {
    background-color: #ffc107; /* Yellowish for edit */
    color: #333;
    border: none;
}

.edit-button:hover {
    background-color: #e0a800;
}

/* Specific style for the delete button with icon */
.delete-icon-button {
    background-color: #dc3545;
    color: white;
    border: none; /* No border for icon */
    width: 40px; /* Fixed size for button */
    height: 40px; /* Fixed size for button */
    padding: 0; /* No internal padding for icon */
    display: flex; /* To center the icon */
    justify-content: center;
    align-items: center;
    font-size: 1.2em; /* Icon size */
    border-radius: 50%; /* For a round button if desired, or 4px for square */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Slight shadow for pop-out effect */
}

.delete-icon-button:hover {
    background-color: #c82333;
    transform: scale(1.05); /* Zoom effect on hover */
    transition: transform 0.2s ease-in-out;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end; /* Align elements on their baseline */
    margin-bottom: 20px; /* Add some space below the form */
}

.filter-group {
    flex: 1;
    min-width: 200px; /* Ensure a minimum width for wrapping */
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Align content to the bottom */
}

.filter-group label {
    margin-bottom: 5px; /* Space between label and input/select */
}

/* This is the key change for the input field within a filter-group */
.filter-group input[type="text"] {
    margin-bottom: 0; /* Remove default margin-bottom to align with SlimSelect */
    height: 40px; /* Ensure consistency */
    box-sizing: border-box; /* Crucial for sizing */
    width: 100%; /* Ensure it takes full width of its group */
}


/* Specific style for filter form buttons */
.filter-form .button {
    height: 40px; /* Force a height to align with fields */
    margin-top: 0; /* Remove any top margin */
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end; /* Align button to the bottom within the flex container */
}

.reset-filters {
    margin-left: 10px; /* Space between filter and reset buttons */
}

/* New styles for the resources header and sort form */
.resources-header {
    display: flex;
    justify-content: space-between; /* Space out the h2 and the sort form */
    align-items: flex-end; /* Align items to the bottom */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    margin-top: 30px;
    border-bottom: 2px solid #eee; /* Match h2 border */
    padding-bottom: 10px; /* Match h2 padding */
}

.resources-header h2 {
    margin: 0; /* Remove default margin for h2 in this context */
    border-bottom: none; /* Remove bottom border as it's on the parent div */
    padding-bottom: 0; /* Remove padding as it's on the parent div */
}

.sort-form {
    display: flex;
    align-items: flex-end; /* Align select and button to the bottom */
    gap: 15px;
    margin: 0; /* Remove default form margin */
    padding: 0; /* Remove default form padding */
    border: none; /* Remove default form border */
    background-color: transparent; /* Remove default form background */
}

.sort-form .filter-group { /* Use filter-group styles for alignment */
    flex: none; /* Do not let it grow */
    min-width: auto; /* Remove min-width to make it compact */
}

.sort-form .button.sort-button {
    height: 40px; /* Ensure button height matches select */
}


/* SlimSelect multi-selected */
.ss-multi-selected {
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    min-height: 40px !important; /* Fixed minimum height for SlimSelect multi-select */
    box-sizing: border-box; /* Include padding and border in the height */
    margin-bottom: 0 !important; /* This is crucial: removes SlimSelect's default bottom margin */
}

/* SlimSelect single selected (for the sort by dropdown) */
.ss-single-selected {
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    height: 40px !important; /* Fixed height for SlimSelect single select */
    box-sizing: border-box; /* Include padding and border in the height */
    display: flex;
    align-items: center;
    padding: 0 10px !important; /* Adjust padding for text alignment */
    margin-bottom: 0 !important; /* This is crucial: removes SlimSelect's default bottom margin */
}

.ss-single-selected .placeholder,
.ss-single-selected .ss-selected-label {
    line-height: 1; /* Ensure text does not overflow vertically */
}


.ss-single-selected, .ss-multi-selected {
    background-color: white !important;
}

.ss-content .ss-list .ss-option {
    padding: 8px 15px !important;
}

.ss-content .ss-list .ss-option.ss-highlighted {
    background-color: #f0f0f0 !important;
}

.ss-content .ss-list .ss-option.ss-option-selected {
    background-color: #e2eaf5 !important;
    color: #0056b3 !important;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-form, .sort-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-form .button, .sort-form .button {
        width: 100%;
        margin-top: 10px;
    }

    .logo {
        margin-bottom: 10px;
        margin-right: 0;
    }
    header {
        flex-direction: column;
    }

    .document-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .document-actions .button {
        width: auto; /* Allow buttons to take their natural width */
        margin-left: 0;
        margin-bottom: 5px; /* Vertical space between buttons */
    }

    .delete-icon-button {
        width: 40px; /* Keep fixed size for icon */
        height: 40px;
        border-radius: 4px; /* Make square on mobile */
    }

    .resources-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}