/* ===========================
   MODULE SYSTÈME - STYLES CSS
   =========================== */

/* Container principal du module système */
.system-module {
    background: var(--card-background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 0;
    margin: 10px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Optimisation générale de l'espace */
.module-content {
    padding: 0;
    max-width: 100%;
}

/* Header compact - utilise le même style que detailed-monitoring */
.system-module .module-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    min-height: 44px;
    gap: 12px;
    flex-wrap: nowrap;
}

.system-module .header-left-section {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    flex-wrap: nowrap;
    min-width: 0;
}

.system-module .module-content-title {
    font-size: 16px;
    font-weight: 500;
    color: #495057;
    margin: 0;
    white-space: nowrap;
}

.system-module .target-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.system-module .target-selector-wrapper label {
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    white-space: nowrap;
}

.system-module .btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
    white-space: nowrap;
}

#systemStatus {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Navigation par onglets */
.system-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    background: var(--secondary-background);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    padding: 0 4px;
}

.system-tab {
    flex: 0 0 auto;
    padding: 8px 12px;
    background: none;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: auto;
}

.system-tab:hover {
    background: var(--hover-background);
    color: var(--text-primary);
}

.system-tab.active {
    background: var(--card-background);
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    transform: translateY(1px);
}

/* Contenu des onglets */
.system-tab-content {
    display: none;
    padding: 0.5rem 1rem;
    min-height: 0;
    animation: fadeIn 0.3s ease;
}

.system-tab-content.active {
    display: block;
}

.system-tab-content h3 {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 6px;
}

@media (min-width: 768px) {
    .system-tab-content {
        padding: 0.75rem 1.25rem;
    }
}

@media (max-width: 760px) {
    .system-module .module-content-header {
        flex-wrap: nowrap;
        padding: 6px 12px;
        gap: 8px;
    }

    .system-module .header-left-section {
        width: auto;
        flex: 1;
        flex-wrap: nowrap;
        gap: 8px;
        min-width: 0;
    }

    .system-module .target-selector-wrapper {
        flex: 1;
        min-width: 0;
    }

    .system-module .target-selector-wrapper select {
        flex: 1;
        min-width: 0;
    }

    .system-tabs {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 6px;
        padding: 6px;
    }

    .system-tab {
        padding: 8px 4px;
        font-size: 0.8rem;
        border-right: none;
        border-radius: 6px;
        border: 1px solid transparent;
        text-align: center;
    }

    .system-tab:not(.active) {
        background: rgba(255, 255, 255, 0.6);
        border-color: var(--border-color);
        color: #222;
    }

    body.dark-mode .system-tab:not(.active) {
        background: rgba(255, 255, 255, 0.08);
        border-color: #404040;
        color: #C5C5C5;
    }

    body.dark-mode .system-tab.active {
        background: #2D2D2D;
        color: #9ACD32;
    }

    .system-tab.active {
        border-bottom: none;
        box-shadow: 0 0 0 1px var(--primary-color);
    }
}

@media (max-width: 480px) {
    .system-module .module-content-header {
        padding: 4px 8px;
    }

    .system-module .module-content-title {
        font-size: 14px;
    }

    .system-module .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .system-tabs {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 4px;
    }

    .system-tab {
        padding: 6px 2px;
        font-size: 0.75rem;
    }
}

@media (min-width: 1200px) {
    .system-tab-content {
        padding: 1rem 1.5rem;
        min-height: 0;
    }
}

/* Règle spécifique pour l'onglet monitoring - même chaîne de hauteur que la vue cible */
#system-tab-monitoring {
    padding: 0;
    overflow: hidden;
    max-height: none;
    height: 100%;
}

#system-tab-monitoring.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#system-tab-monitoring #system-monitoring-module {
    flex: 1 1 auto !important;
    height: 100% !important;
    overflow: hidden !important;
    min-height: 0 !important;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

#system-tab-monitoring #zoom-cible-svg {
    max-height: none !important;
    height: 100% !important;
    display: block !important;
}

#system-tab-monitoring #zoom-cible-svg svg {
    max-height: none !important;
    height: 100% !important;
    display: block !important;
}

/* Tables de registres */
.register-table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.register-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-background);
    font-size: 0.9rem;
}

.register-table th {
    background: var(--secondary-background);
    color: var(--text-primary);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.register-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s;
}

.register-table tr:hover {
    background: var(--hover-background);
}

.field-name {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 200px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.field-value {
    font-family: 'Courier New', monospace;
    font-weight: 500;
    text-align: center;
    min-width: 80px;
}

.field-desc {
    color: var(--text-secondary);
    font-style: italic;
}

.enum-desc {
    color: var(--success-color);
    font-weight: 600;
    font-style: normal;
}

/* Tables spécialisées */
.adc-table .field-value,
.pdval-table .field-value {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    min-width: 50px;
    padding: 6px 8px;
}

.adc-cell,
.pdval-cell {
    transition: all 0.2s ease;
    cursor: help;
}

.adc-cell:hover,
.pdval-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    z-index: 5;
    position: relative;
}

/* Table ADC - Optimisée pour la compacité */
.adc-table {
    font-size: 0.75rem;
    table-layout: auto;
    width: 100%;
}

