/* style.css - Version Mobile-First Professionnelle */

:root {
    --primary-color: #2980b9;
    --success-color: #27ae60;
    --danger-color: #c0392b;
    --light-gray: #f4f5f7;
    --medium-gray: #dfe1e6;
    --dark-gray: #5e6c84;
    --text-color: #172b4d;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--light-gray);
    color: var(--text-color);
}

/* Structure générale */
.screen {
    display: none;
    padding: 15px;
    max-width: 800px;
    margin: 0 auto;
}
.screen.active { display: block; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 5px;
}
header h2 { margin: 0; font-size: 1.5em; }
.header-btn {
    background: none; border: none; font-size: 1.5em;
    cursor: pointer; color: var(--primary-color);
}

/* Style des "Cartes" */
.card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}
.card h3 { margin-top: 0; }

/* Grille de détails */
.details-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
}
.details-grid span { color: var(--dark-gray); }

/* Tableaux d'articles */
.articles-table {
    display: grid;
    /* On définit 4 colonnes : 
       1. La première (Description) prend tout l'espace disponible (1fr).
       2. Les 3 suivantes ont des largeurs fixes adaptées au contenu.
    */
    grid-template-columns: 1fr 70px 70px 70px 50px;
    border: 1px solid var(--medium-gray);
    border-radius: 5px;
    overflow: hidden; /* Important pour les coins arrondis */
}

/* Style commun pour chaque cellule (en-tête et ligne) */
.articles-table > div > span {
    padding: 3px;
    display: flex;
    align-items: center;
    word-break: break-word; /* Permet au texte long de passer à la ligne proprement */
}

/* On utilise un pseudo-élément pour simuler les bordures, c'est plus propre */
.articles-table > .article-item {
    display: contents; /* Astuce pour que les spans deviennent des cellules de la grille */
}
.articles-table > .article-item > span {
    background: white;
    border-bottom: 1px solid var(--medium-gray);
}
.articles-table > div:last-child > span {
    border-bottom: none; /* Pas de bordure pour la dernière ligne */
}

/* En-tête du tableau */
.articles-header {
    display: contents; /* L'en-tête participe aussi à la grille */
}
.articles-header > span {
    font-weight: bold;
    background-color: var(--light-gray);
    color: var(--dark-gray);
    border-bottom: 2px solid var(--medium-gray);
}

/* Alignement des colonnes numériques */
.articles-table .qty,
.articles-table .price,
.articles-table .total {
    justify-content: flex-end; /* Aligne le contenu à droite */
}

.articles-table .total {
    font-weight: bold;
}

/* Style pour les articles non modifiables */
.article-item.readonly > span {
    background-color: #fafafa;
    color: #555;
}

/* Bouton de suppression (inchangé) */
.article-item .actions {
    justify-content: center; /* Centre le bouton */
}
.article-item .actions button {
    background: none; border: none; color: var(--danger-color); cursor: pointer;
    font-size: 1.2em; padding: 0; line-height: 1;
}

/* Formulaires */
input, textarea, button {
    font-size: 1em;
    width: 100%;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid var(--medium-gray);
    box-sizing: border-box;
    margin-bottom: 10px;
}
textarea { min-height: 80px; }
button {
    background-color: var(--primary-color);
    color: white; border: none; cursor: pointer; font-weight: bold;
    transition: background-color 0.2s;
}
button:hover { opacity: 0.9; }

.button-primary { background-color: var(--success-color); }
.btn-danger { background-color: var(--danger-color); }
.btn-full { width: 100%; padding: 15px; font-size: 1.1em; }

.form-row { display: flex; gap: 10px; }
.add-form button {
    flex-shrink: 0;
    width: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* Total et Signature */
.total-section {
    text-align: right;
    font-size: 1.2em;
    margin: 15px 0;
    padding-right: 5px;
}
.signature-label { font-weight: bold; margin-bottom: 8px; }
#signature-canvas {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--medium-gray);
    border-radius: 5px;
    cursor: crosshair;
    touch-action: none;
}
#clear-signature-btn { margin-top: 10px; }

