/**
 * Frontend Styles - Product Variants Auto
 * Giữ nguyên style từ plugin cũ + thêm thumbnail & dropdown
 */

/* Title */
.product-variants-title {
    margin-bottom: 20px;
    font-size: 14px !important;
    color: #444 !important;
    line-height: 16px !important;
    font-weight: bold !important;
}

/* Grid Container */
.product-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.product-variants a:hover {
    color: #444 !important;
}

/* Variant Item - Grid */
.variant-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    text-decoration: none;
    color: #444 !important;
    min-width: 120px;
    width: 23%;
    text-align: center;
    transition: all 0.1s ease;
    position: relative;
}

/* Thumbnail */
.variant-thumbnail {
    width: 100%;
    overflow: hidden;
    margin-bottom: 8px;
    border-radius: 3px;
}

.variant-thumbnail img {
    width: 20%;
    object-fit: cover;
}

/* Title & Price */
.variant-title {
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: bold;
}

.variant-price,
.out-of-stock {
    font-size: 12px;
    color: #444 !important;
}

/* Active State */
.variant-item.active {
    border-color: #D0011B;
}

.variant-item.active .variant-price {
    color: #444 !important;
}

/* Active Checkmark */
.variant-item.active::after {
    content: "✓";
    position: absolute;
    right: 0;
    top: 0;
    background-color: #D0011B;
    color: #fff;
    font-size: 10px;
    height: 13px;
    padding-bottom: 15px;
    padding-left: 2px;
    width: 18px;
    border-radius: 0 0 0 10px;
    z-index: 2;
}

/* Out of Stock Style */
.variant-item.out-of-stock {
    opacity: 1;
    position: relative;
    overflow: hidden;
}

.variant-item.out-of-stock::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        rgba(209, 213, 219, 0.7) calc(50% - 1px),
        rgba(209, 213, 219, 0.7) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
    z-index: 1;
    pointer-events: none;
}

.variant-item.out-of-stock .variant-price {
    color: #dc3545 !important;
}

.variant-item.out-of-stock:hover {
    opacity: 1;
}

/* Active + Out of Stock */
.variant-item.active.out-of-stock {
    opacity: 1;
}

.variant-item.active.out-of-stock::before {
    background: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        rgba(208, 1, 27, 0.7) calc(50% - 1px),
        rgba(208, 1, 27, 0.7) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}

/* ========================================
   DROPDOWN LAYOUT
   ======================================== */

.pva-dropdown-layout .product-variants-title {
    margin-bottom: 10px;
}

.pva-dropdown-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

/* Selected Display */
.pva-dropdown-selected {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.pva-dropdown-selected:hover {
    border-color: #D0011B;
}

.pva-dropdown-selected.open {
    border-color: #D0011B;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.pva-dropdown-thumb {
    width: 40px;
    height: 52px;
    object-fit: cover;
    border-radius: 3px;
}

.pva-dropdown-text {
    flex: 1;
    font-size: 14px;
    color: #444;
}

.pva-dropdown-arrow {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s ease;
}

.pva-dropdown-selected.open .pva-dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Options */
.pva-dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #D0011B;
    border-top: none;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.pva-dropdown-options.show {
    display: block;
}

/* Option Item */
.pva-dropdown-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    text-decoration: none;
    color: #444 !important;
    transition: background-color 0.1s ease;
    border-bottom: 1px solid #eee;
}

.pva-dropdown-option:last-child {
    border-bottom: none;
}

.pva-dropdown-option:hover {
    background-color: #f9f9f9;
}

.pva-dropdown-option.active {
    background-color: #fff5f5;
}

.pva-dropdown-option.out-of-stock {
    opacity: 0.6;
}

.pva-dropdown-option.out-of-stock .pva-option-price {
    color: #dc3545;
}

.pva-option-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
}

.pva-option-price {
    font-size: 13px;
    color: #666;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media screen and (max-width: 768px) {
    .variant-item {
        width: 48%;
    }
    
    .pva-dropdown-container {
        max-width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .variant-item {
        width: 48%;
    }
}