.adc-table th {
    padding: 6px 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.adc-table td {
    padding: 6px 8px;
    text-align: center;
    font-size: 0.75rem;
}

.adc-table th:first-child,
.adc-table td:first-child {
    width: 60px;
    min-width: 60px;
    font-weight: bold;
}

/* Table PD_VAL spécialisée - tailles identiques à ADC */
.pdval-table {
    font-size: 0.75rem;
    table-layout: fixed;
    width: 100%;
}

.pdval-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.pdval-table th {
    padding: 6px 8px;
    text-align: center;
    font-size: 0.75rem;
    width: auto;
    font-weight: 600;
    position: sticky;
    background: var(--card-background, #fff);
    border-bottom: 1px solid var(--border-color, #ddd);
}

/* Première ligne d'en-tête (Index + Slave_1, Slave_2, ...) */
.pdval-table thead tr:first-child th {
    top: 0;
    z-index: 12;
}

/* Deuxième ligne d'en-tête (Col1, Col2, Col3, Col4 pour chaque slave) */
.pdval-table thead tr:nth-child(2) th {
    top: 28px;
    z-index: 11;
}

.pdval-table td {
    padding: 6px 8px;
    text-align: center;
    width: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
}

.pdval-table th:first-child,
.pdval-table td:first-child {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    font-weight: bold;
}

/* Info boxes */
.info-box {
    background: var(--secondary-background);
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 0 6px 6px 0;
}

.info-box h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 1rem;
}

.info-box p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Messages d'état */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    background: var(--secondary-background);
    border-radius: 8px;
    margin: 20px 0;
}

.no-data.error {
    background: var(--error-background);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.no-data p {
    margin: 10px 0;
    font-size: 0.95rem;
}

/* ===============================
   DIAGNOSTIC - VERSION ULTRA-COMPACTE (SANS SCROLL)
   =============================== */

.diagnostic-section {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 6px;
    border: 1px solid #dee2e6;
}

.diagnostic-section h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* GRILLE RESPONSIVE - BASE MOBILE FIRST */
.diagnostic-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 4px 0;
}

.diagnostic-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 6px 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.diagnostic-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    border-color: #007bff;
}

.diagnostic-card h4 {
    margin: 0 0 3px 0;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.diagnostic-card h5 {
    margin: 0 0 3px 0;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding-bottom: 2px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 3px;
}

.diagnostic-card p {
    margin: 1px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.05;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.diagnostic-card p strong {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.diagnostic-card p span {
    text-align: right;
    flex: 1;
}

/* Indicateurs de statut - ultra compacts */
.status-indicator {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    display: inline-block;
}

.status-indicator.ok {
    background: var(--success-background);
    color: var(--success-color);
}

.status-indicator.error {
    background: var(--error-background);
    color: var(--error-color);
}

.status-indicator.loading {
    background: var(--warning-background);
    color: var(--warning-color);
}

.status-indicator.warning {
    background: var(--warning-background);
    color: var(--warning-color);
}

/* Indicateurs de résultat */
.status-result {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    display: inline-block;
    min-width: 40px;
    text-align: center;
}

.status-result.success {
    background: var(--success-background);
    color: var(--success-color);
}

.status-result.error {
    background: var(--error-background);
    color: var(--error-color);
}

.status-result.loading {
    background: var(--info-background);
    color: var(--info-color);
}

/* Boutons de diagnostic - ultra compacts */
.diagnostic-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
    margin-top: 4px;
    width: 100%;
}

.diagnostic-btn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

.diagnostic-btn:active {
    transform: translateY(0);
}

/* ===============================
   RESPONSIVE - TABLETTE (600px+)
   =============================== */
@media (min-width: 600px) {
    .diagnostic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .diagnostic-section {
        padding: 8px 12px;
        margin-bottom: 10px;
    }
    
    .diagnostic-section h4 {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }
    
    .diagnostic-card {
        padding: 10px 12px;
    }
    
    .diagnostic-card h5 {
        font-size: 0.88rem;
        margin-bottom: 6px;
        padding-bottom: 4px;
    }
    
    .diagnostic-card p {
        font-size: 0.82rem;
        margin: 2px 0;
        line-height: 1.15;
    }
    
    .diagnostic-btn {
        font-size: 0.82rem;
        padding: 6px 12px;
    }
}

/* ===============================
   RESPONSIVE - PC (1024px+) - MODE ULTRA-COMPACT 5 COLONNES
   =============================== */
@media (min-width: 1024px) {
    .diagnostic-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        max-width: 1900px;
    }
    
    .diagnostic-section {
        padding: 4px 10px;
        margin-bottom: 6px;
    }
    
    .diagnostic-section h4 {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }
    
    .diagnostic-card {
        padding: 6px 8px;
    }
    
    .diagnostic-card h5 {
        font-size: 0.8rem;
        margin-bottom: 3px;
        padding-bottom: 2px;
    }
    
    .diagnostic-card p {
        font-size: 0.75rem;
        margin: 1px 0;
        line-height: 1.05;
    }
    
    .diagnostic-card p strong {
        font-size: 0.75rem;
    }
    
    .diagnostic-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
        margin-top: 3px;
    }
}

/* ===============================
   RESPONSIVE - GRAND ÉCRAN (1440px+) - 6 COLONNES
   =============================== */
@media (min-width: 1440px) {
    .diagnostic-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }
    
    .diagnostic-section {
        padding: 5px 12px;
        margin-bottom: 8px;
    }
    
    .diagnostic-card {
        padding: 7px 10px;
    }
    
    .diagnostic-card h5 {
        font-size: 0.82rem;
        margin-bottom: 4px;
    }
    
    .diagnostic-card p {
        font-size: 0.77rem;
        margin: 1px 0;
        line-height: 1.05;
    }
}

/* Configuration */
.config-section {
    background: var(--secondary-background);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

/* Note: Styles de diagnostic déjà définis ci-dessus avec responsive complet */

.diagnostic-card h5 {
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.diagnostic-btn {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    margin: 4px;
    transition: all 0.3s ease;
}

.diagnostic-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(23,162,184,0.3);
}

/* Styles pour les contrôles de lasers */
.laser-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.laser-global {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.laser-individual {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.laser-btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

.laser-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none !important;
}

.laser-global-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 15px 25px;
    min-width: 150px;
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.laser-global-btn.active {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 2px 6px rgba(40,167,69,0.4);
}

.laser-global-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.4);
}

.laser-global-btn.active:hover:not(:disabled) {
    box-shadow: 0 4px 8px rgba(40,167,69,0.5);
}

.laser-individual-btn {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
    padding: 8px 6px;
    min-height: 45px;
    box-shadow: 0 2px 4px rgba(108,117,125,0.3);
    font-size: 11px;
}

.laser-individual-btn.active {
    background: linear-gradient(135deg, #dc3545, #c82333);
    box-shadow: 0 2px 6px rgba(220,53,69,0.4);
}

.laser-individual-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(108,117,125,0.4);
}

.laser-individual-btn.active:hover:not(:disabled) {
    box-shadow: 0 3px 8px rgba(220,53,69,0.5);
}

