/* Palette de couleurs inspirée de SABC */
:root {
    --primary-color: #E53E3E; /* Rouge SABC */
    --accent-color: #FF9800; /* Orange */
    --light-background: #F5F5F5;
    --border-color: #E0E0E0;
    --text-primary: #424242;
    --text-secondary: #9E9E9E;
    --white-color: #FFFFFF;
    --success-color: #4CAF50;
    --error-color: #f44336;
}

/* Réinitialisation et styles de base */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-background);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--white-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Conteneur plus large pour les tableaux de bord admin et superviseur */
.container-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--white-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow-x: auto; /* Permet le défilement horizontal si nécessaire */
}

/* Styles spécifiques pour les tableaux DataTables */
.dataTables_wrapper {
    width: 100%;
    overflow-x: auto;
}

/* Assurer que le tableau utilise tout l'espace disponible */
table.dataTable {
    width: 100% !important;
    margin-bottom: 1rem;
}

/* Style pour les boutons d'export */
.btn-export {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    border-radius: 4px !important;
    margin-right: 5px !important;
    font-weight: 500 !important;
}

.btn-export:hover {
    opacity: 0.9 !important;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

header h1 { color: var(--primary-color); font-size: 2rem; }
header p { color: var(--text-secondary); font-size: 1rem; }

/* Styles des formulaires */
form { display: flex; flex-direction: column; gap: 1.5rem; }
fieldset { border: 1px solid var(--border-color); border-radius: 6px; padding: 1.5rem; transition: all 0.3s ease; }
fieldset:focus-within { border-color: var(--primary-color); }
legend { font-weight: 600; color: var(--primary-color); padding: 0 0.5rem; margin-left: 1rem; font-size: 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; margin-bottom: 1rem; }
label { margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.required { color: var(--error-color); }

input[type="text"], input[type="number"], input[type="password"], input[type="file"], select, textarea {
    width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 4px; font-size: 1rem; transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.2);
}

select[disabled] { background-color: #f9f9f9; cursor: not-allowed; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--error-color); }

/* Input avec bouton à côté */
.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button input {
    flex-grow: 1;
}

/* Styles des boutons */
button { font-family: inherit; border: none; border-radius: 4px; padding: 0.75rem 1.5rem; font-size: 1rem; cursor: pointer; transition: background-color 0.3s, transform 0.1s; }
.submit-btn { background-color: var(--primary-color); color: var(--white-color); font-weight: 600; padding: 0.8rem; font-size: 1.1rem; width: 100%; margin-top: 1rem; }
.submit-btn:hover { background-color: #c53030; }
.submit-btn:disabled { background-color: #e0e0e0; cursor: wait; }
#get-location-btn { background-color: var(--accent-color); color: var(--white-color); white-space: nowrap; }
#get-location-btn:hover { background-color: #e68a00; }

/* Classes utilitaires */
.hidden { display: none; }
.feedback { font-size: 0.85rem; margin-top: 0.25rem; min-height: 1em; }
.error-message { color: var(--error-color); font-size: 0.85rem; margin-top: 0.25rem; min-height: 1em; }
#serial-feedback.valid { color: var(--success-color); }
#serial-feedback.invalid { color: var(--error-color); }
#location-feedback { color: var(--text-secondary); }

#form-feedback { text-align: center; padding: 1rem; border-radius: 4px; font-weight: 500; margin-top: 1rem; display: none; }
#form-feedback.success { display: block; background-color: #e8f5e9; color: var(--success-color); }
#form-feedback.error { display: block; background-color: #ffebee; color: var(--error-color); }

/* Prévisualisation des images */
.file-upload-container {
    position: relative;
    margin-bottom: 1rem;
}

.file-upload-container input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 4px;
    background-color: #fafafa;
    transition: all 0.3s ease;
}

.file-upload-label:hover {
    border-color: var(--primary-color);
    background-color: #f5f5f5;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

#image-preview { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
#image-preview .img-container { position: relative; }
#image-preview img { width: 100px; height: 100px; object-fit: cover; border: 1px solid var(--border-color); border-radius: 4px; }
#image-preview .remove-img { position: absolute; top: -5px; right: -5px; background: black; color: white; border-radius: 50%; width: 20px; height: 20px; text-align: center; line-height: 20px; cursor: pointer; font-weight: bold; }

/* =================================== */
/* ======== RESPONSIVE DESIGN ======== */
/* =================================== */

/* Pour les écrans de moins de 768px (tablettes et mobiles) */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        padding: 1rem;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        width: 100%;
    }

    header h1 {
        font-size: 1.5rem;
    }

    /* Forcer les grilles du formulaire à s'empiler */
    .form-grid {
        grid-template-columns: 1fr !important; /* Une seule colonne */
    }

    .input-with-button {
        flex-direction: column;
    }

    .submit-btn {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* Ajustement de la prévisualisation des images */
    #image-preview {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    /* Cacher le texte long dans le header */
    .header-link-text {
        display: none;
    }
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    header {
        text-align: left;
        padding: 1rem;
    }

    header p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    fieldset {
        padding: 1rem;
    }
}