/**
 * Swatch Variation Display Styles
 * Frontend styling for product variation swatches
 * STRUCTURAL ONLY - Layout styles come from global settings via dynamic injection
 * @version 3.0.0
 * @date 2025-10-27
 */

/* ========================================================================
   BASE SWATCH STYLING - STRUCTURAL ONLY
   ======================================================================== */

/* Swatch Row Container */
.swatch-row {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.swatch-label {
    font-weight: bold;
    margin-bottom: 5px;
}

/* Swatch Options Container */
.swatch-options {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    /* gap is applied dynamically from global settings */
}

/* ========================================================================
   SWATCH BUTTON BASE STYLES - STRUCTURAL ONLY
   ======================================================================== */

.swatch-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-width: 2px;
    border-style: solid;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #fff;
    font-size: 14px;
    padding: 4px;
    overflow: hidden;
    /* width, height, border-color, border-radius applied dynamically from global settings */
}

.swatch-btn.has-external-label {
    margin-bottom: 5px;
}

/* ========================================================================
   SWATCH TYPE-SPECIFIC STYLING
   ======================================================================== */

/* Color Swatches */
.swatch-btn.swatch-type-color {
    text-indent: -9999px;
    overflow: hidden;
}

/* Image Swatches */
.swatch-btn.swatch-type-image {
    width: 80px !important;
    height: 80px !important;
}