.laser-icon {
    font-size: 16px;
    transition: all 0.3s ease;
}

.laser-text {
    font-size: 11px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.laser-btn.active .laser-icon {
    filter: brightness(1.2);
    transform: scale(1.1);
}

.laser-btn.active .laser-text {
    color: #fff;
}

/* Styles pour les contrôles de relais */
.relay-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.relay-individual {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.relay-status {
    text-align: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.relay-btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

.relay-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none !important;
}

.relay-individual-btn {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
    padding: 8px 6px;
    min-height: 45px;
    box-shadow: 0 2px 4px rgba(108,117,125,0.3);
    font-size: 11px;
}

.relay-individual-btn.active {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 2px 6px rgba(40,167,69,0.4);
}

.relay-individual-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(108,117,125,0.4);
}

.relay-individual-btn.active:hover:not(:disabled) {
    box-shadow: 0 3px 8px rgba(40,167,69,0.5);
}

.relay-icon {
    font-size: 16px;
    transition: all 0.3s ease;
}

.relay-text {
    font-size: 11px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.relay-btn.active .relay-icon {
    filter: brightness(1.2);
    transform: scale(1.1);
}

/* Styles pour les contrôles de palettes */
.shutter-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.shutter-individual {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.shutter-status {
    text-align: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.shutter-btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

.shutter-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none !important;
}

.shutter-individual-btn {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
    padding: 8px 6px;
    min-height: 45px;
    box-shadow: 0 2px 4px rgba(108,117,125,0.3);
    font-size: 11px;
}

.shutter-individual-btn.active {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #212529;
    box-shadow: 0 2px 6px rgba(255,193,7,0.4);
}

.shutter-individual-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(108,117,125,0.4);
}

.shutter-individual-btn.active:hover:not(:disabled) {
    box-shadow: 0 3px 8px rgba(255,193,7,0.5);
}

.shutter-icon {
    font-size: 16px;
    transition: all 0.3s ease;
}

.shutter-text {
    font-size: 11px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.shutter-btn.active .shutter-icon {
    filter: brightness(1.2);
    transform: scale(1.1);
}

/* Styles pour les boutons de dérogation */
.relay-override-btn,
.shutter-override-btn,
.laser-override-btn {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.relay-override-btn.active,
.shutter-override-btn.active,
.laser-override-btn.active {
    background: linear-gradient(135deg, #dc3545, #c82333);
    box-shadow: 0 2px 6px rgba(220,53,69,0.4);
}

.relay-override-btn:hover,
.shutter-override-btn:hover,
.laser-override-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(108,117,125,0.4);
}

.relay-override-btn.active:hover,
.shutter-override-btn.active:hover,
.laser-override-btn.active:hover {
    box-shadow: 0 3px 8px rgba(220,53,69,0.5);
}

.override-icon {
    font-size: 14px;
    transition: all 0.3s ease;
}

.override-text {
    font-size: 11px;
    font-weight: bold;
}

/* Améliorations du diagnostic grid */
.diagnostic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.diagnostic-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.diagnostic-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-color: #007bff;
}

/* ===============================
   CONFIGURATION - STYLES ULTRA-COMPACTS
   =============================== */

.programming-section {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 6px;
    border: 1px solid #dee2e6;
}

.programming-section h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.programming-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 4px 0;
    align-items: start;
}

.programming-card {
    background: white;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    padding: 6px 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.programming-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
}

/* Carte large qui s'étend sur toute la largeur */
.programming-card-wide {
    grid-column: 1 / -1;
}

.programming-card h5 {
    margin: 0 0 4px 0;
    color: #1a202c;
    font-size: 0.8rem;
    font-weight: 600;
    padding-bottom: 2px;
    border-bottom: 2px solid #d1d5db;
}

.programming-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.programming-form-group label {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.75rem;
}

.programming-form-group select,
.programming-form-group input {
    padding: 4px 6px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.75rem;
    background: white;
    color: #1f2937;
}

.programming-form-group select:focus,
.programming-form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.programming-btn {
    padding: 4px 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 3px;
    width: 100%;
}

.programming-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.programming-btn:disabled {
    background: var(--border-color);
    color: var(--muted-text);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Info box compacte */
.targets-info {
    margin: 4px 0;
    padding: 6px 10px;
    background: #dbeafe;
    border-radius: 6px;
    border-left: 4px solid #3b82f6;
    font-size: 0.7rem;
    color: #1e40af;
    font-weight: 600;
}

/* SVG Container compact */
.svg-container {
    width: 100%;
    height: 350px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    margin: 0;
}

/* Coordonnées compactes */
.coordinates-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.coordinates-pair {
    display: grid;
    grid-template-columns: 25px 1fr 1fr;
    gap: 4px;
    align-items: center;
}

.coordinates-label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.7rem;
}

.coordinates-pair input {
    padding: 3px 4px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 0.7rem;
}

/* Servo-moteurs compacts */
.servo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 8px;
}

.servo-pair {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px;
    align-items: center;
}

.servo-label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.7rem;
    white-space: nowrap;
}

.servo-pair input {
    padding: 3px 4px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 0.7rem;
    min-width: 0;
}

.servo-pair input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.servo-config-card .programming-form {
    gap: 5px;
}

/* Tablette : 1 colonne servo pour que les labels aient assez de place */
@media (min-width: 600px) and (max-width: 1279px) {
    .servo-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 599px) {
    .servo-grid {
        grid-template-columns: 1fr;
    }
}

/* Upload de fichier compact */
.file-input-wrapper {
    display: flex;
    gap: 4px;
    align-items: center;
}

