/* ============================================
   UNIFIED CSS for Divi - FINAL ALIGNED VERSION
   ============================================ */

/* ============================================
   DESKTOP/TABLET STYLES (Your Current 3-Column Table Layout)
   ============================================ */

/* Container for both layouts */
.rfid-details-minimal {
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Prevent creating stacking context that could interfere with modals */
    position: static;
    z-index: auto;
    transform: none;
    isolation: auto;
}

.rfid-content-wrapper {
    display: block;
    /* Prevent creating stacking context */
    position: static;
    z-index: auto;
    transform: none;
}

.rfid-specs-container {
    display: block;
    /* Prevent creating stacking context */
    position: static;
    z-index: auto;
    transform: none;
}

/* Table Styles - Desktop/Tablet (FIXED to show 3 columns) */
.rfid-specs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin-bottom: 15px;
    display: table !important; /* Force table display on desktop */
}

.rfid-specs-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.rfid-specs-table tr:last-child {
    border-bottom: none;
}

.rfid-specs-table td {
    padding: 8px 10px;
    vertical-align: top;
}

.rfid-specs-table td.spec-label {
    font-weight: 600;
    color: #555;
    width: 16.66% !important; /* Fixed width for 3-column layout */
    border-left: 3px solid #d0272f;
    padding-left: 10px;
}

.rfid-specs-table td.spec-value {
    color: #333;
    width: 16.66% !important; /* Fixed width for 3-column layout */
    padding-right: 15px;
}

.rfid-specs-table tr:hover {
    background: #f9f9f9;
}

/* ============================================
   MOBILE STYLES (Div-based Layout)
   ============================================ */

/* Mobile spec items - hidden on desktop by default */
.rfid-spec-item {
    border-left: 3px solid #d0272f;
    padding: 10px 0 10px 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    display: none; /* Hidden by default, shown on mobile */
}

/* ============================================
   SHARED STYLES (Both Layouts)
   ============================================ */

.dimension-link {
    color: #d0272f;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9em;
}

.dimension-link:hover {
    color: #a02020;
}

.external-link {
    color: #d0272f;
    text-decoration: none;
    margin-left: 5px;
    font-size: 0.85em;
    vertical-align: middle;
}

.external-link:hover {
    color: #a02020;
}

.external-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 3px;
    vertical-align: middle;
}

.rfid-view-more-btn {
    width: 100%;
    background: #d0272f;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 0.9em;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease;
}

.rfid-view-more-btn:hover {
    background: #b02020;
}

/* ============================================
   MODAL STYLES - FINAL ALIGNED VERSION
   ============================================ */

.rfid-modal-overlay,
.dimension-modal {
    display: none;
    position: fixed !important;
    z-index: 1000001 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0,0,0,0.7) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto !important;
    /* Force modal to break out of any parent stacking contexts */
    isolation: isolate;
}

