/* static/styles.css */

/* Police utilisée par l'éditeur de vues SVG : embarquée en base64 dans le SVG exporté (voir
   vue_editor.js), déclarée ici aussi pour que l'aperçu à l'écran soit fidèle au rendu exporté. */
@font-face {
    font-family: 'DejaVu Sans';
    src: url('fonts/DejaVuSans.ttf') format('truetype');
}

.img-responsive {
    width: 100%;
    height: auto;
}

.modified {
    background-color: grey;
}
.saved {
    background-color: white;
}

/* styles.css */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
}

/* Navigation */
.nav-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 0.5rem 2rem;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #0066cc;
}

.admin-link {
    color: #e91e63 !important;
}

/* Macaron créateur (module Volume) : fond transparent, contour et lettres dans la couleur du
   compte (via `color`, le contour suit avec currentColor), accessible clavier/lecteur d'écran
   (tabindex + aria-label, en plus du title pour le survol souris). */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    background: transparent;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: default;
}

.filter-row th {
    padding-top: 0.25rem;
}

.filter-input {
    width: 100%;
    box-sizing: border-box;
    font-weight: normal;
}

/* Filtre "Créateur" : bouton + panneau de cases à cocher (Prénom Nom), rien coché = tout affiché. */
.creator-filter {
    position: relative;
    font-weight: normal;
}

.creator-filter-toggle {
    width: 100%;
    box-sizing: border-box;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-weight: normal;
    cursor: pointer;
    text-align: left;
}

.creator-filter-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    min-width: 12rem;
    max-height: 16rem;
    overflow-y: auto;
}

.creator-filter-panel label {
    display: block;
    white-space: nowrap;
    font-weight: normal;
    padding: 0.15rem 0;
}

.avatar:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Layout principal */
[role="main"] {
    margin-top: 4rem;
    padding: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Titres */
h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-size: 2rem;
}

/* Boutons */
/* `font: inherit` est nécessaire ici : sans lui, un <button> reprend la police de contrôle par
   défaut du navigateur (généralement plus petite que le texte du site), alors qu'un <a> ou un
   <label> avec la même classe hérite normalement de la police du texte — deux éléments .btn de
   tag différent se retrouvaient donc à des tailles visuellement incohérentes. */
.btn {
    display: inline-block;
    font: inherit;
    /* line-height resserré (au lieu d'hériter du 1.6 du body) + padding vertical réduit : ~25%
       de hauteur en moins par rapport à l'ancien bouton, texte inchangé (même font-size). */
    line-height: 1.2;
    padding: 0.4rem 1rem;
    background-color: #0066cc;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 0.5rem;
}

.btn:hover {
    background-color: #0052a3;
}

.btn-danger {
    background-color: #dc3545;
    display: inline-block;
    font: inherit;
    line-height: 1.2;
    padding: 0.4rem 1rem;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin: 0.5rem;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Conteneurs centrés */
.center-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
}

/* Formulaires */
.form-group {
    margin-bottom: 1rem;
    text-align: center;
}

.form-control {
    width: 100%;
    max-width: 400px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0.5rem 0;
}

/* Grille pour les projets */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.project-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

/* Images responsives */
.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