.file-input-display {
    flex: 1;
    padding: 4px 6px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    font-size: 0.7rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-browse-btn {
    padding: 4px 8px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
}

.file-input-hidden {
    display: none;
}

/* ===============================
   RESPONSIVE - TABLETTE (600px+)
   =============================== */
@media (min-width: 600px) {
    .programming-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    
    .programming-section {
        padding: 5px 10px;
        margin-bottom: 8px;
    }
    
    .programming-card {
        padding: 7px 10px;
    }
    
    .programming-card h5 {
        font-size: 0.82rem;
        margin-bottom: 6px;
    }
    
    .svg-container {
        height: 250px;
    }
}

/* ===============================
   RESPONSIVE - PC (1024px+) - 3 COLONNES (tablette paysage)
   =============================== */
@media (min-width: 1024px) {
    .programming-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }
    
    .programming-section {
        padding: 6px 12px;
        margin-bottom: 8px;
    }
    
    .programming-card {
        padding: 8px 10px;
    }
    
    .programming-card h5 {
        font-size: 0.82rem;
        margin-bottom: 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .programming-form {
        gap: 8px;
    }
    
    .programming-form-group {
        gap: 3px;
    }
    
    .programming-btn {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
    
    .svg-container {
        height: 300px;
    }
}

/* ===============================
   RESPONSIVE - GRAND PC (1280px+) - 4 COLONNES
   =============================== */
@media (min-width: 1280px) {
    .programming-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
    }
}

/* ===============================
   RESPONSIVE - GRAND ÉCRAN (1440px+)
   =============================== */
@media (min-width: 1440px) {
    .programming-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
    }
    .programming-card h5 {
        white-space: normal;
    }
    
    .programming-section {
        padding: 8px 14px;
    }
    
    .programming-card {
        padding: 10px 12px;
    }
    
    .svg-container {
        height: 350px;
    }
}


/* Upload de fichier */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    background: var(--input-background);
}

.file-input-display {
    flex: 1;
    font-size: 0.9rem;
    color: var(--muted-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-browse-btn {
    padding: 4px 12px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
}

.file-browse-btn:hover {
    background: var(--secondary-hover);
}

.file-input-hidden {
    display: none;
}

/* États responsive améliorés */
@media (max-width: 1024px) {
    .diagnostic-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .system-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .system-controls select,
    .system-controls button {
        width: 100%;
        margin: 0;
    }
    
    /* DÉSACTIVÉ - Utilise display: grid pour responsive
    .system-tabs {
        flex-direction: column;
        gap: 0;
    }
    
    .system-tab {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        min-width: auto;
        padding: 12px;
        font-size: 0.9rem;
    }
    */
    
    .system-tab:last-child {
        border-bottom: none;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) {
        font-size: 0.8rem;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
        table-layout: fixed;
        width: 100%;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) thead,
    .register-table:not(.pdval-table):not(.adc-table) tbody,
    .register-table:not(.pdval-table):not(.adc-table) tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) th,
    .register-table:not(.pdval-table):not(.adc-table) td {
        padding: 8px 6px;
        word-wrap: break-word;
        white-space: normal;
    }
    
    /* Première colonne (Registre/Parameter) - plus large pour slaves/master/adc seulement */
    .register-table:not(.pdval-table):not(.adc-table) th:first-child {
        width: 40%;
        min-width: 120px;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) td:first-child {
        width: 40%;
        min-width: 120px;
    }
    
    /* Forcer la coupure des noms de variables longs sur tablette */
    .register-table .field-name {
        max-width: none;
        word-break: break-all;
        overflow-wrap: anywhere;
        font-size: 0.7rem;
        white-space: normal !important;
    }
    
    /* Colonnes numériques (slaves values) - largeur réduite */
    .register-table:not(.pdval-table) .field-value {
        max-width: 70px;
        min-width: 50px;
        text-align: center;
        font-size: 0.7rem;
    }
    
    .register-table:not(.pdval-table) th:not(:first-child) {
        max-width: 70px;
        min-width: 50px;
        text-align: center;
        font-size: 0.7rem;
    }
    
    .diagnostic-grid {
        grid-template-columns: 1fr;
    }
    
    .coordinates-pair {
        grid-template-columns: 25px 1fr 1fr;
        gap: 6px;
    }
    
    .coordinates-pair input {
        font-size: 0.9rem;
        padding: 8px;
    }
    
    .file-input-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .system-tab {
        padding: 10px 8px;
        font-size: 0.8rem;
    }
    
    .system-tab-content {
        padding: 10px;
        overflow-x: hidden;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) {
        font-size: 0.75rem;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) th,
    .register-table:not(.pdval-table):not(.adc-table) td {
        padding: 6px 4px;
    }
    
    /* Première colonne plus large sur mobile pour slaves/master/adc seulement */
    .register-table:not(.pdval-table):not(.adc-table) th:first-child {
        width: 50%;
        min-width: 90px;
    }
    
    .register-table:not(.pdval-table):not(.adc-table) td:first-child {
        width: 50%;
        min-width: 90px;
    }
    
    /* Réduire encore plus la colonne parameter sur mobile */
    .register-table .field-name {
        max-width: none;
        word-break: break-all;
        overflow-wrap: anywhere;
        font-size: 0.65rem;
        line-height: 1.2;
        white-space: normal !important;
    }
    
    /* Colonnes numériques encore plus compactes sur mobile */
    .register-table:not(.pdval-table) .field-value {
        max-width: 60px;
        min-width: 45px;
        font-size: 0.65rem;
        padding: 4px 2px;
    }
    
    .register-table:not(.pdval-table) th:not(:first-child) {
        max-width: 60px;
        min-width: 45px;
        font-size: 0.65rem;
        padding: 4px 2px;
    }
    
    /* Amélioration pour les coordonnées sur petits écrans */
    .coordinates-grid {
        gap: 8px;
    }
    
    .coordinates-pair {
        grid-template-columns: 25px 1fr 1fr;
        gap: 6px;
    }
    
    .coordinates-label {
        font-size: 0.75rem;
    }
    
    .coordinates-pair span {
        font-size: 0.75rem;
    }
    
    .coordinates-pair input {
        font-size: 0.8rem;
        padding: 6px 4px;
        min-width: 0;
        width: 100%;
    }
    
    /* Amélioration pour les inputs de fichiers */
    .file-input-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }
    
    .file-input-wrapper input[type="file"] {
        font-size: 0.8rem;
    }
    
    /* Boutons sur petits écrans */
    .programming-btn,
    .diagnostic-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        width: 100%;
    }
    
    /* Header avec boutons */
    .tab-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .adc-action-btn,
    .pdval-action-btn {
        margin-left: 0;
        width: 100%;
    }
    
    /* System controls responsive */
    .system-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .system-controls select {
        min-width: 100%;
        max-width: 100%;
    }
    
    .system-controls button {
        width: 100%;
    }
}

