/* Styles pour le panneau de statut des appareils */

/* Bouton toggle principal */
.device-status-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-status-toggle:hover {
    background: #1976d2;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.device-status-toggle.has-alerts {
    background: #f44336;
    animation: pulse-alert 2s infinite;
}

.device-status-toggle.has-alerts:hover {
    background: #d32f2f;
}

/* Badge de compteur sur le bouton */
.device-status-toggle[data-count]:after {
    content: attr(data-count);
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff5722;
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

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

/* Animation de rotation pour le mode chargement */
@keyframes spin-loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Bouton en mode chargement */
.device-status-toggle.loading {
    background: #ff9800;
    animation: spin-loading 1s linear infinite;
    font-size: 12px; /* Plus petit pour afficher les pourcentages */
    font-weight: bold;
}

.device-status-toggle.loading:hover {
    background: #f57c00;
}

/* Panneau principal - Style visites urgentes */
.device-status-panel {
    position: fixed;
    top: 120px;
    right: 20px;
    width: 200px; /* Plus compact comme visites urgentes */
    max-height: 400px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 999;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.device-status-panel.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
}

/* En-tête du panneau - Style visites urgentes */
.device-status-header {
    background: #ff5722; /* Orange comme les visites urgentes */
    color: white;
    padding: 8px 12px; /* Plus compact */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-status-header h3 {
    margin: 0;
    font-size: 13px; /* Plus petit */
    font-weight: 600;
}

.device-status-controls {
    display: flex;
    gap: 4px; /* Plus serré */
}

.device-status-controls button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 3px 5px; /* Plus petit */
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 11px; /* Plus petit */
}

.device-status-controls button:hover {
    background: rgba(255,255,255,0.3);
}

/* Filtres - Style compact */
.device-status-filters {
    display: none; /* On cache les filtres pour l'instant, trop d'espace */
}

/* Contenu du panneau - Style compact */
.device-status-content {
    max-height: 350px; /* Plus compact */
    overflow-y: auto;
    padding: 8px; /* Moins de padding */
}

/* États de chargement/vide */
.status-loading {
    text-align: center;
    padding: 15px;
    color: #666;
    animation: fadeIn 0.5s ease;
}

.loading-text {
    margin-bottom: 10px;
    font-size: 12px;
    color: #666;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196f3, #1976d2);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 10px;
    color: #666;
    font-weight: 500;
}

.status-empty {
    text-align: center;
    padding: 40px 20px;
    color: #4caf50;
    font-style: italic;
}

/* Liste des appareils - Style visites urgentes */
.device-list {
    display: flex;
    flex-direction: column; /* Vertical comme visites urgentes */
    gap: 1px; /* Espacement minimal */
}

/* Item d'appareil - Style visites urgentes */
.device-item-urgent {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    transition: background 0.2s ease;
    border-radius: 4px;
    font-size: 12px;
}

.device-info {
    display: flex;
    align-items: center;
    flex: 1;
    cursor: pointer;
}

.device-item-urgent:hover {
    background: rgba(0,0,0,0.05);
}

.device-item-urgent.pending_interv {
    background: #ffebee;
    border-left: 3px solid #f44336;
}

.device-item-urgent.stopped {
    background: #fff8e1;
    border-left: 3px solid #ff9800;
}

/* Styles pour la section Favoris */
.favorites-section {
    padding: 8px;
}

.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.favorites-header h4 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.add-favorite-btn {
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-favorite-btn:hover {
    background: #45a049;
    transform: scale(1.1);
}

.favorites-list {
    max-height: 300px;
    overflow-y: auto;
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    margin-bottom: 4px;
    border-radius: 6px;
    border-left: 3px solid #2196f3;
    background: #f8f9fa;
    transition: background 0.2s ease;
}

.favorite-item:hover {
    background: #e3f2fd;
}

.favorite-item.pending_interv {
    border-left-color: #f44336;
    background: #ffebee;
}

.favorite-item.stopped {
    border-left-color: #ff9800;
    background: #fff8e1;
}

.favorite-item.working {
    border-left-color: #4caf50;
    background: #e8f5e8;
}

.favorite-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.favorite-code {
    font-weight: bold;
    color: #333;
    font-size: 13px;
}

.favorite-status {
    font-size: 12px;
    color: #666;
}

.favorite-updated {
    font-size: 10px;
    color: #999;
    font-style: italic;
}

.remove-favorite-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-favorite-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

.add-favorite-form {
    display: flex;
    gap: 6px;
    padding: 12px;
    background: #f0f0f0;
    border-radius: 6px;
    margin-top: 8px;
    align-items: center;
}

.add-favorite-form input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    text-transform: uppercase;
}

.add-favorite-form button {
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.confirm-btn {
    background: #4caf50;
    color: white;
}

.confirm-btn:hover {
    background: #45a049;
}

.cancel-btn {
    background: #f44336;
    color: white;
}

.cancel-btn:hover {
    background: #d32f2f;
}

.no-favorites {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
    font-size: 12px;
}

.device-code-urgent {
    font-weight: 600;
    color: #333;
    min-width: 50px;
}

.device-status-urgent {
    font-size: 11px;
    color: #666;
    margin-left: auto;
}

.action-btn-compact:hover {
    background: #1976d2;
}

/* Item d'appareil */
.device-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 6px 8px; /* Réduit drastiquement le padding */
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.device-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.device-item.pending_interv {
    border-left: 4px solid #f44336;
    background: #ffebee;
}

.device-item.stopped {
    border-left: 4px solid #ff9800;
    background: #fff8e1;
}

/* En-tête de l'item */
.device-header {
    display: flex;
    align-items: center;
    margin-bottom: 0px;
    gap: 8px; /* Réduit l'espacement */
}

.device-code {
    font-weight: 600;
    font-size: 13px; /* Plus petit */
    color: #333;
    min-width: 50px; /* Plus compact */
}

.device-status {
    font-size: 11px; /* Plus petit */
    padding: 2px 6px; /* Padding réduit */
    border-radius: 8px;
    font-weight: 500;
    flex: 1;
}

.device-status.pending_interv {
    background: #f44336;
    color: white;
}

.device-status.stopped {
    background: #ff9800;
    color: white;
}

/* Détails de l'appareil */
.device-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.device-info {
    display: flex;
    font-size: 12px;
}

.device-label {
    color: #666;
    min-width: 100px;
    font-weight: 500;
}

.device-value {
    color: #333;
    flex: 1;
}

/* Actions */
.device-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.action-btn {
    background: #2196f3;
    color: white;
    border: none;
    padding: 3px 8px; /* Bouton plus petit */
    border-radius: 4px;
    font-size: 10px; /* Plus petit */
    cursor: pointer;
    transition: background 0.2s ease;
}

.action-btn:hover {
    background: #1976d2;
}

/* Pied de page */
.device-status-footer {
    background: #f9f9f9;
    padding: 10px 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
}

/* Message d'erreur */
.error-message {
    text-align: center;
    padding: 20px;
    color: #f44336;
    background: #ffebee;
    border-radius: 8px;
    margin: 10px;
}

.error-message button {
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 10px;
}

.error-message button:hover {
    background: #d32f2f;
}

/* Scrollbar personnalisée */
.device-status-content::-webkit-scrollbar {
    width: 6px;
}

.device-status-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.device-status-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 6px;
}

.device-status-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive pour petits écrans */
@media (max-width: 480px) {
    .device-status-panel {
        width: calc(100vw - 40px);
        max-width: 400px;
        right: 20px;
    }
    
    .device-status-toggle {
        right: 15px;
        top: 15px;
    }
    
    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .device-info {
        flex-direction: column;
        gap: 2px;
    }
    
    .device-label {
        min-width: auto;
        font-size: 11px;
    }
}

/* Animation d'apparition */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Classe utilitaire pour les éléments cachés */
.hidden {
    display: none !important;
}
