/* Modern Table Styles */

/* Card that contains a table must not clip the sticky last column */
.card:has(.modern-table),
.card-body:has(.modern-table) {
    overflow: visible;
}

.card:has(.modern-table) .card-body {
    overflow: visible;
}

.modern-table-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow-x: auto;
    overflow-y: visible;
    margin-bottom: 2rem;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    margin: 0;
}

.modern-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modern-table thead th {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem;
    border: none;
    position: relative;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modern-table thead th:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modern-table thead th:last-child:hover {
    background: linear-gradient(135deg, #7285f0 0%, #7d54a8 100%);
}

.modern-table thead th:first-child {
    border-top-left-radius: 1rem;
}

.modern-table thead th:last-child {
    border-top-right-radius: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modern-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modern-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modern-table tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

.modern-table tbody tr:nth-child(even):hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

.modern-table td {
    padding: 0.75rem 0.5rem;
    border: none;
    vertical-align: middle;
    font-size: 0.85rem;
    color: #475569;
    max-width: none;
    overflow: visible;
    text-overflow: ellipsis;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
}

.modern-table td:hover {
    white-space: normal;
    word-break: break-word;
}

/* Modern Badges */
.modern-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.modern-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.modern-badge.badge-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.modern-badge.badge-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.modern-badge.badge-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.modern-badge.badge-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.modern-badge.badge-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
}

/* Modern Action Buttons */
.modern-actions {
    display: flex;
    flex-direction: row;
    gap: 0.15rem;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    padding: 0.25rem 0.1rem;
    white-space: nowrap;
}

/* Actions column — narrow + sticky so buttons are always visible */
.modern-table tbody td:last-child {
    width: 1%;
    white-space: nowrap;
    padding: 0.5rem 0.25rem;
    position: sticky;
    right: 0;
    z-index: 2;
    box-shadow: -3px 0 6px rgba(0,0,0,0.07);
    background-color: #f8fafc;
}

.modern-table thead th:last-child {
    width: 1%;
    white-space: nowrap;
    position: sticky;
    right: 0;
    z-index: 3;
    box-shadow: -3px 0 6px rgba(0,0,0,0.07);
}

/* Force buttons horizontal in sticky column */
.modern-table tbody td:last-child .modern-actions {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    display: flex !important;
}

.modern-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.25rem;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    margin: 0 0.0625rem;
    min-width: 1.75rem;
    z-index: 1;
}

.modern-btn i {
    font-size: 0.8rem;
    font-weight: 900;
    display: inline-block;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.modern-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.modern-btn:hover::before {
    left: 100%;
}

.modern-btn:hover {
    transform: translateY(-1px) scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.modern-btn:active {
    transform: translateY(0) scale(0.95);
}

.modern-btn.btn-edit {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: 2px solid #d97706;
}

.modern-btn.btn-view {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    border: 2px solid #0891b2;
}

.modern-btn.btn-delete {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: 2px solid #dc2626;
}

.modern-btn.btn-action {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: 2px solid #059669;
}

.modern-btn.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: 2px solid #059669;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modern-table-container {
        margin: 0 -1rem;
        border-radius: 0;
        overflow-x: auto;
    }
    
    .modern-table {
        min-width: 2000px;
    }
    
    .modern-table thead th,
    .modern-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        max-width: none;
    }
    
    .modern-actions {
        flex-direction: row;
        gap: 0.125rem;
        flex-wrap: wrap;
        padding: 0.125rem;
    }
    
    .modern-btn {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.7rem;
        margin: 0 0.03125rem;
        border-radius: 0.25rem;
    }
    
    .modern-btn i {
        font-size: 0.7rem;
    }
}

/* Wide multi-column FMEA line layout only — skip .fcp-index-table (FMEA Cards, short index grids) */
.modern-table:not(.fcp-index-table) {
    table-layout: fixed;
    width: 100%;
    min-width: 2000px;
}

.modern-table:not(.fcp-index-table) thead th {
    font-size: 0.8rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
}

.modern-table:not(.fcp-index-table) tbody td {
    text-align: center;
}