/* Optimisation pour les grands écrans */
@media (min-width: 1440px) {
    .diagnostic-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 30px;
    }
    
    .register-table-container {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .system-tab-content {
        padding: 25px;
    }
}

@media (min-width: 1920px) {
    .diagnostic-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Amélioration des tableaux pour grande largeur */
@media (min-width: 1200px) {
    .register-table:not(.pdval-table) {
        table-layout: auto;
    }
    
    .register-table:not(.pdval-table) th:first-child,
    .register-table:not(.pdval-table) td:first-child {
        min-width: 200px;
    }
    
    .register-table:not(.pdval-table) th:nth-child(2),
    .register-table:not(.pdval-table) td:nth-child(2) {
        min-width: 120px;
    }
    
    .register-table:not(.pdval-table) th:nth-child(3),
    .register-table:not(.pdval-table) td:nth-child(3) {
        min-width: 300px;
    }
    
    /* Optimisation spéciale pour les tables PD_VAL */
    .pdval-table {
        table-layout: fixed;
        width: 100%;
    }
    
    .pdval-table th,
    .pdval-table td {
        width: auto;
        min-width: auto;
        max-width: 60px;
        padding: 4px 2px;
        font-size: 0.7rem;
    }
    
    .pdval-table th:first-child,
    .pdval-table td:first-child {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
}

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

/* Indicateurs de statut personnalisés */
.status.ok {
    background: var(--success-background);
    color: var(--success-color);
}

.status.error {
    background: var(--error-background);
    color: var(--error-color);
}

.status.loading {
    background: var(--warning-background);
    color: var(--warning-color);
}

.status.loading::after {
    content: '...';
    animation: loading-dots 1s infinite;
}

@keyframes loading-dots {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===============================
   ANIMATIONS DE MISE À JOUR
   =============================== */

/* Style pour les cellules récemment mises à jour */
.updated {
    background: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background: #28a745 !important;
        color: white;
    }
    100% {
        background: #fff3cd !important;
        color: inherit;
    }
}

/* Animation de pulsation pour les nouvelles données */
.pulse-update {
    animation: pulse 1s ease-in-out;
}

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

/* ===============================
   HEADERS AVEC BOUTONS
   =============================== */

/* Header avec titre et bouton d'action */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.tab-header h3 {
    margin: 0;
    flex: 1;
}

.adc-action-btn,
.pdval-action-btn {
    margin-left: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: 110px; /* Augmenté pour "Mesure Auto" */
    transition: all 0.3s ease;
}

.adc-action-btn:hover,
.pdval-action-btn:hover {
    background-color: var(--secondary-dark, #5a6268);
    color: white;
}

/* Style pour les boutons en mode boucle active */
.adc-action-btn.active-loop,
.pdval-action-btn.active-loop {
    background-color: #dc3545 !important; /* Rouge pour indiquer l'état actif */
    color: white !important;
    animation: pulse-active 2s infinite;
    border-color: #dc3545 !important;
}

.adc-action-btn.active-loop:hover,
.pdval-action-btn.active-loop:hover {
    background-color: #c82333 !important; /* Rouge plus foncé au hover */
}

/* Animation de pulsation pour les boutons actifs */
@keyframes pulse-active {
    0% { 
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% { 
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* ========================================
   MODE SOMBRE - MODULE SYSTÈME
   ======================================== */

/* Cartes de programmation */
body.dark-mode .programming-card {
    background: #242424;
    border-color: #333333;
}

body.dark-mode .programming-card:hover {
    border-color: #9ACD32;
    box-shadow: 0 2px 5px rgba(154, 205, 50, 0.2);
}

body.dark-mode .programming-card h5 {
    color: #D0D0D0;
    border-bottom-color: #333333;
}

/* Formulaires de programmation */
body.dark-mode .programming-form {
    background: transparent;
}

body.dark-mode .programming-form-group label {
    color: #C5C5C5;
}

body.dark-mode .programming-form-group input,
body.dark-mode .programming-form-group select,
body.dark-mode input[type="number"],
body.dark-mode input[type="text"],
body.dark-mode input[type="file"],
body.dark-mode select {
    background-color: #2D2D2D;
    color: #C5C5C5;
    border-color: #404040;
}

body.dark-mode .programming-form-group input:focus,
body.dark-mode .programming-form-group select:focus {
    background-color: #333333;
    border-color: #9ACD32;
    box-shadow: 0 0 0 3px rgba(154, 205, 50, 0.15);
}

/* Boutons de programmation */
body.dark-mode .programming-btn,
body.dark-mode .file-browse-btn {
    background-color: #42A5F5;
    color: #1A1A1A;
    border-color: #42A5F5;
}

body.dark-mode .programming-btn:hover,
body.dark-mode .file-browse-btn:hover {
    background-color: #1976D2;
}

/* File input display */
body.dark-mode .file-input-display {
    background-color: #2D2D2D;
    color: #C5C5C5;
    border-color: #404040;
}

/* Coordonnées et servos */
body.dark-mode .coordinates-label,
body.dark-mode .servo-label {
    color: #C5C5C5;
}

body.dark-mode .coordinates-pair input,
body.dark-mode .servo-pair input {
    background-color: #2D2D2D;
    color: #C5C5C5;
    border-color: #404040;
}

/* Info cibles */
body.dark-mode .targets-info {
    background: rgba(66, 165, 245, 0.15);
    border-color: #42A5F5;
    color: #C5C5C5;
}

/* Sections de programmation */
body.dark-mode .programming-section {
    background: transparent;
}

body.dark-mode .programming-section h4 {
    color: #D0D0D0;
    border-bottom-color: #333333;
}

/* Section header */
body.dark-mode .section-header {
    background: #2D2D2D;
    border-color: #404040;
}

body.dark-mode .section-header h4 {
    color: #9ACD32;
}

/* Config section */
body.dark-mode .config-section {
    background: transparent;
}

body.dark-mode .config-section h4 {
    color: #D0D0D0;
    border-bottom-color: #333333;
}

/* Info cards et diagnostic cards */
body.dark-mode .info-card,
body.dark-mode .diagnostic-card {
    background: #242424;
    border-color: #333333;
}

body.dark-mode .info-card h4,
body.dark-mode .diagnostic-card h4,
body.dark-mode .info-card h5,
body.dark-mode .diagnostic-card h5 {
    color: #D0D0D0;
    border-bottom-color: #333333;
}

body.dark-mode .info-card p,
body.dark-mode .diagnostic-card p {
    color: #C5C5C5;
}

/* Tables de registres */
body.dark-mode .register-table {
    background: #242424;
    border-color: #333333;
}

body.dark-mode .register-table th {
    background: #2D2D2D;
    color: #9ACD32;
    border-color: #404040;
}

body.dark-mode .register-table td {
    color: #C5C5C5;
    border-color: #333333;
}

body.dark-mode .register-table tr:hover {
    background: #2D2D2D;
}

/* Status indicators */
body.dark-mode .status-indicator {
    background: #2D2D2D;
    color: #C5C5C5;
    border-color: #404040;
}

body.dark-mode .status-indicator.success {
    background: rgba(102, 187, 106, 0.2);
    color: #66BB6A;
    border-color: #66BB6A;
}

body.dark-mode .status-indicator.error {
    background: rgba(239, 83, 80, 0.2);
    color: #EF5350;
    border-color: #EF5350;
}

body.dark-mode .status-indicator.warning {
    background: rgba(255, 167, 38, 0.2);
    color: #FFA726;
    border-color: #FFA726;
}

/* Logs */
body.dark-mode .log-container {
    background: #1A1A1A;
    border-color: #333333;
}

body.dark-mode .log-entry {
    border-bottom-color: #333333;
    color: #C5C5C5;
}

body.dark-mode .log-entry.error {
    background: rgba(239, 83, 80, 0.1);
    color: #EF5350;
}

body.dark-mode .log-entry.warning {
    background: rgba(255, 167, 38, 0.1);
    color: #FFA726;
}

body.dark-mode .log-entry.success {
    background: rgba(102, 187, 106, 0.1);
    color: #66BB6A;
}

/* No data */
body.dark-mode .no-data {
    color: #A0A0A0;
    background: #2D2D2D;
    border-color: #404040;
}

/* SVG Container */
body.dark-mode .svg-container {
    background: #1A1A1A;
    border-color: #333333;
}

/* ===========================
   ERROR TOOLTIP STYLES
   =========================== */

/* Style pour les cellules d'erreur avec tooltip */
.error-cell,
td.error-cell,
.field-value.error-cell {
    position: relative;
    cursor: help;
    border-bottom: 2px dotted #ff5252 !important;
    background-color: rgba(255, 82, 82, 0.05) !important;
    font-weight: 600;
    z-index: 1; /* Créer un contexte de stacking */
}

.error-cell:hover,
td.error-cell:hover,
.field-value.error-cell:hover {
    background-color: rgba(255, 82, 82, 0.15) !important;
    z-index: 9999; /* Passer au premier plan au survol */
}

/* Tooltip container - attaché au body avec position fixed */
.error-tooltip {
    position: fixed;
    background: white;
    border: 2px solid #ff5252;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 999999 !important; /* Très haut z-index */
    min-width: 300px;
    max-width: 400px;
    font-size: 13px;
    line-height: 1.5;
    display: none;
    pointer-events: none;
    top: 0;
    left: 0;
}

.error-tooltip.visible {
    display: block;
}

.error-tooltip-header {
    font-weight: bold;
    color: #d32f2f;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ffcdd2;
    font-size: 14px;
}

.error-tooltip-body {
    margin-bottom: 8px;
}

.error-tooltip-item {
    padding: 4px 0;
    color: #424242;
}

.error-tooltip-item strong {
    color: #d32f2f;
    display: inline-block;
    min-width: 100px;
}

.error-tooltip-footer {
    font-size: 11px;
    color: #757575;
    text-align: right;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
}

.error-tooltip-success {
    color: #388e3c;
    font-weight: 500;
}

/* Dark mode support */
body.dark-mode .error-tooltip {
    background: #2d2d2d;
    border-color: #ff5252;
    color: #e0e0e0;
}

body.dark-mode .error-tooltip-header {
    color: #ff6b6b;
    border-bottom-color: #4a4a4a;
}

body.dark-mode .error-tooltip-item {
    color: #e0e0e0;
}

body.dark-mode .error-tooltip-item strong {
    color: #ff6b6b;
}

body.dark-mode .error-tooltip-footer {
    color: #a0a0a0;
    border-top-color: #4a4a4a;
}

body.dark-mode .field-value.error-cell:hover {
    background-color: rgba(255, 82, 82, 0.2) !important;
}

/* Status register description styling */
.status-ready {
    color: #2e7d32;
    font-weight: 600;
}

.status-error {
    color: #d32f2f;
    font-weight: 600;
}

.status-absent {
    color: #f57c00;
    font-weight: 600;
}

.status-pd-fault {
    color: #f57c00;
    font-weight: 500;
}

.status-adc-fault {
    color: #f57c00;
    font-weight: 500;
}

/* Dark mode support for status descriptions */
body.dark-mode .status-ready {
    color: #66bb6a;
}

body.dark-mode .status-error {
    color: #ff6b6b;
}

body.dark-mode .status-absent {
    color: #ffa726;
}

body.dark-mode .status-pd-fault {
    color: #ffb74d;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAINTENANCE TAB
   ═══════════════════════════════════════════════════════════════════════════ */

.maintenance-section {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
}

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

.maintenance-actions-row {
    margin-bottom: 0.75rem;
}

/* Counters grid */
.maintenance-counters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.maintenance-counter-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    background: var(--surface-variant, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    text-align: center;
}

.maintenance-counter-card--total {
    border-color: #3b82f6;
    background: #eff6ff;
}

.maintenance-counter-card--lifetime {
    border-color: #7c3aed;
    background: #f5f3ff;
}

.counter-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 0.25rem;
}

.counter-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    font-variant-numeric: tabular-nums;
}

/* Sélecteur de numéros de cartes de détection */
.maintenance-card-selector {
    display: none;
    margin-top: 0.5rem;
    margin-left: 1.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-variant, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
}

.maintenance-card-selector-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 0.4rem;
}

.maintenance-card-numbers {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.maintenance-card-numbers label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

body.dark-mode .maintenance-card-selector {
    background: var(--surface-dark, #1e293b);
    border-color: var(--border-dark, #334155);
}

/* Dates grid : auto-fill pour accueillir 7 cartes */
.maintenance-dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.maintenance-date-card {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    background: var(--surface-variant, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
}

.date-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 0.25rem;
}

.date-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.date-operator {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    font-style: italic;
}

/* Buttons */
.maintenance-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, opacity 0.15s;
}

.maintenance-btn.btn-primary {
    background: #2563eb;
    color: #fff;
}
.maintenance-btn.btn-primary:hover { background: #1d4ed8; }

.maintenance-btn.btn-secondary {
    background: #e2e8f0;
    color: #334155;
}
.maintenance-btn.btn-secondary:hover { background: #cbd5e1; }

.maintenance-btn.btn-danger {
    background: #dc2626;
    color: #fff;
}
.maintenance-btn.btn-danger:hover { background: #b91c1c; }

.maintenance-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.maintenance-hint {
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* History table */
.maintenance-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.maintenance-history-table th,
.maintenance-history-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.maintenance-history-table th {
    background: var(--surface-variant, #f8fafc);
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.maintenance-empty,
.maintenance-loading {
    color: var(--text-secondary, #64748b);
    font-style: italic;
    padding: 1rem 0;
}

.maintenance-error {
    color: #dc2626;
    font-size: 0.875rem;
}

/* Modal */
.maintenance-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maintenance-modal.hidden { display: none; }

.maintenance-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.maintenance-modal-box {
    position: relative;
    background: var(--surface, #fff);
    border-radius: 12px;
    width: 90%;
    max-width: 540px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    overflow: hidden;
    z-index: 1;
}

.maintenance-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface-variant, #f8fafc);
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.maintenance-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.maintenance-modal-body {
    padding: 1.5rem;
}

.maintenance-modal-warn {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #713f12;
}

.maintenance-fieldset {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.maintenance-fieldset legend {
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0 0.25rem;
}

.maintenance-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.maintenance-notes-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.maintenance-notes-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.maintenance-textarea {
    width: 100%;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.875rem;
    resize: vertical;
    box-sizing: border-box;
}

.maintenance-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.maintenance-confirm-warning {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #7f1d1d;
}

.maintenance-summary {
    background: var(--surface-variant, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.maintenance-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ── Paysage tablette : 2 colonnes sans scrollbar ────────────────────────── */
@media (orientation: landscape) and (max-height: 800px) {

    /* Grille 2 colonnes sur le conteneur de l'onglet — seulement quand l'onglet est actif
       (sans .active, la spécificité ID 1-0-0 écrase le display:none de .system-tab-content) */
    #system-tab-maintenance.active {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 0.75rem;
        align-items: start;
        align-content: start;
    }

    /* Titre et ligne MAC : pleine largeur */
    #system-tab-maintenance > h3 {
        grid-column: 1 / -1;
        font-size: 1rem;
        margin-bottom: 0.25rem;
        padding-bottom: 4px;
    }
    .maintenance-target-info {
        grid-column: 1 / -1;
        margin-bottom: 0.4em;
    }

    /* Colonne gauche : compteurs (ligne 3) + bouton (ligne 4) */
    #maintenance-counters-section { grid-column: 1; grid-row: 3; }
    #maintenance-record-section   { grid-column: 1; grid-row: 4; }

    /* Colonne droite :  dates (ligne 3) + historique (ligne 4) */
    #maintenance-dates-section    { grid-column: 2; grid-row: 3; }
    #maintenance-history-section  {
        grid-column: 2;
        grid-row: 4;
        overflow-y: auto;
        max-height: calc(50vh - 60px);
    }

    /* Sections : espacement réduit */
    .maintenance-section {
        margin-bottom: 0.4rem;
        padding: 0.5rem 0.75rem;
    }
    .maintenance-section h4 {
        margin: 0 0 0.4rem;
        font-size: 0.8rem;
        padding-bottom: 0.25rem;
    }

    /* Compteurs : 4 par ligne au lieu de auto-fill */
    .maintenance-counters-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.4rem;
    }
    .maintenance-counter-card { padding: 0.35rem 0.2rem; }
    .counter-value { font-size: 1.1rem; }
    .counter-label { font-size: 0.65rem; }

    /* Dates : 3 par ligne */
    .maintenance-dates-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }
    .maintenance-date-card { padding: 0.35rem 0.5rem; }
    .date-value  { font-size: 0.8rem; }
    .date-label  { font-size: 0.65rem; }

    /* Bouton compact */
    .maintenance-hint { font-size: 0.75rem; margin-bottom: 0.4rem; }
}

/* Dark mode */
body.dark-mode .maintenance-section {
    background: var(--surface-dark, #1e293b);
    border-color: var(--border-dark, #334155);
}

body.dark-mode .maintenance-counter-card,
body.dark-mode .maintenance-date-card {
    background: var(--surface-variant-dark, #0f172a);
    border-color: var(--border-dark, #334155);
}

body.dark-mode .maintenance-modal-box {
    background: var(--surface-dark, #1e293b);
}

body.dark-mode .maintenance-modal-warn {
    background: #422006;
    border-color: #92400e;
    color: #fde68a;
}

body.dark-mode .maintenance-confirm-warning {
    background: #450a0a;
    border-color: #991b1b;
    color: #fca5a5;
}

body.dark-mode .status-adc-fault {
    color: #ffb74d;
}

/* ===========================
   CALIBRATION MODULE STYLES
   =========================== */

/* Calibration panel disabled state */
.calibration-panel.calibration-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Select pour la calibration - meilleur contraste */
#calibration-target-selector {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #1f2937;
}

#calibration-target-selector:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Calibration status box */
.calibration-status-box {
    margin: 4px 0;
    padding: 8px;
    background: #e5e7eb;
    border-radius: 8px;
    border: 2px solid #d1d5db;
}

.calibration-status {
    margin: 0;
    padding: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    text-align: center;
}

/* Calibration results display */
.calibration-results {
    margin-top: 6px;
    padding: 6px 10px;
    background: #d1fae5;
    border-left: 4px solid #10b981;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}

.coord-display {
    display: inline-block;
    margin: 0 8px;
    font-weight: bold;
    color: #047857;
    font-size: 14px;
}

.coord-display span {
    color: #065f46;
    font-size: 14px;
}

/* Calibration buttons */
.calibration-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.btn-calibration-start {
    background: #2196F3;
    color: white;
}

.btn-calibration-start:hover:not(:disabled) {
    background: #1976D2;
}

.btn-calibration-action {
    background: #4CAF50;
    color: white;
}

.btn-calibration-action:hover:not(:disabled) {
    background: #388E3C;
}

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

/* Compaction ciblée de la tuile Targets Centering */
.target-centering-card .programming-form {
    gap: 4px;
}

.target-centering-card #btn-toggle-calibration-mode {
    margin-bottom: 4px;
    padding: 3px 6px;
    font-size: 0.72rem;
    min-height: 1.5rem;
}

.target-centering-card #calibration-target-selector {
    padding: 4px 8px;
    font-size: 12px;
}

.target-centering-card .calibration-status-box {
    margin: 2px 0;
    padding: 5px;
}

.target-centering-card .calibration-status {
    padding: 2px;
    font-size: 12px;
}

.target-centering-card .calibration-results {
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 11px;
}

.target-centering-card .coord-display,
.target-centering-card .coord-display span {
    font-size: 12px;
}

.target-centering-card .calibration-buttons {
    gap: 4px;
    margin-top: 6px;
}

.target-centering-card .calibration-buttons .programming-btn {
    padding: 3px 6px;
    min-height: 1.55rem;
    font-size: 0.68rem;
    margin-top: 0;
}

.btn-calibration-abort:hover:not(:disabled) {
    background: #d32f2f;
}

.programming-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animation flash verte pour les champs mis à jour */
.field-updated {
    animation: flash-green 0.5s ease-in-out 3;
    border-color: #4CAF50 !important;
    border-width: 2px !important;
}

/* Encadrement vert permanent pour les champs calibrés */
.field-calibrated {
    border: 2px solid #4CAF50 !important;
    background-color: #e8f5e9 !important;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
}

@keyframes flash-green {
    0%, 100% { 
        background-color: white; 
    }
    50% { 
        background-color: #c8e6c9; 
    }
}

/* Panel targets en mode calibration */
#targets-position-panel.calibrating {
    background: linear-gradient(135deg, #fffbe0 0%, #fff9c4 100%);
    border: 2px solid #ffc107;
    transition: all 0.3s ease;
}

/* Animations de clignotement pour les cibles */
@keyframes calibration-pulse-blue {
    0%, 100% { 
        stroke-width: 5;
        stroke-opacity: 1;
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 3px rgba(33, 150, 243, 0.55));
    }
    50% { 
        stroke-width: 11;
        stroke-opacity: 0.95;
        opacity: 0.95;
        transform: scale(1.12);
        filter: drop-shadow(0 0 8px rgba(33, 150, 243, 0.9));
    }
}

@keyframes calibration-pulse-yellow {
    0%, 100% { 
        stroke-width: 5;
        stroke-opacity: 1;
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 3px rgba(255, 193, 7, 0.55));
    }
    50% { 
        stroke-width: 11;
        stroke-opacity: 0.95;
        opacity: 0.95;
        transform: scale(1.12);
        filter: drop-shadow(0 0 8px rgba(255, 193, 7, 0.9));
    }
}

@keyframes calibration-pulse-green {
    0%, 100% { 
        stroke-width: 5;
        stroke-opacity: 1;
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 3px rgba(76, 175, 80, 0.55));
    }
    50% { 
        stroke-width: 11;
        stroke-opacity: 0.95;
        opacity: 0.95;
        transform: scale(1.12);
        filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.9));
    }
}

/* Classes pour les cibles en calibration */
.target-circle.calibrating-waiting-start {
    animation: calibration-pulse-blue 1.2s ease-in-out infinite;
    stroke: #2196F3 !important;
    transform-box: fill-box;
    transform-origin: center;
}

.target-circle.calibrating-waiting-object {
    animation: calibration-pulse-yellow 1.2s ease-in-out infinite;
    stroke: #FFC107 !important;
    transform-box: fill-box;
    transform-origin: center;
}

.target-circle.calibrating-success {
    animation: calibration-pulse-green 1.2s ease-in-out infinite;
    stroke: #4CAF50 !important;
    transform-box: fill-box;
    transform-origin: center;
}

/* Dark mode support */
body.dark-mode #calibration-target-selector {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
}

body.dark-mode #calibration-target-selector:focus {
    border-color: #9ACD32;
    box-shadow: 0 0 0 3px rgba(154, 205, 50, 0.15);
}

body.dark-mode .calibration-status-box {
    background: #2d2d2d;
    border-color: #444;
}

body.dark-mode .calibration-status {
    color: #e0e0e0;
}

body.dark-mode .calibration-results {
    background: #1b5e20;
    border-left-color: #4CAF50;
}

body.dark-mode .coord-display {
    color: #a5d6a7;
}

body.dark-mode .coord-display span {
    color: #c8e6c9;
}

body.dark-mode #targets-position-panel.calibrating {
    background: linear-gradient(135deg, #3e3a2f 0%, #4a4636 100%);
    border-color: #ffc107;
}

body.dark-mode .field-updated {
    background-color: #2d2d2d;
}

body.dark-mode .field-calibrated {
    border: 2px solid #66BB6A !important;
    background-color: #1b5e20 !important;
    box-shadow: 0 0 8px rgba(102, 187, 106, 0.4);
}

@keyframes flash-green-dark {
    0%, 100% { 
        background-color: #2d2d2d; 
    }
    50% { 
        background-color: #2e5d2e; 
    }
}

body.dark-mode .field-updated {
    animation: flash-green-dark 0.5s ease-in-out 3;
}
