/* Styles pour le module de monitoring détaillé */

.detailed-monitoring-module {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    min-height: 0;
    height: var(--available-height);
    max-height: var(--available-height);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
    border: none;
    box-shadow: none;
    gap: 0;
}

/* Header du module avec titre et boutons */
.module-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.15rem 0.5rem; /* Réduire le padding vertical */
    background: var(--bg-primary);
    border-bottom: 1px solid #e9ecef;
    min-height: 1.5rem; /* Réduire la hauteur minimale */
    gap: 8px;
    flex-wrap: nowrap;
}

.header-left-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.module-content-title {
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    margin: 0;
    white-space: nowrap;
    line-height: 1.1;
    flex-shrink: 0;
}

.target-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.target-selector-wrapper label {
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
    white-space: nowrap;
    line-height: 1.1;
}

.target-selector-detailed {
    min-width: 160px;
    padding: 0.063rem 0.25rem;
    border: 1px solid #ced4da;
    border-radius: 3px;
    background: white;
    color: #495057;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 1.375rem;
}

.target-selector-detailed:hover {
    border-color: #667eea;
}

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

.header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.module-content-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Groupe tous les boutons à droite sur une ligne */
.header-buttons,
.module-content-actions {
    display: contents;
}

.module-content-header .header-buttons button:not(.btn-back),
.module-content-header .module-content-actions button:not(.btn-back) {
    flex-shrink: 0;
    margin-left: 4px;
}

.btn-back {
    min-width: 70px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.125rem 0.375rem;
    font-size: 12px;
    height: 1.375rem;
}

/* Bouton engrenage compact */
.header-buttons button:not(.btn-back) {
    padding: 0.125rem 0.25rem;
    font-size: 12px;
    height: 1.375rem;
    min-width: 1.5rem;
}

