/**
 * TOOLiX Subscription Selector v3.0
 * 100% Isolated Styles - No interference with theme/ShopEngine
 * 
 * All classes prefixed with "toolix-selector-" to avoid conflicts
 */

/* ============================================
   WRAPPER - Completely Isolated Container
   ============================================ */
.toolix-selector-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    
    /* Reset any inherited styles */
    text-align: left;
    font-size: 14px;
    color: #333;
}

.toolix-selector-wrapper *,
.toolix-selector-wrapper *::before,
.toolix-selector-wrapper *::after {
    box-sizing: border-box;
}

/* ============================================
   LABEL
   ============================================ */
.toolix-selector-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1e3a5f;
}

.toolix-label-icon {
    font-size: 16px;
    line-height: 1;
}

.toolix-label-text {
    flex: 1;
}

/* ============================================
   CARDS STYLE
   ============================================ */
.toolix-selector-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
}

@media screen and (max-width: 768px) {
    .toolix-selector-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 400px) {
    .toolix-selector-cards {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

.toolix-selector-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 10px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    text-align: center;
    min-height: 70px;
    user-select: none;
}

.toolix-selector-card:hover {
    border-color: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.toolix-selector-card.active {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.toolix-selector-card.active::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #10b981;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

.toolix-popular-tag {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    z-index: 1;
}

.toolix-card-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1e3a5f;
    margin-bottom: 4px;
    line-height: 1.3;
}

.toolix-card-price {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #10b981;
    line-height: 1.3;
}

.toolix-selector-card.active .toolix-card-name {
    color: #065f46;
}

/* ============================================
   TABS STYLE
   ============================================ */
.toolix-selector-tabs {
    display: flex;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    width: 100%;
}

.toolix-selector-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border-right: 1px solid #e5e7eb;
    position: relative;
    min-height: 50px;
    user-select: none;
}

.toolix-selector-tab:last-child {
    border-right: none;
}

.toolix-selector-tab:hover {
    background: #f9fafb;
}

.toolix-selector-tab.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toolix-tab-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e3a5f;
    line-height: 1.3;
}

.toolix-selector-tab.active .toolix-tab-name {
    color: #ffffff;
}

.toolix-tab-price {
    font-size: 12px;
    color: #10b981;
    margin-top: 3px;
    line-height: 1.3;
}

.toolix-selector-tab.active .toolix-tab-price {
    color: rgba(255, 255, 255, 0.9);
}

.toolix-tab-badge {
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 10px;
}

/* ============================================
   DROPDOWN STYLE
   ============================================ */
.toolix-selector-dropdown {
    display: block;
    width: 100%;
    padding: 14px 45px 14px 16px;
    font-size: 15px;
    font-weight: 500;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: #1e3a5f;
}

.toolix-selector-dropdown:hover,
.toolix-selector-dropdown:focus {
    border-color: #10b981;
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media screen and (max-width: 480px) {
    .toolix-selector-label {
        font-size: 13px;
    }
    
    .toolix-selector-card {
        padding: 12px 6px;
        min-height: 60px;
    }
    
    .toolix-card-name {
        font-size: 13px;
    }
    
    .toolix-card-price {
        font-size: 14px;
    }
    
    .toolix-selector-tab {
        padding: 10px 4px;
    }
    
    .toolix-tab-name {
        font-size: 11px;
    }
    
    .toolix-tab-price {
        font-size: 10px;
    }
}

/* ============================================
   NO INTERFERENCE RULES
   These ensure our styles don't leak out
   ============================================ */

/* Don't affect anything outside our wrapper */
.toolix-selector-wrapper ~ *,
.toolix-selector-wrapper + * {
    /* No styles applied */
}

/* Ensure ShopEngine flexbox is not affected */
.shopengine-swatches .toolix-selector-wrapper,
.shopengine-add-to-cart .toolix-selector-wrapper {
    /* If somehow placed inside, stay isolated */
    position: relative;
    z-index: 1;
}
