/**
 * Styles pour la gestion des appareils autorisés
 * Date: 2025-08-16
 */

/* ===== ÉTAT "AUCUN APPAREIL" ===== */
.no-devices {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
    border: 2px dashed #dee2e6;
}

.no-devices-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.7;
}

.no-devices h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.no-devices p {
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.6;
}

.no-devices-steps {
    text-align: left;
    max-width: 400px;
    margin: 20px auto;
    padding: 0;
    list-style: none;
}

.no-devices-steps li {
    color: #6c757d;
    margin-bottom: 8px;
    padding: 8px 0;
    border-left: 3px solid #007bff;
    padding-left: 15px;
    background: rgba(0, 123, 255, 0.05);
    border-radius: 0 4px 4px 0;
}

.no-devices-steps li:last-child {
    margin-bottom: 0;
}

.no-devices .btn {
    margin-top: 20px;
    padding: 12px 24px;
    font-size: 1.1rem;
}

/* Message "aucun résultat" pour les filtres */
.no-results {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-radius: 15px;
    border: 2px solid #ffc107;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.1);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.no-results h3 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.no-results p {
    color: #856404;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.5;
}

.no-results .btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.no-results .btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #343a40 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

/* Styles pour le bouton de pointage avec statut du device */
.pointage-button.device-authorized {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: #28a745;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.pointage-button.device-authorized:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.pointage-button.device-not-authorized {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    border-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.pointage-button.device-not-authorized:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pointage-button.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Indicateur de statut du device */
.device-status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    animation: fadeIn 0.3s ease-in;
}

.device-status-indicator.authorized {
    background: rgba(40, 167, 69, 0.9);
    color: white;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
}

.device-status-indicator.not-authorized {
    background: rgba(220, 53, 69, 0.9);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== MODAL D'AJOUT D'APPAREIL ===== */
.add-device-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.add-device-modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
    position: relative;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header .close-modal {
    position: absolute;
    top: 20px;
    right: 25px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-header .close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
}

/* ===== FORMULAIRE D'AJOUT ===== */
.add-device-form {
    display: grid;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label i {
    color: #6b7280;
    width: 16px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.form-group .help-text {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
}

.form-group .error-message {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 4px;
    display: none;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: #dc2626;
    background: #fef2f2;
}

.form-group.has-error .error-message {
    display: block;
}

/* ===== BOUTONS D'ACTION ===== */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* ===== SECTION GESTION DES APPAREILS ===== */
.devices-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin: 20px 0;
    overflow: hidden;
}

.devices-section-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
}

.devices-section-header h3 {
    margin: 0 0 10px 0;
    color: #1e293b;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.devices-section-header p {
    margin: 0;
    color: #64748b;
    font-size: 0.9rem;
}

.devices-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.device-search {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.device-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.device-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.device-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.device-filters {
    display: flex;
    gap: 10px;
    align-items: center;
}

.device-filter {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    color: #374151;
}

.device-filter:focus {
    outline: none;
    border-color: #667eea;
}

/* ===== LISTE DES APPAREILS ===== */
.devices-content {
    padding: 25px;
}

.no-devices {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.no-devices-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-devices h3 {
    margin: 0 0 10px 0;
    color: #374151;
    font-size: 1.2rem;
}

.no-devices p {
    margin: 0 0 20px 0;
    color: #6b7280;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

/* ===== CARTES D'APPAREILS ===== */
.device-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.device-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

.device-card.active {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.device-card.inactive {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fef2f2 100%);
    opacity: 0.8;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.device-type-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.active {
    background: #10b981;
}

.status-indicator.inactive {
    background: #ef4444;
}

.device-info {
    margin-bottom: 20px;
}

.device-name {
    margin: 0 0 10px 0;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.device-identifier {
    margin-bottom: 12px;
}

.device-identifier code {
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #374151;
    font-family: 'Courier New', monospace;
}

.device-type,
.device-location {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.device-assignment {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #059669;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    background: #d1fae5;
    border-radius: 6px;
    margin-top: 10px;
}

.device-assignment.shared {
    color: #7c3aed;
    background: #e0e7ff;
}

.device-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

.stat-value.success {
    color: #059669;
}

.stat-value.warning {
    color: #d97706;
}

.stat-value.danger {
    color: #dc2626;
}

/* Styles pour les filtres */
.device-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.device-filter {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    min-width: 150px;
    cursor: pointer;
    font-family: inherit;
}

.device-filter:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.device-filter:hover {
    border-color: #007bff;
    background-color: #f8f9fa;
}

.device-filter option {
    padding: 8px;
    font-size: 0.9rem;
}

/* Styles pour les boutons d'action */
.device-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.device-actions .btn {
    flex: 1;
    min-width: 120px;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    justify-content: center;
}

.device-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.device-actions .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Bouton Activer/Désactiver - Vert */
.device-actions .btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    color: white;
}

.device-actions .btn-success:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Bouton Supprimer - Rouge */
.device-actions .btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    border: none;
    color: white;
}

.device-actions .btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #c0392b 100%);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* Animation d'apparition des boutons */
.device-actions .btn {
    animation: buttonSlideIn 0.4s ease-out;
}

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

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    .devices-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .device-search {
        min-width: auto;
    }
    
    .device-filters {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .device-stats {
        grid-template-columns: 1fr;
    }
    
    .device-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .modal-body {
        padding: 20px;
    }
    
    .devices-content {
        padding: 20px;
    }
    
    .device-card {
        padding: 15px;
    }
}

/* ===== ANIMATIONS ===== */
.device-card {
    animation: cardFadeIn 0.5s ease-out;
}

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

.device-card:nth-child(1) { animation-delay: 0.1s; }
.device-card:nth-child(2) { animation-delay: 0.2s; }
.device-card:nth-child(3) { animation-delay: 0.3s; }
.device-card:nth-child(4) { animation-delay: 0.4s; }
.device-card:nth-child(5) { animation-delay: 0.5s; }

/* ===== ÉTATS DE CHARGEMENT ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== SYSTÈME DE NOTIFICATIONS MODERNE ===== */
.device-notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 450px;
    pointer-events: none;
}

.device-notification {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-left: 4px solid;
    overflow: hidden;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    max-width: 100%;
}

.device-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.device-notification-success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.device-notification-error {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fef2f2 100%);
}

.device-notification-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.device-notification-info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    position: relative;
}

.notification-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-message {
    flex: 1;
    color: #1f2937;
    font-size: 0.9rem;
    line-height: 1.4;
    font-weight: 500;
}

.device-notification-error .notification-message {
    color: #991b1b;
}

.device-notification-success .notification-message {
    color: #065f46;
}

.device-notification-warning .notification-message {
    color: #92400e;
}

.device-notification-info .notification-message {
    color: #1e40af;
}

.notification-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #374151;
}

/* Notifications avec liste */
.device-notification-list .notification-message ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    list-style-type: disc;
}

.device-notification-list .notification-message li {
    margin: 4px 0;
    font-size: 0.85rem;
}

/* Animations */
@keyframes notificationSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes notificationSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .device-notifications-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .device-notification {
        max-width: 100%;
    }
}

/* ===== TOOLTIPS ===== */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* ===== SCROLLBAR PERSONNALISÉE ===== */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
