/* users.css - Styles modernes pour la page de gestion des membres */

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #8b5cf6;
    --background: #f8fafc;
    --background-light: #f1f5f9;
    --card-background: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition-fast: 0.15s ease-out;
    --transition-base: 0.2s ease-out;
    --transition-slow: 0.3s ease-out;
}

/* Reset et base */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background decoratif */
.background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    pointer-events: none;
    z-index: -1;
}

/* Container principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* Header avec logo */
.header-container {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
    padding: 24px 32px;
    background: var(--card-background);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.header-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--info-color));
}

.logo-link {
    display: inline-block;
    text-decoration: none;
    line-height: 0;
}

.logo {
    height: 64px;
    width: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base);
}

.logo-link:hover .logo {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.logo-link:active .logo {
    transform: scale(0.98);
}

.title {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

/* Messages et loader */
.message-fixed {
    position: fixed;
    top: 90px;
    right: 24px;
    z-index: 9999;
    max-width: 400px;
}

.famivest-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    display: flex;
    gap: 10px;
}

.famivest-loader .ball {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: bounce 1.4s infinite ease-in-out both;
}

.famivest-loader .ball.yellow {
    background: var(--warning-color);
    animation-delay: -0.32s;
}

.famivest-loader .ball.green {
    background: var(--success-color);
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.is-hidden {
    display: none !important;
}

/* Carte de formulaire */
.form-card {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition-base);
}

.form-card:hover {
    box-shadow: var(--shadow-lg);
}

.form-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
}

.form-icon {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Section du formulaire */
.form-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
}

/* Formulaire */
.form-row {
    margin-bottom: 20px;
}

.form-row-triple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    background: var(--card-background);
    color: var(--text-primary);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Checkboxes modernisées */
.form-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.checkbox-card {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--background-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
}

.checkbox-card:hover {
    border-color: var(--primary-color);
    background: var(--card-background);
    box-shadow: var(--shadow-sm);
}

.checkbox-card input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.checkbox-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.checkbox-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checkbox-text strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.checkbox-text small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Boutons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--card-background);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.95rem;
}

.btn-secondary:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    font-size: 1.1em;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* Section des membres */
.users-section {
    margin-top: 32px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
    gap: 16px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Boutons de filtrage */
.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.filter-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Grille de membres */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.user-card {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.user-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.user-card.principal {
    border-color: var(--info-color);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.03) 0%, rgba(59, 130, 246, 0.03) 100%);
}

.user-card.principal::before {
    content: '⭐ Principal';
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--info-color);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.user-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    word-wrap: break-word;
}

.user-birth {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--background-light);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.user-badge.foyer {
    background: #dbeafe;
    color: #1e40af;
}

.user-badge.locataire {
    background: #fef3c7;
    color: #92400e;
}

.user-badge.handicape {
    background: #e0e7ff;
    color: #3730a3;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    word-break: break-all;
}

.principal-checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--background-light);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.principal-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--info-color);
}

.principal-checkbox-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.user-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.btn-edit,
.btn-delete,
.btn-relations {
    flex: 1;
    padding: 10px 16px;
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-edit {
    background: linear-gradient(135deg, var(--warning-color), #f59e0b);
}

.btn-delete {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
}

.btn-relations {
    background: linear-gradient(135deg, var(--info-color), #7c3aed);
}

.btn-edit:hover,
.btn-delete:hover,
.btn-relations:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* État vide */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-background);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    margin-top: 20px;
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Modal de relations */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 2px solid var(--border-light);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--background-light);
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.relation-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--background-light);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.relation-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.relation-info h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.relations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.relation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.relation-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.relation-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.relation-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning-color), #f59e0b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    font-weight: 700;
}

.relation-item-details h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.relation-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: var(--card-background);
    cursor: pointer;
    transition: all var(--transition-base);
    min-width: 180px;
}

.relation-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Responsive */
@media (max-width: 968px) {
    .form-row-triple {
        grid-template-columns: 1fr;
    }
    
    .form-checkboxes {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header-container {
        padding: 20px;
        flex-direction: column;
        text-align: center;
    }

    .title {
        font-size: 1.75rem;
    }

    .form-card {
        padding: 20px;
    }

    .users-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .section-title {
        justify-content: center;
    }
    
    .filter-buttons {
        justify-content: center;
    }
    
    .filter-btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }
}

/* Scroll personnalisé */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-hover);
}

/* Focus amélioré pour accessibilité */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}