/* 
 * Styles pour la page SAV et la gestion du service après-vente
 */

/* Conteneur principal */
.sav-page, .sav-history-page {
    padding: 15px 15px 20px; /* Ajout de padding en haut */
}

/*
 * La marge laterale, reprise au conteneur general.
 *
 * `.order-prep-container` pose `padding: 0 !important` : la declaration
 * ci-dessus etait perdue, et sur telephone les cartes touchaient les deux bords
 * de l'ecran. Le selecteur double porte la marge, et l'important repond au sien.
 */
.order-prep-container.sav-page,
.order-prep-container.sav-history-page {
    padding-left: 10px !important;
    padding-right: 10px !important;
}

/* En-tête */
.order-prep-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.order-prep-header h1 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.order-prep-header-actions {
    display: flex;
    gap: 10px;
    justify-content: center; /* Centre les boutons horizontalement */
}

.order-prep-button-secondary {
    display: inline-flex;
    align-items: center;
    background-color: #f5f5f5;
    color: #333;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.order-prep-button-secondary svg {
    margin-right: 8px;
}

.order-prep-button-secondary:hover {
    background-color: #e0e0e0;
}

/* Liste des items SAV */
.sav-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sav-description {
    font-size: 14px;
    color: #555;
    line-height: 1.4;
}

.sav-complete-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4CAF50; /* Vert */
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sav-edit-button:hover {
    color: #333;
    background-color: #f0f0f0;
}

.sav-complete-button:hover {
    background-color: #3e8e41; /* Vert légèrement plus foncé */
}

.sav-complete-button svg {
    margin-right: 6px;
}

/*
 * Le libelle du bouton est ecrit dans le modele, et non ici.
 *
 * Il l'etait dans cette feuille, par « content », ou aucune traduction ne peut
 * l'atteindre : il sortait en francais sur toutes les boutiques, quelle que
 * soit leur langue.
 */
.sav-complete-button .sav-complete-label {
    font-size: 12px;
}

/* Historique SAV */
.sav-history-item {
    padding: 15px;
}

.sav-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sav-history-date {
    font-size: 14px;
    color: #666;
}

.sav-history-completed {
    font-size: 12px;
    color: #888;
}