/* Sections DXF et Plans */
.section {
    margin: 0.5rem 0 2rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Titre de la page projet : moins d'espace en dessous qu'un h1 générique */
.projet-title {
    margin-top: -1rem;
    margin-bottom: 0.75rem;
    font-size: 1.3rem;
}

/* Media queries */
@media (max-width: 768px) {
    .nav-container {
        padding: 0.5rem;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    [role="main"] {
        padding: 1rem;
    }

    .valeurs-columns {
        flex-direction: column;
    }

    .valeurs-col > div {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .valeurs-col label {
        flex: none;
        text-align: left;
    }
}

/* Styles additionnels pour volumes.html */
.text-center {
    text-align: center;
    margin: 1rem 0;
    color: #666;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.project-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.project-card h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
    text-align: center;
}

/* Assurez-vous que les formulaires inline ne perturbent pas la mise en page */
.project-card form {
    margin: 0;
}


/* static/css/styles.css */

/* Styles pour le conteneur centré */
.login-center-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0f0f0;
}

/* Styles pour le formulaire de login */
.login-form {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 300px;
    text-align: center;
}

.login-form form {
    display: flex;
    flex-direction: column;
}

.login-form label {
    margin-bottom: 5px;
    text-align: left;
}

.login-form input {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.login-form .btn {
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.login-form .btn:hover {
    background-color: #0056b3;
}

.form-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Conteneur pour la table */
.table-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    overflow-x: auto;
}

/* Styles pour la table des projets */
.projects-table {
    border-collapse: collapse;
    width: 80%;
    margin: 0 auto;
}

.projects-table th, .projects-table td {
    border: 1px solid #ddd;
    padding: 4px 10px;
    line-height: 1.3;
    text-align: left;
}

.projects-table th {
    background-color: #f2f2f2;
}

.projects-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.projects-table tr:hover {
    background-color: #f1f1f1;
}

/* Styles pour le cadre de traitement */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.processing-message {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    font-size: 1.5rem;
    color: #333;
}

/* Styles pour le formulaire en grille */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    max-width: 800px;
    margin: 0 auto;
}

.form-grid div {
    display: flex;
    flex-direction: column;
}

/* Champs de valeurs du rapport (page projet) : label et champ côte à côte plutôt qu'empilés, et
   colonne 1 remplie en premier puis colonne 2 (plutôt que ligne par ligne) — cf.
   app/routers/projets.py::open_projet pour le calcul du découpage en colonnes. Une div .valeurs-
   col par colonne, chacune un flex-column indépendant : l'ordre visuel suit directement l'ordre
   du DOM (contrairement à une grille CSS à 2 colonnes, qui remplirait ligne par ligne). */
.valeurs-columns {
    display: flex;
    gap: 6px 24px;
    max-width: 900px;
    margin: 0 auto;
}

.valeurs-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 260px;
}

.valeurs-col > div {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.valeurs-col label {
    flex: 0 0 170px;
    text-align: right;
    font-size: 0.82rem;
    color: #444;
}

.valeurs-col input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 3px 6px;
    font-size: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Bouton "Sauvegarder" mis en évidence quand des champs ont été modifiés sans être encore
   enregistrés (cf. app/templates/open_volume.html, classe togglée en JS). */
.btn-unsaved {
    background-color: #ff9800;
}

.btn-unsaved:hover {
    background-color: #e68a00;
}

.form-actions {
    grid-column: span 2;
    display: flex;
    justify-content: center;
}

/* Styles pour centrer le contenu de la div */
.centered-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px; /* Espace entre les éléments */
}

/* Tuiles repliables (DXF/modèle/infos, plans, coupes) de la page projet */
.tuile {
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 0.5rem 0 1.5rem;
    overflow: hidden;
}

.tuile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background-color: #fafafa;
}

.tuile.collapsed .tuile-header {
    border-bottom: none;
}

.tuile-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    text-align: left;
}

.tuile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.tuile-toggle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 900;
    color: #333;
    line-height: 1;
}

.tuile-toggle:hover {
    background-color: #eee;
}

.tuile-body {
    padding: 1rem;
    border-top: 1px solid #eee;
}

.tuile.collapsed .tuile-body {
    display: none;
}

.tuile-title {
    font-weight: 600;
    color: #333;
}

.tuile-thumb {
    height: 48px;
    width: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: block;
}

.modele-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Coupe désactivée : tuile grisée, miniature en niveaux de gris */
.tuile.tuile-desactivee {
    background-color: #f7f7f7;
}

.tuile.tuile-desactivee .tuile-header {
    background-color: #ececec;
}

.tuile.tuile-desactivee .tuile-title {
    color: #888;
}

.tuile-thumb-grise {
    filter: grayscale(1);
    opacity: 0.6;
}

.btn-muted {
    background-color: #999;
}

.btn-muted:hover {
    background-color: #888;
}

/* Bouton "admin" du menu principal : reprend la couleur rose de .admin-link (barre de menu)
   pour distinguer les fonctions/modules réservés aux admins des autres boutons (restés bleus). */
