/* PROMETHEUS 4.0 - Fenêtre détaillée */

#device-modal[hidden] {
    display: none !important;
}

#device-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px;
}

#device-modal .device-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
}

#device-modal .device-modal-content {
    position: relative;
    z-index: 1;
    width: min(900px, calc(100vw - 40px));
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    border: 1px solid #284d75;
    border-radius: 18px;
    background: #101c30;
    color: #e8f1ff;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
}

#device-modal .device-modal-close {
    position: absolute;
    top: 12px;
    right: 18px;
    border: none;
    background: transparent;
    color: #a9bfd8;
    font-size: 30px;
    cursor: pointer;
}

#device-modal .device-detail-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 26px;
}

#device-modal .device-detail-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 14px;
    background: #193858;
    font-size: 30px;
}

#device-modal .device-detail-header h2 {
    margin: 0 0 8px;
    font-size: 24px;
}

#device-modal .device-detail-header p {
    margin: 0;
    color: #92a9c8;
}

#device-modal .device-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

#device-modal .device-detail-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 16px;
    border: 1px solid #28405f;
    border-radius: 10px;
    background: #15263e;
}

#device-modal .device-detail-item span {
    color: #92a9c8;
    font-size: 12px;
}

#device-modal .device-detail-item strong {
    color: #fff;
    font-size: 14px;
    overflow-wrap: anywhere;
}

#device-modal .device-detail-note {
    margin-top: 22px;
    color: #92a9c8;
    font-size: 12px;
    line-height: 1.6;
}

body.modal-open {
    overflow: hidden;
}

/* PROMETHEUS 4.0 - Supervision Proxmox */

#device-modal .proxmox-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

#device-modal .proxmox-metric {
    padding: 16px;
    border: 1px solid #284d75;
    border-radius: 12px;
    background: #15263e;
}

#device-modal .proxmox-metric-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

#device-modal .proxmox-metric-heading span {
    color: #92a9c8;
}

#device-modal .proxmox-metric-heading strong {
    color: #e8f1ff;
    font-size: 18px;
}

#device-modal .proxmox-progress {
    height: 9px;
    overflow: hidden;
    border-radius: 20px;
    background: #091526;
}

#device-modal .proxmox-progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: #29a6e8;
    transition: width .3s ease;
}

#device-modal .proxmox-progress-fill.warning {
    background: #f4b44e;
}

#device-modal .proxmox-progress-fill.critical {
    background: #f06565;
}

#device-modal .proxmox-metric small {
    display: block;
    margin-top: 10px;
    color: #92a9c8;
}

#device-modal .proxmox-vms-title {
    margin: 24px 0 12px;
    color: #e8f1ff;
}

#device-modal .proxmox-vms {
    display: grid;
    gap: 10px;
}

#device-modal .proxmox-vm {
    padding: 14px;
    border: 1px solid #28405f;
    border-radius: 10px;
    background: #15263e;
}

#device-modal .proxmox-vm-identity {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

#device-modal .proxmox-vm-state {
    font-size: 12px;
    font-weight: 600;
}

#device-modal .proxmox-vm-state.running {
    color: #57d9a3;
}

#device-modal .proxmox-vm-state.stopped {
    color: #f06565;
}

#device-modal .proxmox-vm small {
    color: #92a9c8;
}

@media (max-width: 600px) {
    #device-modal .proxmox-metrics {
        grid-template-columns: 1fr;
    }
}

/* Bouton administration Proxmox */

#device-modal .proxmox-admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 16px 0;
    padding: 12px 20px;

    color: #ffffff;
    background: #1769aa;

    border: 1px solid #299bea;
    border-radius: 10px;

    font-size: 14px;
    font-weight: 600;
    text-decoration: none;

    transition: background .2s ease, box-shadow .2s ease;
}

#device-modal .proxmox-admin-link:hover {
    background: #218bd5;
    box-shadow: 0 0 18px rgba(41, 155, 234, .3);
}