.rfid-modal-overlay.active,
.dimension-modal.active {
    display: block !important;
    z-index: 1000001 !important;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.rfid-modal-content,
.dimension-modal-content {
    background-color: #fff !important;
    padding: 0;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    max-height: calc(100vh - 200px); /* DESKTOP: Leave space at bottom */
    overflow: hidden;
    position: fixed !important;
    z-index: 1000002 !important;
    top: 160px; /* DESKTOP: Fixed position to match original - below header/logo */
    left: 50%;
    transform: translateX(-50%) !important; /* DESKTOP: Only translate X */
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.dimension-modal-content {
    max-width: 600px;
}

.rfid-modal-content > h4,
.dimension-modal-content > h4 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    background: #d0272f;
    padding: 15px 50px 15px 25px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* FIXED: Close button alignment */
.rfid-modal-close,
.dimension-modal-close {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.rfid-modal-body,
.dimension-modal-body {
    padding: 15px 20px;
    max-height: calc(85vh - 60px);
    overflow-y: auto;
}

.rfid-modal-content h5 {
    margin: 10px 0 8px 0;
    font-size: 0.9em; /* MATCHED: Same as main table */
    color: #d0272f;
    font-weight: 600; /* MATCHED: Same as main table labels */
}

/* Modal table styling to match main table */
.rfid-modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em; /* MATCHED: Same as main table */
    margin-bottom: 15px;
}

.rfid-modal-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.rfid-modal-table tr:last-child {
    border-bottom: none;
}

.rfid-modal-table td {
    padding: 6px 8px;
    vertical-align: top;
}

.rfid-modal-table td:first-child {
    font-weight: 600; /* MATCHED: Same as main table labels */
    color: #555; /* MATCHED: Same as main table labels */
    width: 45%;
}

.rfid-modal-table td:last-child {
    color: #333; /* MATCHED: Same as main table values */
}

/* Right-align modal values on mobile */
@media (max-width: 768px) {
    .rfid-modal-table td:last-child {
        text-align: right;
    }
}

.dimension-diagram {
    width: 100%;
    height: auto;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.reference-note {
    margin-top: 10px !important; /* MOBILE: Move up the note */
}

/* ============================================
   RESPONSIVE BREAKPOINTS - FINAL ALIGNED VERSION
   ============================================ */

/* Tablet: 2 columns */
@media (max-width: 1024px) {
    .rfid-specs-table td.spec-label {
        width: 24% !important;
    }
    .rfid-specs-table td.spec-value {
        width: 26% !important;
    }
    /* Hide 3rd column on tablet */
    .rfid-specs-table td.spec-label:nth-child(5),
    .rfid-specs-table td.spec-value:nth-child(6) {
        display: none;
    }
}

/* Mobile: Switch to div layout - FINAL ALIGNED VERSION */
@media (max-width: 768px) {
    /* Hide table layout on mobile */
    .rfid-specs-table {
        display: none !important;
    }
    
    /* Show and style mobile div layout */
    .rfid-spec-item {
        display: flex;
        align-items: flex-start;
        padding: 14px 18px;
        margin-bottom: 12px;
        background: #fff;
        border-bottom: 1px solid #e0e0e0;
        transition: background 0.2s ease;
    }
    
    .rfid-spec-item:hover {
        background: #f9f9f9;
    }
    
    /* MOBILE: Label styling with right alignment for values */
    .rfid-spec-item .spec-label {
        font-weight: 700;
        color: #555;
        font-size: 1.1em !important;
        min-width: 160px !important;
        flex-shrink: 0;
        margin-right: 15px;
        padding-top: 2px;
        display: block;
        line-height: 1.3;
    }
    
    /* MOBILE: Value styling with right alignment */
    .rfid-spec-item .spec-value {
        color: #333;
        font-size: 1.1em !important;
        flex: 1;
        word-wrap: break-word;
        line-height: 1.3;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        text-align: right;
    }
    
    /* Override alignment for inline elements */
    .rfid-spec-item .spec-value > * {
        text-align: left;
        justify-content: flex-start;
    }
    
    /* External link styling for mobile */
    .rfid-spec-item .external-link {
        color: #d0272f;
        text-decoration: none;
        display: inline-flex !important;
        align-items: center;
        vertical-align: middle;
        white-space: nowrap;
    }
    
    .rfid-spec-item .external-link:hover {
        color: #a02020;
    }
    
    .rfid-spec-item .external-icon {
        display: inline-block;
        width: 14px;
        height: 14px;
        margin-left: 3px;
        vertical-align: middle;
        flex-shrink: 0;
    }
    
    /* Value text wrapper */
    .rfid-spec-item .value-text {
        display: inline;
        margin-right: 5px;
    }
    
    /* Dimension text */
    .rfid-spec-item .dimension-text {
        display: inline;
        margin-right: 5px;
    }
    
    /* Dimension link */
    .rfid-spec-item .dimension-link {
        color: #d0272f;
        text-decoration: underline;
        cursor: pointer;
        font-size: 0.95em !important;
        display: inline !important;
        white-space: nowrap;
    }
    
    .rfid-spec-item .dimension-link:hover {
        color: #a02020;
    }
    
    .rfid-details-minimal {
        padding: 0 10px;
    }
    
    .rfid-view-more-btn {
        padding: 16px 20px;
        font-size: 1.1em !important;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .rfid-view-more-btn:active {
        transform: scale(0.98);
    }
    
    /* MOBILE: Disclaimer positioning */
    .disclaimer-text {
        margin-top: 0 !important;
    }
    
    /* MOBILE: Modal adjustments - FIXED positioning */
    .rfid-modal-content,
    .dimension-modal-content {
        width: 95%;
        max-height: 90vh;
        top: 50%; /* MOBILE: Center vertically */
        transform: translate(-50%, -50%); /* MOBILE: Center both */
    }
    
    .rfid-modal-body,
    .dimension-modal-body {
        padding: 15px;
        max-height: calc(90vh - 50px);
    }
    
    .rfid-modal-content > h4,
    .dimension-modal-content > h4 {
        padding: 12px 40px 12px 15px;
        font-size: 1.1em !important;
        display: flex;
        align-items: center;
    }
    
    /* MOBILE: Fixed close button positioning */
    .rfid-modal-close,
    .dimension-modal-close {
        font-size: 24px;
        top: 50%;
        right: 15px;
        transform: translateY(-50%);
    }
}

/* Desktop: Hide mobile layout and show table */
@media (min-width: 769px) {
    .rfid-spec-item {
        display: none !important;
    }
    
    .rfid-specs-table {
        display: table !important;
    }
}

/* Extra small mobile - Final adjustments */
@media (max-width: 480px) {
    .rfid-details-minimal {
        padding: 0 8px;
    }
    
    .rfid-spec-item {
        padding: 12px 15px;
        margin-bottom: 10px;
    }
    
    .rfid-spec-item .spec-label {
        font-size: 1em !important;
        min-width: 130px !important;
        margin-right: 12px;
    }
    
    .rfid-spec-item .spec-value {
        font-size: 1em !important;
    }
    
    .rfid-spec-item .external-link {
        font-size: 0.9em;
    }
    
    .rfid-view-more-btn {
        padding: 14px 18px;
        font-size: 1em !important;
    }
}