/* Import del CSS fornito - versione ridotta per i componenti necessari */
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,300,700");


/* Risk Matrix Styles */
.fmea-matrix-container {
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.matrix-header {
    text-align: center;
    margin-bottom: 20px;
}

.matrix-header h3 {
    color: #333;
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 600;
}

.matrix-header p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

.matrix-wrapper {
    margin-bottom: 20px;
}

.risk-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    border: 2px solid #333;
    margin: 0 auto;
}

.matrix-corner {
    background: #f8f9fa;
    border: 2px solid #333;
    width: 150px;
    height: 60px;
    text-align: center;
    vertical-align: middle;
    font-weight: bold;
    padding: 8px;
}

.severity-header-main {
    background: #e9ecef;
    border: 2px solid #333;
    text-align: center;
    font-weight: bold;
    padding: 8px;
    color: #d32f2f;
    font-size: 14px;
    height: 45px;
}

.severity-header {
    background: #fff3e0;
    border: 1px solid #333;
    padding: 8px 4px;
    text-align: center;
    vertical-align: middle;
    min-width: 100px;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 400;
}

.likelihood-header-main {
    background: #e9ecef;
    border: 2px solid #333;
    text-align: center;
    font-weight: bold;
    width: 30px;
    padding: 8px;
    color: #d32f2f;
    font-size: 14px;
}

.likelihood-header {
    background: #e3f2fd;
    border: 1px solid #333;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
    width: 150px;
    font-size: 10px;
    line-height: 1.2;
}

.matrix-cell {
    border: 1px solid #333;
    padding: 0;
    text-align: center;
    width: 80px;
    height: 40px;
    position: relative;
}

.rpn-value {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #000;
    position: relative;
}

