/* 
 * Style principal pour l'application Form Builder
 */

/* Variables globales */
:root {
    --primary-color: #007bff;
    --primary-dark: #0069d9;
    --primary-light: #cce5ff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --body-bg: #f8f9fa;
    --form-builder-bg: #f8f9fa;
    --form-builder-border: #dee2e6;
    --form-builder-component-hover: #e9ecef;
    --form-builder-active: #007bff;
    --form-builder-drop-indicator: #007bff;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

/* Structure principale */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--body-bg);
}

body {
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--dark-color);
    line-height: 1.6;
}

main {
    flex: 1;
    padding-bottom: 60px; /* Espace pour le footer */
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* En-tête et navigation */
header {
    background-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #fff;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 80%;
}

/* Pied de page */
.footer {
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
    padding: 20px 0;
    font-size: 0.9rem;
    margin-top: auto;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 8px;
}

.footer a:hover {
    text-decoration: underline;
}

/* Cartes et panneaux */
.card {
    border: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-speed) ease;
    margin-bottom: 20px;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border-bottom: none;
    padding: 15px 20px;
}

.card-header.bg-light {
    background-color: var(--light-color);
    color: var(--dark-color);
    border-bottom: 1px solid #dee2e6;
}

.card-body {
    padding: 20px;
    background-color: #fff;
}

.card-footer {
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
    padding: 12px 20px;
}

/* Formulaires */
.form-control, .form-select {
    padding: 0.6rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.input-group .input-group-text {
    background-color: var(--light-color);
}

/* Boutons */
.btn {
    border-radius: 4px;
    font-weight: 500;
    padding: 0.6rem 1.2rem;
    text-transform: none;
    transition: all 0.2s ease-in-out;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
    font-size: 0.875rem;
}

/* Alertes */
.alert {
    border: none;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.alert-success {
    background-color: #e8f5e9;
    color: #1b5e20;
}

.alert-danger {
    background-color: #ffebee;
    color: #b71c1c;
}

.alert-warning {
    background-color: #fff8e1;
    color: #ff6f00;
}

.alert-info {
    background-color: #e1f5fe;
    color: #0277bd;
}

/* Tableaux */
.table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6;
    background-color: var(--light-color);
    font-weight: 600;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* Badges */
.badge {
    padding: 0.4em 0.6em;
    font-weight: 500;
    border-radius: 4px;
}

/* Utilitaires */
.cursor-pointer {
    cursor: pointer;
}

.cursor-move {
    cursor: move;
}

.min-vh-50 {
    min-height: 50vh;
}

.form-canvas {
    min-height: 400px;
    background-color: var(--form-builder-bg);
    border: 2px dashed var(--form-builder-border);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.form-canvas.dragover {
    border-color: var(--form-builder-active);
    background-color: rgba(0, 123, 255, 0.1);
}

/* Animations et effets */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {transform: translateX(0);}
    20%, 60% {transform: translateX(-5px);}
    40%, 80% {transform: translateX(5px);}
}

/* Adaptations responsive */
@media (max-width: 768px) {
    .card-header, .card-body, .card-footer {
        padding: 12px 15px;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 10px;
    }
    
    .card {
        border-radius: 6px;
    }
    
    .btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.85rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
}

/* Thème sombre (préparé pour une future implémentation) */
/* Pour activer, ajouter la classe .dark-theme à body */
body.dark-theme {
    --body-bg: #212121;
    --form-builder-bg: #2d2d2d;
    --form-builder-border: #444;
    --form-builder-component-hover: #3a3a3a;
    --light-color: #333;
    --dark-color: #f8f9fa;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    
    color: #f8f9fa;
}

body.dark-theme .card,
body.dark-theme .card-body {
    background-color: #2d2d2d;
}

body.dark-theme .card-header.bg-light,
body.dark-theme .card-footer {
    background-color: #333;
    color: #f8f9fa;
}

body.dark-theme .table thead th {
    background-color: #333;
    color: #f8f9fa;
}

body.dark-theme .alert-info {
    background-color: #0d47a1;
    color: #e3f2fd;
}

body.dark-theme .alert-success {
    background-color: #1b5e20;
    color: #e8f5e9;
}

/* Accessibilité */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Focus visible pour accessibilité */
:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}


/* Styles pour la sélection de membres/groupes */
.members-list .list-group-item,
.groups-list .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.members-list .list-group-item:hover,
.groups-list .list-group-item:hover {
    background-color: #f8f9fa;
}

.members-list .form-check-input,
.groups-list .form-check-input {
    cursor: pointer;
}

.selected-count {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    text-align: center;
}

/* Animation pour le bouton de copie */
.copy-link.copied {
    animation: pulse 0.5s;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Toast personnalisé */
.toast {
    min-width: 300px;
}

/* Badge de notification */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Amélioration responsive pour les tables */
@media (max-width: 575px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table td, .table th {
        padding: 0.5rem 0.25rem;
    }
    
    .dropdown-menu {
        font-size: 0.875rem;
    }
    
    .badge {
        font-size: 0.75rem;
        padding: 0.25em 0.5em;
    }
}

/* Style pour les listes de membres et groupes */
.members-list,
.groups-list {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Pour un scroll fluide sur iOS */
}

.list-group-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Amélioration du modal sur mobile */
@media (max-width: 575px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
}