.sav-history-content {
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.sav-history-main-info {
    margin-bottom: 8px;
}

.sav-history-order-number {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
}

.sav-history-client-name {
    font-size: 15px;
    color: #333;
}

.sav-history-description {
    font-size: 14px;
    color: #555;
    line-height: 1.4;
}

/* Modal */
.sav-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.sav-modal-content {
    background-color: #fff;
    border-radius: 8px;
    max-width: 90%;
    width: 500px;
    overflow: hidden;
    max-height: 90vh; /* repli navigateurs sans dvh */
    max-height: min(90dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.sav-modal-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sav-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.sav-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.sav-modal-body {
    padding: 15px;
    overflow-y: auto;
}

/* Formulaire */
.sav-form-field {
    margin-bottom: 15px;
}

.sav-form-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
}

.sav-form-field input[type="text"],
.sav-form-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.sav-form-field input[type="text"]:focus,
.sav-form-field textarea:focus {
    border-color: var(--op-ink);
    outline: none;
}

.sav-form-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}

.sav-form-button {
    background-color: var(--op-action);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    flex: 1;
    transition: background-color 0.2s;
}

.sav-form-button:hover {
    background-color: var(--op-action-hover);
}

.sav-form-button:disabled {
    background-color: #b0b0b0;
    cursor: not-allowed;
}

.sav-form-button-secondary {
    background-color: #f5f5f5;
    color: #333;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    flex: 1;
    transition: background-color 0.2s;
}

.sav-form-button-secondary:hover {
    background-color: #e0e0e0;
}

/* Pagination */
.order-prep-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

.pagination-links {
    display: flex;
    gap: 5px;
}

.pagination-link,
.pagination-prev,
.pagination-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background-color: #f5f5f5;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}

.pagination-link.current {
    background-color: var(--op-ink);
    color: white;
}

.pagination-link:hover,
.pagination-prev:hover,
.pagination-next:hover {
    background-color: #e0e0e0;
}

/* Message quand il n'y a pas de SAV */
.no-sav-items {
    text-align: center;
    padding: 30px 0;
    color: #666;
}

/* Responsive */
@media (max-width: 480px) {
    .order-prep-header {
        flex-direction: column;
        align-items: center; /* Centre les éléments horizontalement */
        text-align: center;
    }
    
    .order-prep-header h1 {
        margin-bottom: 15px; /* Ajoute de l'espace entre le titre et les boutons */
    }
    
    .order-prep-header-actions {
        margin-top: 10px;
        width: 100%; /* Prend toute la largeur */
        justify-content: center; /* Centre les boutons */
    }
    

    .sav-actions {
        justify-content: center;
        gap: 10px;
    }
    
    .sav-history-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sav-history-completed {
        margin-top: 5px;
    }
    
    .sav-modal-content {
        width: 95%;
    }
    
    .pagination-info {
        font-size: 12px;
    }
    
    .pagination-link,
    .pagination-prev,
    .pagination-next {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/*
 * Le bouton qui lance la preparation d'un renvoi.
 *
 * Il mene ailleurs, la ou ses voisins agissent sur place : il prend donc la
 * teinte des actions principales de l'application, sans lui voler la vedette.
 */
.sav-prepare-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    background-color: var(--op-ink, #16181b);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.sav-prepare-button:hover,
.sav-prepare-button:focus {
    background-color: var(--op-ink-hover, #000000);
    color: #ffffff;
}

.sav-prepare-button svg {
    flex: 0 0 auto;
}

/*
 * Les articles a renvoyer d'une fiche, un bloc chacun.
 *
 * Ils s'ecrivaient dans la description : le texte du vendeur et la liste des
 * articles s'y melaient, et retirer un article voulait dire retrouver sa ligne
 * dans la commande et la decocher. Chacun porte maintenant sa croix.
 */
/* Sans titre, la rangee de blocs ne disait pas ce qu'elle comptait. */
.sav-slots-title {
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
}

.sav-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.sav-slot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 4px 4px 10px;
    border: 1px solid #d7dbe0;
    border-radius: 999px;
    background: #f4f6f8;
    font-size: 13px;
    line-height: 1.2;
    color: #2b2f36;
}

.sav-slot--whole {
    border-color: #b8ddc9;
    background: #e8f5ee;
}

.sav-slot-quantity {
    font-weight: 600;
    color: #5b6068;
}

.sav-slot-text {
    /* Un nom long se coupe plutot que d'etirer le bloc hors de la fiche. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sav-slot-remove {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #dfe3e8;
    color: #4a4f57;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.sav-slot-remove:hover {
    background: #c9ced5;
}

.sav-slot-remove:disabled {
    opacity: 0.5;
    cursor: wait;
}

/*
 * Une fiche de service client, presentee en carte.
 *
 * Elle se lisait sur deux colonnes, le texte a gauche et une bande grise de
 * boutons a droite, qui poussait la description dans une colonne etroite. La
 * carte se lit maintenant de haut en bas : qui et quand, ce qui s'est passe,
 * puis ce qu'on en fait.
 */
.sav-item, .sav-history-item {
    background-color: #fff;
    border: 1px solid #e9ebee;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    overflow: hidden;
}

.sav-item {
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.sav-item:hover {
    box-shadow: 0 2px 4px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.08);
}

.sav-info {
    flex: 1;
    padding: 14px 16px 16px;
}

/* L'entete : l'essentiel a gauche, la retouche dans l'angle. */
.sav-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.sav-card-head-text {
    min-width: 0;
}

.sav-date {
    font-size: 12px;
    color: #8a9099;
    margin-bottom: 6px;
}

.sav-main-info {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.sav-order-number {
    font-weight: 700;
    font-size: 16px;
    color: #16181b;
    margin-bottom: 0;
}

.sav-order-number::before {
    content: '#';
    color: #b4b9c0;
}

.sav-client-name {
    font-size: 14px;
    color: #5b6068;
}

.sav-description {
    font-size: 14px;
    color: #4a4f57;
    line-height: 1.45;
}

/*
 * Le crayon, dans l'angle : discret tant qu'on ne le cherche pas, et assez
 * large pour un pouce.
 */
.sav-edit-button {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: -4px -4px 0 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: #8a9099;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sav-edit-button:hover,
.sav-edit-button:focus {
    border-color: #e0e3e7;
    background-color: #f5f6f8;
    color: #16181b;
}

/*
 * Le pied : les deux gestes qui engagent une suite.
 *
 * Ils se partagent la largeur plutot que de se tasser contre le bord droit, ou
 * ils laissaient un vide au milieu de la carte et tombaient loin du pouce.
 */
.sav-actions {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #f0f1f3;
    background-color: #fbfbfc;
}

.sav-actions > .sav-prepare-button,
.sav-actions > .sav-complete-button {
    flex: 1 1 0;
    justify-content: center;
    min-height: 40px;
}

/*
 * Les articles d'une fiche close, dans l'historique.
 *
 * L'ecran ne montrait que le texte de la fiche : on ne savait ni ce qu'elle
 * portait, ni si c'etait parti. Chaque ligne le dit maintenant, et la couleur
 * separe d'un coup d'oeil ce qui a ete renvoye de ce qui ne l'a pas ete.
 */
.sav-history-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid #d0d5db;
    background: #f7f8f9;
}

.sav-history-items.is-sent {
    border-left-color: #4CAF50;
    background: #f1f8f3;
}

.sav-history-items.is-unsent {
    border-left-color: #e0a800;
    background: #fdf8ec;
}

.sav-history-item-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 13px;
    line-height: 1.35;
}

.sav-history-item-name {
    font-weight: 600;
    color: #2b2f36;
}

.sav-history-item-state {
    color: #6b7280;
}

.sav-history-items.is-unsent .sav-history-item-state {
    color: #8a6100;
}