/* RPN Color Scheme */
.rpn-18 { background-color: #15b64a; }
.rpn-21 { background-color: #35c040; }
.rpn-24 { background-color: #55ca36; }
.rpn-27 { background-color: #74d42c; }
.rpn-28 { background-color: #7fd728; }
.rpn-30 { background-color: #94de22; }
.rpn-32 { background-color: #aae41b; }
.rpn-33 { background-color: #d4f10e; }
.rpn-35 { background-color: #c9ee11; }
.rpn-36 { background-color: #d4f10e; }
.rpn-40 { background-color: #ffff00; }
.rpn-42 { background-color: #ffea00; }
.rpn-44 { background-color: #ffd500; }
.rpn-45 { background-color: #ffca00; }
.rpn-48 { background-color: #ffab00; }
.rpn-49 { background-color: #ffa000; }
.rpn-50 { background-color: #ff9500; }
.rpn-54 { background-color: #ff6b00; }
.rpn-55 { background-color: #ff6000; }
.rpn-56 { background-color: #ff5600; }
.rpn-60 { background-color: #ff2b00; }
.rpn-63 { background-color: #ff0b00; }
.rpn-64 { background-color: #ff0000; }
.rpn-66 { background-color: #ff0000; }
.rpn-70 { background-color: #ff0000; }
.rpn-72 { background-color: #ff0000; }
.rpn-77 { background-color: #ff0000; }
.rpn-80 { background-color: #ff0000; }
.rpn-88 { background-color: #ff0000; }

/* Evidenziazione celle con dati - bordi graduali basati sul numero di record */
.has-data {
    position: relative;
    border-style: solid !important;
    border-color: #007bff !important;
}

/* Sistema di bordi graduali scalabile: ogni 10 record = +1px (max 10px) */
.has-data-1-10 {
    border-width: 1px !important;
    box-shadow: 0 0 3px rgba(0, 123, 255, 0.3);
}

.has-data-11-20 {
    border-width: 2px !important;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.4);
}

.has-data-21-30 {
    border-width: 3px !important;
    box-shadow: 0 0 7px rgba(0, 123, 255, 0.5);
}

.has-data-31-40 {
    border-width: 4px !important;
    box-shadow: 0 0 9px rgba(0, 123, 255, 0.55);
}

.has-data-41-50 {
    border-width: 5px !important;
    box-shadow: 0 0 11px rgba(0, 123, 255, 0.6);
}

.has-data-51-60 {
    border-width: 6px !important;
    box-shadow: 0 0 13px rgba(0, 123, 255, 0.65);
}

.has-data-61-70 {
    border-width: 7px !important;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.7);
}

.has-data-71-80 {
    border-width: 8px !important;
    box-shadow: 0 0 17px rgba(0, 123, 255, 0.75);
}

.has-data-81-90 {
    border-width: 9px !important;
    box-shadow: 0 0 19px rgba(0, 123, 255, 0.8);
}

.has-data-91-plus {
    border-width: 10px !important;
    box-shadow: 0 0 22px rgba(0, 123, 255, 0.9);
    animation: pulse-data 2s infinite;
}

@keyframes pulse-data {
    0%, 100% { 
        box-shadow: 0 0 22px rgba(0, 123, 255, 0.9); 
    }
    50% { 
        box-shadow: 0 0 30px rgba(0, 123, 255, 1); 
    }
}

.has-data::before {
    /* content: '●'; */
    position: absolute;
    top: -2px;
    right: 2px;
    color: #007bff;
    font-size: 12px;
    font-weight: bold;
}

/* Tutte le celle RPN sono cliccabili */
.clickable-rpn {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clickable-rpn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.4);
    z-index: 50;
    position: relative;
}

.clickable-rpn:active {
    transform: scale(0.95);
}

.data-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 1px solid black;
}

/* Legend */
.matrix-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border: 1px solid #000;
    border-radius: 3px;
}

.legend-very-low { background-color: #4CAF50; }
.legend-low { background-color: #FFEB3B; }
.legend-medium { background-color: #FF9800; }
.legend-high { background-color: #FF5722; }
.legend-very-high { background-color: #F44336; }
.legend-has-data { background-color: #007bff; }

/* Modal styles */
.pfmea-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 2% auto;
    padding: 0;
    border: none;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, #ffffff, #ededed);
    color: black;
    padding: 20px 25px;
    position: relative;
    border-radius: 12px 12px 0 0;
}

.modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.modal-subtitle {
    margin: 5px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #979797;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #ffcccc;
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
}

.process-group {
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #007bff;
    overflow: hidden;
}

.process-group-header {
    background: #e9ecef;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.process-group-header:hover {
    background: #dee2e6;
}

.process-group-header.active {
    background: #ffffff;
    color: black;
}

.process-title {
    font-weight: bold;
    font-size: 16px;
    margin: 0;
}

.process-meta {
    font-size: 12px;
    opacity: 0.8;
    margin: 2px 0;
}

.toggle-icon {
    font-size: 18px;
    transition: transform 0.3s;
}

.process-group-header.active .toggle-icon {
    transform: rotate(180deg);
}

.process-items {
    display: none;
    padding: 0;
}

.process-items.show {
    display: block;
}

.pfmea-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.pfmea-item:hover {
    background: #ffffff;
}

.pfmea-item:last-child {
    border-bottom: none;
}

.pfmea-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.pfmea-id-badge {
    background: #007bff;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
}

.rpn-badge {
    color: black;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-left: auto;
}

.step-info {
    flex: 1;
}

.step-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
}

.step-description {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.failure-mechanism {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
}

.failure-mechanism-title {
    font-weight: bold;
    color: #856404;
    font-size: 12px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.failure-mechanism-text {
    color: #856404;
    font-size: 13px;
    line-height: 1.4;
}

.effect-info {
    margin-top: 10px;
    padding: 8px 12px;
    background: #e3f2fd;
    border-radius: 6px;
    border-left: 3px solid #2196f3;
}

.effect-label {
    font-size: 11px;
    font-weight: bold;
    color: #1976d2;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.effect-text {
    font-size: 12px;
    color: #1976d2;
}

.process-count-badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .risk-matrix-table { 
        font-size: 10px; 
    }
    .severity-header, .likelihood-header { 
        font-size: 9px; 
        min-width: 70px; 
    }
    .rpn-value { 
        font-size: 12px; 
    }
    .matrix-legend {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }
    .modal-header {
        padding: 15px 20px;
    }
    .modal-title {
        font-size: 20px;
    }
    .modal-body {
        padding: 15px;
    }
    .pfmea-item-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .rpn-badge {
        margin-left: 0;
        margin-top: 5px;
        align-self: flex-start;
    }
}