.monitoring-content {
    flex: 0 0 auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.toem-container {
    position: relative; /* Pour permettre le positionnement absolu du sélecteur */
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
}

.monitoring-header {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.monitoring-header .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    min-width: auto;
    font-size: 1.2rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.monitoring-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.config-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0;
}

.config-item {
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: nowrap;
}

.config-label {
    font-weight: 600;
    color: var(--text-primary);
}

.config-value {
    color: var(--primary-color);
    margin-left: 0.25rem;
    font-weight: 700;
}

.monitoring-content {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    border: none;
    min-height: 0;
}

.toem-container {
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 0;
    padding: 0; /* Supprimer tout padding inutile */
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
}

.loading-container p {
    margin-top: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.error-container {
    text-align: center;
    padding: 3rem;
    color: var(--text-primary);
}

.error-container h3 {
    color: var(--error-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.error-container p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.error-details {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    color: var(--error-color);
}

/* Adaptations pour l'intégration TOEM */
.detailed-monitoring-module .main-vbox {
    min-height: 0;
    height: fit-content;
}

.detailed-monitoring-module .main-anchor {
    overflow: visible;
    min-height: 0;
}

.detailed-monitoring-module .tab-content {
    overflow: visible;
    min-height: 0;
}

.detailed-monitoring-module .tab-panel {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 1200px) {
    .config-display {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.75rem;
    }
}

/* Tablette 1009x706 - Optimisation pour visualisation sans scrolling */
@media (max-width: 1100px) and (max-height: 800px) {
    .detailed-monitoring-module {
        height: 100%;
        max-height: var(--available-height);
        overflow: hidden;
    }
    
    .module-content-header {
        padding: 0.25rem 0.5rem;
        min-height: 1.75rem;
        flex-shrink: 0;
    }
    
    .module-content-title {
        font-size: 12px;
    }
    
    .target-selector-detailed {
        min-width: 100px;
        font-size: 11px;
        height: 1.25rem;
        padding: 0.063rem 0.25rem;
    }
    
    .btn-back,
    .header-buttons button:not(.btn-back) {
        font-size: 11px;
        height: 1.25rem;
        padding: 0.125rem 0.375rem;
    }
    
    .monitoring-header {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .monitoring-header h2 {
        font-size: 1.1rem;
    }
    
    .config-display {
        gap: 0.4rem;
        margin-top: 0.3rem;
    }
    
    .config-item {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .monitoring-content {
        flex: 1;
        overflow: hidden;
        max-height: calc(100vh - 8rem);
    }
    
    .toem-container {
        padding: 0.25rem 0.5rem;
        overflow: hidden;
        height: 100%;
    }
    
    /* Optimiser l'affichage TOEM pour la visualisation */
    #toem-monitoring-container {
        max-height: var(--available-height);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Réduire les marges et paddings des sections */
    .toem-container > * {
        margin-bottom: 0.5rem !important;
    }
    
    .toem-container h3,
    .toem-container h4 {
        font-size: 0.9rem !important;
        margin-bottom: 0.3rem !important;
    }
    
    /* Compacter les boutons d'action */
    .toem-container button {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem !important;
        height: auto !important;
    }
    
    /* Optimiser la grille de cibles */
    .targets-grid {
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    
    /* Réduire la taille des cercles de cibles */
    .detailed-monitoring-module .target-circle,
    .detailed-monitoring-module .toem-target {
        transform: scale(0.85) !important;
    }
}

/* Tablettes en mode portrait uniquement - largeur max 900px */
@media (max-width: 900px) {
    .detailed-monitoring-module {
        padding: 0;
    }
    
    .module-content-header {
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
        padding: 0.188rem 0.375rem;
        min-height: 1.5rem;
        overflow: hidden;
    }
    
    .header-left-section {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }
    
    .target-selector-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 3px;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .target-selector-detailed {
        width: auto;
        min-width: 80px;
        max-width: 120px;
        height: 20px;
        font-size: 11px;
        padding: 1px 3px;
        flex-shrink: 1;
    }
    
    .module-content-title {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
        flex-shrink: 1;
    }
    
    .target-selector-wrapper label {
        font-size: 11px;
        flex-shrink: 0;
    }
    
    .btn-back {
        font-size: 11px;
        min-width: 50px;
        height: 20px;
        padding: 1px 3px;
        flex-shrink: 0;
    }
    
    .header-buttons button:not(.btn-back) {
        font-size: 11px;
        height: 20px;
        min-width: 18px;
        padding: 1px 2px;
        flex-shrink: 0;
    }
}

/* Mobile portrait et très petits écrans - Header ultra-compact */
@media (max-width: 600px) {
    .module-content-header {
        padding: 0.125rem 0.25rem;
        min-height: 1.375rem;
        gap: 4px;
    }
    
    .module-content-title {
        font-size: 11px;
        max-width: none !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }
    
    .target-selector-wrapper label {
        font-size: 10px;
        min-width: 30px;
    }
    
    .target-selector-detailed {
        font-size: 10px;
        height: 18px;
        min-width: 60px;
        max-width: 80px;
        padding: 0 2px;
    }
    
    .btn-back {
        font-size: 10px;
        min-width: 40px;
        height: 18px;
        padding: 1px 3px;
    }
    
    .header-buttons button:not(.btn-back) {
        font-size: 10px;
        height: 18px;
        min-width: 16px;
        padding: 0 1px;
    }

    .monitoring-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .monitoring-header .section-header {
        flex-direction: row;
        gap: 1rem;
        align-items: center;
    }
    
    .monitoring-header h2 {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .config-display {
        grid-template-columns: 1fr;
    }
    
    .config-item {
        text-align: center;
        padding: 0.5rem 0.75rem;
    }
    
    .monitoring-content {
        padding: 0.5rem;
    }
}

@media (max-width: 600px) {
    .monitoring-header {
        padding: 0.5rem;
    }
    
    .monitoring-header h2 {
        font-size: 1rem;
    }
    
    .config-item {
        font-size: 0.7rem;
        padding: 0.3rem;
    }
    
    .module-content-header {
        padding: 0.125rem 0.25rem;
        min-height: 20px;
        gap: 3px;
        flex-wrap: nowrap;
        overflow: hidden;
    }
    
    .header-left-section {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        min-width: 0;
        flex-shrink: 1;
    }
    
    .target-selector-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 2px;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .target-selector-wrapper label {
        flex-shrink: 0;
        min-width: 30px;
        font-size: 10px;
    }
    
    .module-content-title {
        font-size: 11px;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        flex-shrink: 1;
    }
    
    .target-selector-detailed {
        min-width: 60px;
        max-width: 80px;
        font-size: 10px;
        height: 18px;
        flex-shrink: 1;
    }
    
    .btn-back {
        font-size: 10px;
        min-width: 40px;
        height: 18px;
        padding: 1px 2px;
        flex-shrink: 0;
    }
    
    .header-buttons button:not(.btn-back) {
        font-size: 10px;
        height: 18px;
        min-width: 16px;
        padding: 1px;
        flex-shrink: 0;
    }
    
    .target-selector-detailed {
        font-size: 10px;
        height: 18px;
        min-width: 80px;
        max-width: 120px;
    }
    
    .btn-back {
        font-size: 10px;
        min-width: 50px;
        height: 18px;
    }
    
    .header-buttons button:not(.btn-back) {
        font-size: 10px;
        height: 18px;
        min-width: 18px;
    }
}

/* Mode ultra-compact pour écrans très étroits */
@media (max-width: 360px) {
    .module-content-header {
        padding: 1px 2px;
        min-height: 18px;
        gap: 2px;
        flex-wrap: nowrap;
        overflow: hidden;
    }
    
    .header-left-section {
        gap: 2px;
        min-width: 0;
        flex-shrink: 1;
    }
    
    .module-content-title {
        font-size: 9px;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: none !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        flex-shrink: 1;
    }
    
    .target-selector-wrapper {
        gap: 1px;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .target-selector-wrapper label {
        font-size: 9px;
        min-width: 25px;
        flex-shrink: 0;
    }
    
    .target-selector-detailed {
        font-size: 9px;
        height: 16px;
        min-width: 50px;
        max-width: 60px;
        padding: 0 1px;
        flex-shrink: 1;
    }
    
    .btn-back {
        font-size: 9px;
        min-width: 30px;
        height: 16px;
        padding: 0 1px;
        flex-shrink: 0;
    }
    
    .header-buttons button:not(.btn-back) {
        font-size: 9px;
        height: 16px;
        min-width: 14px;
        padding: 0;
        flex-shrink: 0;
    }
}

/* Styles pour le modal de configuration */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.config-section {
    margin-bottom: 2rem;
}

.config-section:last-child {
    margin-bottom: 0;
}

.config-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.config-row {
    margin-bottom: 1.5rem;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-row label {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.input-group input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.input-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.input-group input[type="number"] {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    text-align: center;
}

.input-group .icon {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.target-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

#target-preview-canvas {
    border-radius: var(--border-radius);
    background: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Responsive pour le modal - mobile uniquement */
@media (max-width: 600px) {
    .modal {
        align-items: flex-start !important;
        padding: 0.5rem 0;
        overflow-y: auto;
    }
    
    .modal-content {
        width: 95%;
        max-height: none;
        margin: 0.5rem auto;
    }
    
    .modal-header {
        padding: 0.75rem;
    }
    
    .modal-header h3 {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 0.75rem;
    }
    
    .modal-footer {
        padding: 0.75rem;
        flex-direction: row;
        gap: 1rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Réduire tous les espacements */
    .config-section {
        margin-bottom: 1rem;
    }
    
    .config-section h4 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.3rem;
    }
    
    .input-group {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .input-group label {
        font-size: 0.85rem;
    }
    
    .input-group input[type="number"],
    .input-group input[type="range"] {
        width: 100%;
    }
    
    /* RÉDUIRE DRASTIQUEMENT la prévisualisation de la cible sur mobile */
    #target-preview-canvas {
        max-width: 150px !important;
        max-height: 150px !important;
        width: 150px !important;
        height: 150px !important;
    }
    
    .config-section:has(#target-preview-canvas) {
        text-align: center;
    }
}

/* ========================================
   MODE SOMBRE - MONITORING DÉTAILLÉ
   ======================================== */

body.dark-mode .detailed-monitoring-module {
    background: #1A1A1A !important;
    border-color: #444 !important;
}

/* Header du monitoring - MODE SOMBRE */
body.dark-mode .module-content-header {
    background: #1A1A1A !important;
    border-bottom: none !important;
}

body.dark-mode .module-content-title {
    color: #D0D0D0 !important;
}

body.dark-mode .target-selector-wrapper label {
    color: #b0b0b0;
}

body.dark-mode .target-selector-detailed {
    background: #1a1a1a;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode .target-selector-detailed:hover,
body.dark-mode .target-selector-detailed:focus {
    border-color: #667eea;
}

body.dark-mode .header-buttons {
    background: transparent !important;
}

body.dark-mode .monitoring-header,
body.dark-mode .monitoring-header.section-header,
body.dark-mode div.monitoring-header {
    background: #242424 !important;
    background-color: #242424 !important;
    border-color: #333333 !important;
}

body.dark-mode .monitoring-header *,
body.dark-mode .section-header * {
    background-color: transparent !important;
}

body.dark-mode .monitoring-header h2,
body.dark-mode .monitoring-header .section-header h2 {
    color: #D0D0D0 !important;
}

body.dark-mode .monitoring-header .section-header {
    background: transparent !important;
}

body.dark-mode .header-actions {
    background: transparent !important;
}

body.dark-mode .btn-icon {
    background: #2D2D2D !important;
    color: #C5C5C5 !important;
    border-color: #404040 !important;
}

body.dark-mode .btn-icon:hover {
    background: #9ACD32 !important;
    color: #1A1A1A !important;
    border-color: #9ACD32 !important;
}

/* Configuration display */
body.dark-mode .config-item {
    background: #2D2D2D !important;
    border-color: #404040 !important;
}

body.dark-mode .config-label {
    color: #C5C5C5 !important;
}

body.dark-mode .config-value {
    color: #9ACD32 !important;
}

/* Contenu principal */
body.dark-mode .monitoring-content {
    background: #242424 !important;
    border-color: #333333 !important;
}

body.dark-mode .toem-container {
    background: #2D2D2D !important;
}

/* Redéfinir les variables CSS pour ce module en mode sombre */
body.dark-mode .detailed-monitoring-module {
    --bg-primary: #242424;
    --bg-secondary: #1A1A1A;
    --text-primary: #D0D0D0;
    --text-secondary: #A0A0A0;
    --border-color: #333333;
    --primary-color: #9ACD32;
    --accent-color: #9ACD32;
}

/* Forcer tous les éléments avec les vraies classes */
body.dark-mode .detailed-monitoring-module * {
    scrollbar-color: #404040 #1A1A1A;
}