.modern-table:not(.fcp-index-table) tbody td:first-child,
.modern-table:not(.fcp-index-table) tbody td:nth-child(2),
.modern-table:not(.fcp-index-table) tbody td:nth-child(3),
.modern-table:not(.fcp-index-table) tbody td:nth-child(8) {
    text-align: left;
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) {
    text-align: center;
    vertical-align: middle;
    padding: 0.5rem;
    background: rgba(248, 250, 252, 0.3);
    border-left: 2px solid rgba(102, 126, 234, 0.2);
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-actions {
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn:hover {
    transform: translateY(-2px) scale(1.15);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    z-index: 20;
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn i {
    font-size: 0.9rem;
    font-weight: 900;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn.btn-edit {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: 2px solid #d97706;
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn.btn-view {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    border: 2px solid #0891b2;
}

.modern-table:not(.fcp-index-table) tbody td:nth-child(18) .modern-btn.btn-delete {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: 2px solid #dc2626;
}

/* Column % map for 18+ col FMEA tables only */
.modern-table:not(.fcp-index-table) th:nth-child(1), .modern-table:not(.fcp-index-table) td:nth-child(1) { width: 8%; min-width: 100px; } /* Process */
.modern-table:not(.fcp-index-table) th:nth-child(2), .modern-table:not(.fcp-index-table) td:nth-child(2) { width: 12%; min-width: 120px; } /* Cause */
.modern-table:not(.fcp-index-table) th:nth-child(3), .modern-table:not(.fcp-index-table) td:nth-child(3) { width: 12%; min-width: 120px; } /* Effect */
.modern-table:not(.fcp-index-table) th:nth-child(4), .modern-table:not(.fcp-index-table) td:nth-child(4) { width: 4%; min-width: 40px; } /* Severity */
.modern-table:not(.fcp-index-table) th:nth-child(5), .modern-table:not(.fcp-index-table) td:nth-child(5) { width: 4%; min-width: 40px; } /* Occurrence */
.modern-table:not(.fcp-index-table) th:nth-child(6), .modern-table:not(.fcp-index-table) td:nth-child(6) { width: 4%; min-width: 40px; } /* Detection */
.modern-table:not(.fcp-index-table) th:nth-child(7), .modern-table:not(.fcp-index-table) td:nth-child(7) { width: 4%; min-width: 40px; } /* RPN */
.modern-table:not(.fcp-index-table) th:nth-child(8), .modern-table:not(.fcp-index-table) td:nth-child(8) { width: 8%; min-width: 80px; } /* Equipment */
.modern-table:not(.fcp-index-table) th:nth-child(9), .modern-table:not(.fcp-index-table) td:nth-child(9) { width: 6%; min-width: 60px; } /* Characteristic */
.modern-table:not(.fcp-index-table) th:nth-child(10), .modern-table:not(.fcp-index-table) td:nth-child(10) { width: 6%; min-width: 60px; } /* Special */
.modern-table:not(.fcp-index-table) th:nth-child(11), .modern-table:not(.fcp-index-table) td:nth-child(11) { width: 8%; min-width: 80px; } /* Prevention */
.modern-table:not(.fcp-index-table) th:nth-child(12), .modern-table:not(.fcp-index-table) td:nth-child(12) { width: 8%; min-width: 80px; } /* Detection */
.modern-table:not(.fcp-index-table) th:nth-child(13), .modern-table:not(.fcp-index-table) td:nth-child(13) { width: 8%; min-width: 80px; } /* Recommended */
.modern-table:not(.fcp-index-table) th:nth-child(14), .modern-table:not(.fcp-index-table) td:nth-child(14) { width: 8%; min-width: 80px; } /* Completed */
.modern-table:not(.fcp-index-table) th:nth-child(15), .modern-table:not(.fcp-index-table) td:nth-child(15) { width: 6%; min-width: 60px; } /* Create Date */
.modern-table:not(.fcp-index-table) th:nth-child(16), .modern-table:not(.fcp-index-table) td:nth-child(16) { width: 6%; min-width: 60px; } /* Update Date */
.modern-table:not(.fcp-index-table) th:nth-child(17), .modern-table:not(.fcp-index-table) td:nth-child(17) { width: 6%; min-width: 60px; } /* Status */
.modern-table:not(.fcp-index-table) th:nth-child(18), .modern-table:not(.fcp-index-table) td:nth-child(18) { 
    width: 8%; 
    min-width: 80px; 
    text-align: center;
    vertical-align: middle;
    background: rgba(102, 126, 234, 0.1);
    border-left: 2px solid rgba(255, 255, 255, 0.3);
} /* Actions column */

.modern-table.fcp-index-table {
    table-layout: auto;
    min-width: 100%;
}

/* Loading Animation */
.table-loading {
    position: relative;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.table-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Compact Table Mode */
.modern-table.compact thead th,
.modern-table.compact td {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.modern-table.compact .modern-btn {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-dot.inactive {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.status-dot.pending {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Priority Indicators */
.priority-high {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.priority-medium {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.priority-low {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

/* RPN Score Styling */
.rpn-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    height: 2rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.875rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.rpn-critical {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: white;
    animation: pulse 2s infinite;
}

.rpn-high {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    color: white;
}

.rpn-medium {
    background: linear-gradient(135deg, #d97706, #92400e);
    color: white;
}

.rpn-low {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}/* Modal A
nimation Keyframes */
@keyframes modalFadeIn {
    from { 
        opacity: 0; 
        transform: translate(-50%, -60%); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%); 
    }
}

@keyframes backdropFadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}