/**
 * Product Size Chart - Frontend Styles
 * Styles for the size chart button and modal
 */

/* ===================================
   Size Chart Button Styles
   =================================== */

/* Make th.label use flexbox to keep button on same line */
.variations th.label {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    text-transform: none !important;
    width: 100% !important;
}

.variations th.label label {
    text-transform: uppercase;
    flex: 0 1 auto;
    white-space: nowrap;
    margin-right: auto !important;
}

/* Button always on the right */
.variations th.label .psc-size-chart-btn,
span.psc-size-chart-btn,
.psc-size-chart-btn {
    display: inline !important;
    flex: 0 0 auto !important;
    padding: 0 !important;
    margin: 0 0 0 auto !important;
    background: none !important;
    border: none !important;
    font-size: inherit !important;
    font-weight: normal !important;
    font-family: inherit !important;
    color: inherit !important;
    cursor: pointer !important;
    text-decoration: underline !important;
    line-height: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    white-space: nowrap !important;
}

.variations th.label .psc-size-chart-btn:hover,
span.psc-size-chart-btn:hover,
.psc-size-chart-btn:hover {
    text-decoration: underline !important;
}

.variations th.label .psc-size-chart-btn:focus,
span.psc-size-chart-btn:focus,
.psc-size-chart-btn:focus {
    outline: none !important;
}

.variations th.label .psc-size-chart-btn:active,
span.psc-size-chart-btn:active,
.psc-size-chart-btn:active {
    opacity: 0.8 !important;
}

/* Mobile responsive - ensure it stays on the same line */
@media (max-width: 768px) {
    .variations th.label {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
    }
    
    .variations th.label label {
        flex: 0 1 auto;
        margin-right: 10px !important;
        font-size: 14px;
    }
    
    .variations th.label .psc-size-chart-btn {
        flex: 0 0 auto !important;
        margin-left: auto !important;
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .variations th.label label {
        font-size: 13px;
    }
    
    .variations th.label .psc-size-chart-btn {
        font-size: 13px !important;
    }
}

.psc-icon {
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* Hidden Content */
.psc-hidden-content {
    display: none !important;
    visibility: hidden;
    position: absolute;
    left: -9999px;
}

/* Force preload images */
.psc-hidden-content img {
    content-visibility: auto;
    max-width: 100%;
    height: auto;
}

/* ===================================
   Modal Styles
   =================================== */

.psc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.psc-modal.psc-modal-show {
    opacity: 1;
    visibility: visible;
}

.psc-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    cursor: pointer;
}

.psc-modal-dialog {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    z-index: 1000000;
    transform: translateY(-30px);
    transition: transform 0.3s ease;
}

.psc-modal.psc-modal-show .psc-modal-dialog {
    transform: translateY(0);
}

.psc-modal-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* Modal Header */
.psc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
    background-color: #fafafa;
}

.psc-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.psc-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.psc-modal-close:hover {
    background-color: #e5e5e5;
    color: #000;
}

.psc-modal-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Modal Body */
.psc-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.6;
}

/* Modal Body Content Styling */
.psc-modal-body h1,
.psc-modal-body h2,
.psc-modal-body h3,
.psc-modal-body h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #333;
}

.psc-modal-body p {
    margin: 0 0 12px;
    color: #555;
}

.psc-modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.psc-modal-body table th,
.psc-modal-body table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.psc-modal-body table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.psc-modal-body table tr:nth-child(even) {
    background-color: #fafafa;
}

.psc-modal-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px auto;
    border-radius: 4px;
    /* Prevent layout shift during image loading */
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

.psc-modal-body ul,
.psc-modal-body ol {
    margin: 0 0 15px;
    padding-left: 25px;
}

.psc-modal-body li {
    margin-bottom: 6px;
    color: #555;
}

/* Prevent body scroll when modal is open */
body.psc-modal-open {
    overflow: hidden;
}

/* ===================================
   Responsive Design
   =================================== */

/* Tablet - Portrait */
@media (max-width: 1024px) {
    .psc-modal-dialog {
        width: 92%;
        max-width: 700px;
    }
}

/* Tablet - Landscape & Mobile */
@media (max-width: 768px) {
    .psc-modal-dialog {
        width: 95%;
        max-width: 95%;
    }
    
    .psc-modal-header {
        padding: 16px 20px;
    }
    
    .psc-modal-title {
        font-size: 18px;
    }
    
    .psc-modal-body {
        padding: 20px;
    }
    
    .psc-size-chart-btn {
        display: flex;
        /* width: 100%; */
        margin-left: 0;
        margin-top: 10px;
        justify-content: center;
    }
    
    /* Adjust tables for mobile */
    .psc-modal-body table {
        font-size: 13px;
    }
    
    .psc-modal-body table th,
    .psc-modal-body table td {
        padding: 8px 6px;
    }
}

/* Mobile - Small Screens */
@media (max-width: 480px) {
    .psc-modal-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
    }
    
    .psc-modal-content {
        border-radius: 0;
        max-height: 100vh;
    }
    
    .psc-modal-header {
        padding: 14px 16px;
    }
    
    .psc-modal-title {
        font-size: 16px;
    }
    
    .psc-modal-body {
        padding: 16px;
    }
    
    .psc-modal-close {
        width: 32px;
        height: 32px;
        font-size: 28px;
    }
    
    .psc-size-chart-btn {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    /* Make tables scrollable on very small screens */
    .psc-modal-body table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 12px;
    }
}

/* ===================================
   Accessibility Enhancements
   =================================== */

/* Focus visible for keyboard navigation */
.psc-size-chart-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 3px;
}

.psc-modal-close:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .psc-size-chart-btn {
        border-width: 2px;
    }
    
    .psc-modal-content {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .psc-modal,
    .psc-modal-dialog,
    .psc-size-chart-btn,
    .psc-modal-close {
        transition: none;
    }
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    .psc-size-chart-btn {
        display: none;
    }
    
    .psc-modal {
        display: none;
    }
}