.btn-admin-tuile {
    background-color: #e91e63;
}

.btn-admin-tuile:hover {
    background-color: #c2185b;
}

/* Grille du menu principal (dashboard) : boutons carrés, 4 par ligne (les suivants passent à la
   ligne d'en dessous). */
.dashboard-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 140px);
    grid-auto-rows: 140px;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2rem;
}

.dashboard-menu-grid .btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem;
    border-radius: 8px;
}



/* Styles pour la table des utilisateurs */
.users-table {
    border-collapse: collapse;
    width: 80%;
    margin: 0 auto;
}

.users-table th, .users-table td {
    border: 1px solid #ddd;
    padding: 4px 10px;
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
}

.users-table th {
    background-color: #f2f2f2;
}

.users-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.users-table tr:hover {
    background-color: #f1f1f1;
}

/* Colonne "Modules" : tronquée avec "..." si trop longue pour tenir sur la ligne ; la liste
   complète reste consultable via l'infobulle native (attribut title) au survol. */
.modules-cell {
    max-width: 240px;
}

.modules-truncate {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Colonne "Actions" : menu déroulant (natif <details>, sans JS de positionnement) pour que
   chaque ligne utilisateur tienne sur une seule ligne malgré le nombre d'actions possibles. */
.actions-menu {
    position: relative;
    display: inline-block;
}

.actions-menu summary {
    cursor: pointer;
    list-style: none;
}

.actions-menu summary::-webkit-details-marker {
    display: none;
}

.actions-menu summary::after {
    content: ' \25BE';
}

.actions-menu-content {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    margin-top: 4px;
    padding: 4px;
    white-space: nowrap;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.actions-menu-content a,
.actions-menu-content button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-decoration: none;
}

.actions-menu-content a:hover,
.actions-menu-content button:hover {
    background-color: #f1f1f1;
}

.actions-menu-content button.action-danger {
    color: #dc3545;
}

.actions-menu-content form {
    margin: 0;
}

/* Styles pour les messages flash */
.flashes {
    list-style-type: none;
    padding: 0;
}

.flashes li {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 4px;
}

.flashes .success {
    background-color: #d4edda;
    color: #155724;
}

.flashes .error,
.flashes .danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Avertissements non bloquants de génération DXF (cf. volume/vol.py::generer_projet) : fond
   orange transparent, pour bien se distinguer des succès/erreurs pleines couleur ci-dessus. */
.flashes .warning {
    background-color: rgba(255, 165, 0, 0.18);
    color: #7a4a00;
    border: 1px solid rgba(255, 165, 0, 0.5);
}

/* En-tête de page avec actions à côté du titre (ex : page modèle, "Télécharger"/"Fermer"). */
.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-header-row h1 {
    margin-bottom: 0;
    text-align: left;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Formulaire de la page modèle (ajout/édition) : classe dédiée (pas .form-grid, partagée avec
   d'autres formulaires comme admin/add_user.html) pour ne pas répercuter ces réglages ailleurs.
   Champ "nom" empilé au-dessus du champ "fichier" (une seule colonne). */
.template-modele-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    max-width: 800px;
    margin: 0 auto;
}

.template-modele-form > div {
    display: flex;
    flex-direction: column;
}

.template-modele-form input[type="text"] {
    width: 220px;
    max-width: 100%;
}

.template-modele-form input[type="file"] {
    width: 100%;
}

/* Liste des champs texte détectés : une colonne, réordonnable par glisser-déposer (cf.
   app/templates/template_form.html). */
.champs-liste {
    list-style: none;
    margin-top: 0.5rem;
    padding: 0;
    max-width: 320px;
    width: 100%;
}

.champs-liste li {
    color: #0066cc;
    font-weight: bold;
    padding: 6px 10px;
    margin-bottom: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    cursor: move;
}

.champs-liste li.champ-glisse {
    opacity: 0.4;
}

.champs-liste li.champ-survole {
    border-top: 2px solid #0066cc;
}

.champs-liste-aide {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
}