/* ==========================================
   PROMETHEUS 4.0 - Machines virtuelles
   ========================================== */

#device-modal .proxmox-vm {
    overflow: hidden;
}

#device-modal .proxmox-vm-trigger {
    display: block;
    width: 100%;
    padding: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

#device-modal .proxmox-vm-trigger:hover {
    background: rgba(59, 130, 246, 0.08);
}

#device-modal .proxmox-vm-trigger:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: -2px;
}

#device-modal .proxmox-vm-trigger[aria-expanded="true"] {
    background: rgba(59, 130, 246, 0.12);
}

#device-modal .proxmox-vm-trigger .proxmox-vm-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#device-modal .proxmox-vm-trigger small {
    display: block;
    margin-top: 6px;
    color: #93a9c8;
}

#device-modal .proxmox-vm-details {
    padding: 12px;
    border-top: 1px solid #29415e;
    background: rgba(8, 18, 35, 0.35);
}

#device-modal .proxmox-vm-details[hidden] {
    display: none !important;
}

#device-modal .proxmox-vm-details .device-details-grid {
    margin-bottom: 12px;
}

#device-modal .proxmox-vm-details .proxmox-metrics {
    margin-top: 10px;
}

@media (max-width: 600px) {
    #device-modal .device-details-grid {
        grid-template-columns: 1fr;
    }

    #device-modal .device-modal-content {
        padding: 22px;
    }
}


/* ==========================================
   PROMETHEUS 4.0 - MODAL LARGE
   ========================================== */

#device-modal .device-modal-content {
    flex: 0 0 900px;
    width: 900px;
    max-width: calc(100vw - 40px);
    min-width: 0;
    max-height: 88vh;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #365b85 #101c30;
}

#device-modal .device-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

#device-modal .device-detail-item {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    #device-modal .device-modal-content {
        flex-basis: auto;
        width: calc(100vw - 20px);
        max-width: none;
        max-height: 92vh;
    }

    #device-modal .device-details-grid {
        grid-template-columns: 1fr;
    }
}


/* Couleurs des jauges Proxmox */
#device-modal .proxmox-progress-fill {
    background: #22c55e;
}

#device-modal .proxmox-progress-fill.warning {
    background: #f59e0b;
}

#device-modal .proxmox-progress-fill.critical {
    background: #ef4444;
}

#device-modal .proxmox-progress-fill.unknown {
    background: #64748b;
}


/* Jauges compactes des machines virtuelles */
#device-modal .proxmox-vm-compact-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 12px;
}

#device-modal .proxmox-vm-compact-gauge {
    min-width: 0;
}

#device-modal .proxmox-vm-compact-gauge span {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: #a9c6e8;
}

#device-modal .proxmox-vm-compact-gauge .proxmox-progress {
    height: 7px;
}

@media (max-width: 600px) {
    #device-modal .proxmox-vm-compact-metrics {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* PROMETHEUS 4.0 — Couleurs communes des ressources */
#device-modal {
    --resource-normal: #19c978;
    --resource-warning: #f4b44e;
    --resource-critical: #f06565;
    --resource-unknown: #64748b;
}

/* CPU et RAM : état normal */
#device-modal .proxmox-progress-fill {
    background: var(--resource-normal);
}

/* CPU et RAM : avertissement */
#device-modal .proxmox-progress-fill.warning {
    background: var(--resource-warning);
}

/* CPU et RAM : critique */
#device-modal .proxmox-progress-fill.critical {
    background: var(--resource-critical);
}

/* Données indisponibles */
#device-modal .proxmox-progress-fill.unknown {
    background: var(--resource-unknown);
}

/* Affichage des valeurs */
#device-modal .proxmox-metric-heading strong {
    font-weight: 700;
}

/* Transition fluide des jauges */
#device-modal .proxmox-progress-fill {
    transition: width 0.4s ease, background-color 0.3s ease;
}
