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

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.8;
    font-size: 18px;
}

/* Gestion des pages */
.page {
    display: none;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    padding-top: 80px;
}

.page.active {
    display: block;
}


/* Styles de la page de connexion */
#loginPage {
    text-align: center;
    padding-top: 50px;
}

#loginForm {
    margin: 20px 0;
}

input {
    width: 100%;
    padding: 20px;
    margin: 15px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 20px;
}

button {
    width: 100%;
    padding: 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
}

button:hover {
    background-color: #0056b3;
}

/* Liste des mois */
.months-container {
    display: grid;
    gap: 10px;
    padding: 10px;
}

.month-item {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
}

.month-item:hover {
    background-color: #f8f9fa;
}

/* Liste des courses */
.pdf-button {
    display: block;
    background: #28a745;
    color: white;
    text-decoration: none;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    margin: 15px 0;
    font-size: 20px;
    font-weight: bold;
}

.pdf-button:hover {
    background: #218838;
}

.course-item {
    background: white;
    padding: 20px;
    margin: 15px 0;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.course-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 5px 0;
}

.course-summary:hover {
    opacity: 0.8;
}

.course-details {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.course-item.expanded .course-details {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.course-amount {
    font-weight: bold;
    color: #28a745;
    font-size: 1.2em;
}

.course-detail {
    margin: 10px 0;
    color: #666;
}

.course-detail i {
    width: 20px;
    text-align: center;
    margin-right: 8px;
}

h1 {
    text-align: center;
    font-size: 32px;
}

/* Bouton retour */
.back-button {
    display: none;
}

/* Loader */
#loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Message d'erreur */
.error-message {
    position: fixed;
    top: 240px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #dc3545;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Responsive design */
@media (max-width: 600px) {
    .course-item {
        font-size: 18px;
    }

    input, button {
        font-size: 18px;
        padding: 15px;
    }

    h1 {
        font-size: 28px;
    }
}

.pickup-icon {
    color: #007bff;
    margin-right: 5px;
}

.destination-icon {
    color: #28a745;
    margin-right: 5px;
}

/* Header */
#mainHeader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

#headerPlateNumber {
    font-size: 18px;
    font-weight: bold;
}

.header-back, .header-logout {
    width: auto;
    padding: 10px;
    background: none;
    color: #333;
    font-size: 20px;
}

.header-back:hover, .header-logout:hover {
    background: none;
    color: #007bff;
}

/* Style pour les inputs du code SMS */
.sms-code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.sms-code-inputs input {
    width: 60px;
    height: 60px;
    text-align: center;
    font-size: 24px;
}

/* Style pour le compte à rebours */
.countdown {
    font-size: 18px;
    color: #666;
    margin: 15px 0;
}

/* Style pour le préfixe GE */
.plate-input-container {
    position: relative;
    width: 100%;
}

.plate-prefix {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #333;
}

#plateNumber {
    padding-left: 60px;
}

/* Style pour le sélecteur d'année */
.year-selector {
    margin: 20px 0;
    width: 100%;
    padding: 10px;
    font-size: 18px;
    border-radius: 8px;
    border: 2px solid #ddd;
}

#headerTitle {
    flex-grow: 1;
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: bold;
}

#headerTitle i {
    font-size: 24px;
    color: #007bff;
}

/* Styles pour la section utilisateur */
.user-info {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.plate-number-display {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    color: #007bff;
}

.disconnect-button {
    background-color: #dc3545;
    margin-top: 20px;
}

.disconnect-button:hover {
    background-color: #c82333;
}

/* Modification du bouton utilisateur */
.header-user {
    width: auto;
    padding: 10px;
    background: none;
    color: #333;
    font-size: 20px;
}

.header-user:hover {
    background: none;
    color: #007bff;
}

.no-data-message {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    color: #666;
    font-size: 18px;
}

.secondary-button {
    background-color: #6c757d;
    margin-top: 20px;
}

.secondary-button:hover {
    background-color: #5a6268;
}

/* Style pour la popup d'erreur */
.error-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 2000;
    max-width: 90%;
    width: 300px;
    text-align: center;
}