.job-item {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 15px; /* Espace entre les cartes */
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 5px solid var(--primary-color); /* Ajoute une barre de couleur pour le style */
}

/* Effet de survol pour indiquer que l'élément est cliquable */
.job-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}

.job-item strong {
    font-size: 1.1em;
    display: block; /* Met le nom du client sur sa propre ligne */
    margin-bottom: 5px;
}

.job-item span {
    color: var(--dark-gray);
}

.grand-total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid var(--primary-color);
    font-size: 1.3em;
    font-weight: bold;
}
.btn-secondary { background-color: var(--dark-gray); }
.btn-secondary:hover { background-color: var(--text-color); }

/* Ajoutez cette nouvelle classe à la fin du fichier */
.btn-success { background-color: var(--success-color); }
.btn-success:hover { background-color: #229954; } /* Une teinte un peu plus foncée */

/* --- STYLES POUR LES ONGLETS --- */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--medium-gray);
}

.tab-button {
    padding: 10px 15px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--dark-gray);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.jobs-list-panel {
    display: none; /* Tous les panneaux sont cachés par défaut */
}

.jobs-list-panel.active {
    display: block; /* Seul le panneau actif est visible */
}
/* Fichier : temporaire/style.css */

/* ============================================= */
/* ==         STYLES POUR LA RESPONSIVE         == */
/* ============================================= */

/* Ces règles ne s'appliquent que sur les écrans de moins de 768px de large (téléphones, tablettes en portrait) */
@media (max-width: 768px) {

    /* On réduit le padding général pour gagner de la place */
    .screen {
        padding: 10px;
    }

    /* On transforme la grille des détails du client en une simple liste verticale */
    .details-grid {
        grid-template-columns: 1fr; /* Une seule colonne */
        gap: 10px;
    }
    .details-grid strong {
        margin-top: -8px; /* Rapproche la valeur de son label */
    }

    /* C'est la partie la plus importante : la transformation des tableaux d'articles */
    .articles-table {
        display: block; /* On annule la grille CSS */
        border: none;
    }

    /* On cache l'en-tête du tableau sur mobile */
    .articles-table .articles-header {
        display: none;
    }

    /* Chaque ligne devient une "carte" */
    .articles-table > .article-item {
        display: block;
        border: 1px solid var(--medium-gray);
        border-radius: 6px;
        padding: 10px;
        margin-bottom: 10px;
        background-color: white; /* Fond pour les lignes dans la section "ajouts" */
    }
    
    .articles-table > .article-item.readonly > span {
         background-color: transparent; /* Annule la couleur de fond pour les articles prévus */
    }
    
    .articles-table > .article-item > span {
        display: block; /* Chaque "cellule" prend toute la largeur */
        border: none;
        padding: 4px 0;
        text-align: right; /* On aligne le contenu à droite */
    }

    /* On utilise les pseudo-éléments pour recréer les labels de colonne */
    .articles-table > .article-item > span::before {
        content: attr(data-label); /* On lira un attribut 'data-label' qu'on ajoutera en JS */
        font-weight: bold;
        float: left; /* Le label à gauche, la valeur à droite */
        color: var(--dark-gray);
    }
    
    /* Le nom de l'article prend toute la largeur */
    .articles-table > .article-item > span.name {
         display: block;
         font-weight: bold;
         font-size: 1.1em;
         text-align: left;
         margin-bottom: 8px;
         padding-bottom: 8px;
         border-bottom: 1px solid #eee;
    }
    .articles-table > .article-item > span.name::before {
        display: none; /* Pas de label "Description:" pour le nom */
    }
    
    /* Le bouton de suppression est centré */
    .articles-table > .article-item > span.actions {
        text-align: center;
        margin-top: 10px;
    }
     .articles-table > .article-item > span.actions::before {
        display: none;
    }

    /* Le formulaire d'ajout passe en mode vertical */
    .add-form .form-row {
        flex-direction: column;
    }
     /* On s'assure que le formulaire lui-même est bien visible */
    #add-article-form {
        display: block; /* Force l'affichage du formulaire */
        margin-top: 20px; /* Ajoute un peu d'espace au-dessus */
    }
}