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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Pages */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Page de Login */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container h1 {
    color: white;
    font-size: 2.5em;
    margin-bottom: 2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.login-form {
    background: white;
    padding: 3rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form input, .login-form select {
    padding: 1rem;
    border: 2px solid #e1e5e9;
    border-radius: 50px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.login-form input:focus, .login-form select:focus {
    outline: none;
    border-color: #667eea;
}

.login-form select:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
}

.login-form button {
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.login-form button:hover {
    background: #5a6fd8;
}

.mode-toggle {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.mode-toggle .checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 500;
    color: #2c3e50;
}

.mode-toggle input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.login-memory {
    margin-top: 1rem;
    text-align: center;
}

.login-memory small {
    color: #666;
    font-style: italic;
}

.recent-connections {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f0f7ff;
    border: 1px solid #d1e7ff;
    border-radius: 8px;
}

.recent-connections label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.recent-connections select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.recent-connections small {
    color: #666;
    font-style: italic;
}

/* Modale d'affichage du mot de passe */
.password-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.password-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    padding: 1rem;
    color: #856404;
}

.password-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.password-info label {
    font-weight: 600;
    color: #2c3e50;
}

.password-value {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.password-value input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #e74c3c;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    background: #fdf2f2;
    color: #2c3e50;
}

.password-value button {
    padding: 0.75rem 1rem;
}

/* Header principal */
.main-header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.user-info {
    font-size: 0.9rem;
    opacity: 0.8;
}

.header-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-right button {
    padding: 0.5rem 1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.header-right button:hover {
    background: #2980b9;
}

.settings-btn {
    background: none !important;
    font-size: 1.2rem;
    padding: 0.5rem !important;
}

/* Fil d'Ariane */
.breadcrumb {
    background: #ecf0f1;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid #ddd;
    font-size: 0.9rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb-item {
    color: #667eea;
    cursor: pointer;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    transition: all 0.3s;
}

.breadcrumb-item:hover {
    background: #667eea;
    color: white;
}

.breadcrumb-item.active {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.breadcrumb-separator {
    color: #999;
    font-weight: bold;
}

/* Container des colonnes */
.columns-container {
    display: flex;
    height: calc(100vh - 120px);
    overflow-x: auto;
}

/* Colonnes */
.column {
    min-width: 300px;
    width: 300px;
    background: white;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.column.reduced {
    width: 200px;
    min-width: 200px;
}

.column.hidden {
    display: none;
}

.column-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #ddd;
}

.column-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.column-header h3 {
    margin: 0;
    color: #2c3e50;
}

.view-toggle-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.view-toggle-btn:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

.column-footer {
    padding: 1rem;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.add-button-column {
    width: 100%;
    padding: 0.75rem;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s;
}

.add-button-column:hover {
    background: #45a049;
}

.search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.column-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* Items dans les colonnes */
.client-item, .societe-item, .user-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.client-item:hover, .societe-item:hover, .user-item:hover {
    background: #f8f9fa;
}

.client-item.selected, .societe-item.selected, .user-item.selected {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

/* Vue compacte */
.client-item.compact, .societe-item.compact, .user-item.compact {
    padding: 0.5rem 1rem;
}

.client-item.compact .item-details,
.societe-item.compact .item-details,
.user-item.compact .item-details {
    display: none;
}

.client-item.compact .item-subtitle,
.societe-item.compact .item-subtitle,
.user-item.compact .item-subtitle {
    font-size: 0.7rem;
    opacity: 0.7;
}

.item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-subtitle {
    font-size: 0.85rem;
    color: #666;
}

.item-details {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
}

/* Note: Anciens boutons d'ajout supprimés - maintenant dans .add-button-column */

/* Modales */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

/* Mode Selection */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.mode-selection label {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
    padding: 1rem;
    border: 2px solid #eee;
    border-radius: 10px;
    transition: all 0.3s;
}

.mode-selection label:hover {
    border-color: #667eea;
}

.mode-selection input[type="radio"]:checked + .mode-option {
    color: #667eea;
}

.mode-selection label:has(input:checked) {
    border-color: #667eea;
    background: #f8f9ff;
}

.mode-option strong {
    display: block;
    margin-bottom: 0.25rem;
}

.mode-option p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

/* Formulaires */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

form input, form select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

form button {
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

form button:hover {
    background: #5a6fd8;
}

/* Sections des formulaires */
.profile-fields, .roles-section {
    border: 1px solid #eee;
    border-radius: 5px;
    padding: 1rem;
    margin: 0.5rem 0;
}

.profile-fields h4, .roles-section h4 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.profile-field, .role-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.profile-field input[type="checkbox"], .role-item input[type="checkbox"] {
    width: auto;
}

.profile-field label, .role-item label {
    margin: 0;
    flex: 1;
}

/* Test Users */
.test-users {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.test-user-btn {
    padding: 1rem !important;
    background: #f8f9fa !important;
    border: 1px solid #ddd !important;
    border-radius: 5px !important;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
}

.test-user-btn:hover {
    background: #e9ecef !important;
    border-color: #667eea !important;
}

.test-user-btn strong {
    font-size: 1.1rem;
    color: #2c3e50;
}

.test-user-btn span {
    color: #666;
    font-size: 0.9rem;
}

.test-user-btn small {
    color: #888;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .columns-container {
        flex-direction: column;
        height: auto;
    }
    
    .column {
        min-width: 100%;
        width: 100%;
        height: 400px;
    }
    
    .header-right {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .login-form {
        width: 90%;
        padding: 2rem;
    }
}

/* États de chargement */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.loading:after {
    content: "...";
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: black;
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:
            .25em 0 0 black,
            .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow:
            .25em 0 0 black,
            .5em 0 0 black;
    }
}

/* Formulaires améliorés */
.modal-content.large {
    max-width: 800px;
    width: 95%;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.form-group small {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.btn-primary {
    background: #667eea !important;
    color: white !important;
    border: none !important;
}

.btn-primary:hover {
    background: #5a6fd8 !important;
}

.btn-secondary {
    background: #f8f9fa !important;
    color: #495057 !important;
    border: 1px solid #ddd !important;
}

.btn-secondary:hover {
    background: #e9ecef !important;
}

.btn-cancel {
    background: #6c757d !important;
    color: white !important;
    border: none !important;
}

.btn-cancel:hover {
    background: #5a6268 !important;
}

.btn-danger {
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
}

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

/* Sections de description */
.section-description {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.type-description {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 3px;
    border-left: 3px solid #667eea;
}

/* Grilles de checkboxes et rôles */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    cursor: pointer;
    margin: 0 !important;
}

.checkbox-item input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
}

.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.roles-assignment {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

/* Modales de détails */
.details-content {
    max-height: 60vh;
    overflow-y: auto;
}

.details-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.details-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.details-section h4 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.detail-item span, .detail-item p {
    color: #333;
    font-size: 1rem;
}

/* Badges de statut */
.status-badge {
    display: inline-block !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 12px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    margin-left: 0.5rem !important;
}

.status-badge.verified {
    background: #d4edda;
    color: #155724;
}

.status-badge.unverified {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.enabled {
    background: #cce5ff;
    color: #004085;
}

.status-badge.disabled {
    background: #e2e3e5;
    color: #383d41;
}

.status-badge.active {
    background: #d1ecf1;
    color: #0c5460;
}

.status-badge.inactive {
    background: #f5c6cb;
    color: #721c24;
}

/* Badges de rôles */
.roles-badges {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
}

.role-badge {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Configuration des profils */
.profile-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.profile-config-item {
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.profile-config-item.required {
    border-left-color: #28a745;
}

.profile-config-item.optional {
    border-left-color: #ffc107;
}

/* Configuration des rôles */
.roles-config {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.role-config-item {
    background: #667eea;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Historique des connexions */
.connection-history {
    max-height: 300px;
    overflow-y: auto;
}

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.connection-item:last-child {
    border-bottom: none;
}

.connection-time {
    color: #666;
}

.connection-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.connection-method {
    font-weight: 600;
    color: #2c3e50;
}

.connection-details {
    color: #666;
    font-size: 0.8rem;
}

/* Actions sur les items */
.item-actions {
    display: none;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.client-item:hover .item-actions,
.societe-item:hover .item-actions,
.user-item:hover .item-actions {
    display: flex;
}

.action-btn {
    padding: 0.2rem 0.4rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.2s;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn.edit {
    background: #ffc107;
    color: #212529;
}

.action-btn.delete {
    background: #dc3545;
    color: white;
}

.action-btn.view {
    background: #17a2b8;
    color: white;
}

.action-btn:hover {
    opacity: 0.8;
    transform: scale(1.05);
}