.error-popup-content {
    margin-bottom: 20px;
}

.error-popup-icon {
    color: #dc3545;
    font-size: 48px;
    margin-bottom: 15px;
}

.error-popup-message {
    color: #333;
    font-size: 16px;
    line-height: 1.4;
}

.error-popup-button {
    background-color: #dc3545;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.error-popup-button:hover {
    background-color: #c82333;
}

.error-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1999;
}

/* Style pour le moteur de recherche */
.search-container {
    position: relative;
    margin: 20px 0;
}

.search-container input {
    padding-left: 45px;
    background-color: white;
    border: 2px solid #ddd;
}

.search-container .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 20px;
}

.search-container input:focus {
    border-color: #007bff;
    outline: none;
}

/* Styles pour les livraisons en attente */
.pending-delivery-item {
    background: white;
    padding: 20px;
    margin: 15px 0;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pending-delivery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.delivery-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.delivery-ref {
    font-weight: bold;
    color: #007bff;
}

.delivery-addresses {
    color: #666;
}

.delivery-addresses i {
    margin-right: 8px;
}

/* Styles pour le statut de livraison */
.status-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
}

.status-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    margin-bottom: 20px;
}

.status-badge.waiting {
    background: #ffc107;
    color: #000;
}

.status-badge.in-progress {
    background: #007bff;
    color: white;
}

.status-badge.completed {
    background: #28a745;
    color: white;
}

.action-buttons {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.photo-button, .signature-button {
    padding: 15px;
    font-size: 16px;
}

.photos-preview, .signature-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.delivery-summary {
    background: white;
    padding: 20px;
    border-radius: 12px;
}

.summary-item {
    margin: 10px 0;
}

.delivery-stats {
    margin-top: 20px;
    display: grid;
    gap: 10px;
    color: #666;
}

/* Styles pour la capture photo et signature */
#photoCapture, #signaturePad {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.camera-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 3/4;
    background: #000;
    position: relative;
}

.signature-container {
    width: 100%;
    max-width: 500px;
    height: 300px;
    background: white;
    border-radius: 12px;
    position: relative;
}

#signatureCanvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 12px;
}

.hidden {
    display: none !important;
}

/* Style pour les prévisualisations de photos */
.photo-preview {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 10px 0;
    overflow: hidden;
}

.photo-preview img {
    width: 100%;
    max-width: 100%;
    display: block;
}

.photo-preview .delete-photo {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    padding: 8px;
    background: rgba(220, 53, 69, 0.9);
    border-radius: 50%;
    color: white;
    font-size: 16px;
}

.photo-preview .delete-photo:hover {
    background: #dc3545;
}

/* Modification du style pour la prévisualisation des signatures */
.signature-preview-item {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 10px 0;
    overflow: hidden;
    padding: 10px;
}

.signature-preview-item img {
    width: 100%;
    max-width: 100%;
    display: block;
}

/* Ajustement de la grille pour les signatures */
.signature-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

/* Styles pour les types de colis */
.package-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    margin-left: 10px;
}

.package-type.lettre {
    background-color: #e3f2fd;
    color: #1976d2;
}

.package-type.petit.colis {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.package-type.grand.colis {
    background-color: #fbe9e7;
    color: #d84315;
}

/* Styles pour les temps et comptes à rebours */
.delivery-times {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

.pickup-time {
    margin-bottom: 5px;
}

.countdown-timer {
    font-weight: bold;
}

.countdown-timer.urgent {
    color: #f44336;
}

.countdown-timer.expired {
    color: #9e9e9e;
}

.delivery-amount {
    font-weight: bold;
    color: #28a745;
}

.delivery-info {
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}