.swatch-btn.swatch-type-image img {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Label Swatches */
.swatch-btn.swatch-type-label {
    background-color: #f5f5f5;
    text-align: center;
}

/* Size Swatches */
.swatch-btn.swatch-type-size {
    background-color: #f0f0f0;
    text-align: center;
}

/* Text swatches need auto width */
.swatch-btn.swatch-type-text,
.swatch-btn.swatch-type-label {
    width: auto !important;
    padding: 0 12px !important;
}

/* ========================================================================
   LABEL POSITIONING
   ======================================================================== */

/* ========================================================================
   LABEL POSITIONING
   ======================================================================== */

.swatch-row.label-left {
    flex-direction: row;
    align-items: center;
}

.swatch-row.label-left .swatch-label {
    margin-right: 10px;
    margin-bottom: 0;
    min-width: 80px;
}

.swatch-row.label-right {
    flex-direction: row-reverse;
    align-items: center;
}

.swatch-row.label-right .swatch-label {
    margin-left: 10px;
    margin-bottom: 0;
    min-width: 80px;
}

.swatch-label-rtl.text-right + .swatch-options .swatch-external-label {
    text-align: right;
}

.swatch-label-rtl.text-left + .swatch-options .swatch-external-label {
    text-align: left;
}

/* ========================================================================
   ENHANCED SWATCH ITEM STYLING
   ======================================================================== */

.swatch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

/* Swatch Label */
.swatch-item .swatch-label {
    margin-top: 4px;
    text-align: center;
    font-size: 12px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.swatch-item .swatch-label-text {
    font-weight: 500;
    line-height: 1.2;
}

/* Swatch Type Indicator */
.swatch-type-indicator {
    font-size: 10px;
    opacity: 0.7;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swatch-type-indicator .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Attribute Label */
.attribute-label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
}

/* ========================================================================
   HOVER EFFECTS
   ======================================================================== */

.swatch-item:hover .swatch-label-text {
    color: #333;
    font-weight: 600;
}

.swatch-item:hover .swatch-type-indicator {
    opacity: 1;
    color: #666;
}

/* ========================================================================
   SELECTED STATE STYLING
   ======================================================================== */

.swatch-btn.selected + .swatch-label .swatch-label-text {
    color: #333;
    font-weight: 600;
}

.swatch-btn.selected + .swatch-label .swatch-type-indicator {
    opacity: 1;
    color: #333;
}

/* Swatch Checkmark */
.swatch-checkmark {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #2271b1;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.swatch-checkmark .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Enhanced Selected State */
.swatch-btn.selected {
    border-color: #2271b1;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
    transform: scale(1.05);
}

.swatch-item:hover .swatch-checkmark {
    transform: scale(1.1);
}

.swatch-btn.selected + .swatch-checkmark {
    display: flex !important;
}

/* ========================================================================
   EXTERNAL LABELS
   ======================================================================== */

.swatch-btn.swatch-type-color.has-external-label {
    position: relative;
    margin-bottom: 20px;
}

.swatch-external-label {
    display: block;
    text-align: center;
    font-size: 12px;
    margin-top: 5px;
    width: 100%;
    color: #333;
}

.swatch-row.label-left,
.swatch-row.label-right {
    flex-direction: column;
}

/* ========================================================================
   BORDER STYLES
   ======================================================================== */

.swatch-btn.border-solid {
    border-style: solid;
}

.swatch-btn.border-dashed {
    border-style: dashed;
}

.swatch-btn.border-dotted {
    border-style: dotted;
}

/* ========================================================================
   HIGHLIGHT STYLES
   ======================================================================== */

.swatch-btn.selected.highlight-shadow {
    box-shadow: 0 0 5px 2px rgba(0,0,0,0.3);
}

.swatch-btn.selected.highlight-glow {
    box-shadow: 0 0 8px 2px #0071a1;
}

.swatch-btn.selected.highlight-outline {
    outline: 2px solid #0071a1;
    outline-offset: 2px;
}

/* ========================================================================
   SPACING OPTIONS
   ======================================================================== */

.swatch-options.spacing-small {
    gap: 4px;
}

.swatch-options.spacing-medium {
    gap: 8px;
}

.swatch-options.spacing-large {
    gap: 12px;
}

/* ========================================================================
   ALTERNATIVE VARIATION STYLES
   ======================================================================== */

.variation-swatch-block { 
    margin-bottom: 18px; 
}

.swatch-options label input[type="radio"]:checked + span {
    box-shadow: 0 0 0 3px #1e40af;
    outline: 2px solid #1e40af;
}

.swatch-options label input[type="radio"] { 
    display: none; 
}

.swatch-options label { 
    transition: box-shadow .2s; 
}

.swatch-options label:hover span { 
    box-shadow: 0 0 0 2px #6366f1; 
}

/* Image Swatch Variations */
.swatch-options .swatch-image-swatch {
    display: inline-block;
    width: 120px;
    height: 120px;
    border-radius: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 3px solid #e2e8f0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.swatch-options label input[type="radio"]:checked + .swatch-image-swatch {
    border-color: #1e40af;
    box-shadow: 0 0 0 6px #c7dafe;
}

.swatch-options label:hover .swatch-image-swatch {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px #6366f1;
}

/* ========================================================================
   LAYOUT OPTIONS
   ======================================================================== */

.swatch-options.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}

.swatch-options.vertical {
    flex-direction: column;
    flex-wrap: nowrap;
}

/* ========================================================================
   LABEL INTEGRATION
   ======================================================================== */

.swatch-btn.has-lf-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.swatch-btn.lf-label-before {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    min-width: auto;
    padding: 4px 10px;
    text-align: left;
}

.swatch-btn.lf-label-after {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    min-width: auto;
    padding: 4px 10px;
    text-align: right;
}

.lf-swatch-label {
    font-size: 13px;
    line-height: 1.2;
    margin: 0 5px;
    color: #333;
    max-width: 100px;
    text-align: center;
}

.lf-label-bold {
    font-weight: bold;
}

.lf-label-italic {
    font-style: italic;
}

.lf-label-uppercase {
    text-transform: uppercase;
}

/* Inner Swatch Content */
.lf-swatch-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    min-height: 30px;
}

.swatch-btn.swatch-type-color .lf-swatch-inner {
    width: 100%;
    height: 100%;
}

/* Type-Specific Label Padding */
.swatch-type-color.has-lf-label {
    padding: 0px;
}

.swatch-type-label.has-lf-label,
.swatch-type-text.has-lf-label {
    padding: 4px 10px;
}

/* ========================================================================
   RTL SUPPORT
   ======================================================================== */

.swatch-label-rtl {
    font-weight: bold;
    margin-bottom: 8px;
    width: 100%;
}

.swatch-label-rtl.text-right {
    text-align: right;
    direction: rtl;
}

.swatch-label-rtl.text-left {
    text-align: left;
    direction: ltr;
}

.swatch-row.label-none .swatch-label-rtl {
    display: none;
}

/* ========================================================================
   RESPONSIVE STYLES
   ======================================================================== */

@media (max-width: 768px) {
    .lf-swatch-label {
        font-size: 11px;
        max-width: 70px;
        margin: 0 3px;
    }
    
    .swatch-options {
        gap: 6px;
    }
    
    .swatch-btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 13px;
    }
    
    .swatch-row {
        padding: 8px;
    }
}
