/**
 * WooCommerce Certificate Customizer - Visibility Rules Styles
 * 
 * CSS styles for the conditional visibility system
 */

/* Hidden elements */
.hidden-by-rule {
    display: none !important;
}

/* Ensure proper hiding of different element types */
.wcc-step-content.hidden-by-rule,
.wcc-field-container.hidden-by-rule,
.wcc-radio-option.hidden-by-rule,
.wcc-checkbox-option.hidden-by-rule,
.wcc-image-option.hidden-by-rule {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Hide step tabs when step content is hidden */
.wcc-step-tab.hidden-by-rule {
    display: none !important;
}

/* Smooth transitions when elements are shown/hidden */
.wcc-step-content,
.wcc-field-container,
.wcc-radio-option,
.wcc-checkbox-option,
.wcc-image-option {
    transition: opacity 0.3s ease-in-out;
}

/* Dynamic final step styling */
.wcc-final-step-dynamic .wcc-navigation-buttons .wcc-next-step {
    display: none !important;
}

.wcc-final-step-dynamic .wcc-navigation-buttons .wcc-last-step-actions {
    display: flex !important;
}

.wcc-final-step-dynamic .wcc-navigation-buttons #wcc-add-to-cart-button,
.wcc-final-step-dynamic .wcc-navigation-buttons #wcc-direct-checkout-button {
    display: inline-block !important;
}

.wcc-final-step-dynamic .wcc-navigation-buttons .wcc-confirm-step {
    display: inline-block !important;
}

/* Ensure proper button transitions */
.wcc-navigation-buttons .wcc-next-step,
.wcc-navigation-buttons .wcc-confirm-step,
.wcc-navigation-buttons .wcc-direct-checkout {
    transition: opacity 0.2s ease-in-out;
}

/* Admin styles for visibility rules interface */
.wcc-visibility-rules-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.wcc-visibility-rule {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    position: relative;
}

.wcc-visibility-rule .wcc-rule-handle {
    cursor: move;
    padding: 5px;
    color: #666;
    display: flex;
    align-items: center;
}

.wcc-visibility-rule .wcc-rule-handle:hover {
    color: #0073aa;
}

.wcc-visibility-rule select {
    min-width: 150px;
    max-width: 200px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.wcc-visibility-rule .wcc-rule-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.wcc-visibility-rule .wcc-rule-remove:hover {
    background: #c82333;
}

.wcc-rule-label {
    font-weight: 500;
    min-width: 40px;
    color: #333;
}

#wcc-visibility-rules-container {
    min-height: 50px;
    border: 2px dashed transparent;
    border-radius: 4px;
    transition: border-color 0.2s ease;
}

#wcc-visibility-rules-container.ui-sortable-helper {
    opacity: 0.8;
}

#wcc-visibility-rules-container .ui-sortable-placeholder {
    background: #f0f0f0;
    border: 2px dashed #ccc;
    height: 60px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.wcc-visibility-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* Error states for rule validation */
.wcc-rule-error {
    border-color: #dc3545 !important;
    background-color: #f8d7da !important;
}

.wcc-rule-error .wcc-rule-trigger,
.wcc-rule-error .wcc-rule-target {
    border-color: #dc3545 !important;
}

.wcc-rule-error::before {
    content: "⚠";
    position: absolute;
    top: -5px;
    left: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Success state for valid rules */
.wcc-rule-valid {
    border-color: #28a745;
    background-color: #d4edda;
}

/* Loading state */
.wcc-visibility-rules-loading {
    opacity: 0.6;
    pointer-events: none;
}

.wcc-visibility-rules-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #0073aa;
    border-radius: 50%;
    border-top-color: transparent;
    animation: wcc-spin 1s linear infinite;
}

@keyframes wcc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .wcc-visibility-rule {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .wcc-rule-label {
        text-align: center;
        min-width: auto;
    }
    
    .wcc-visibility-rule select {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
    
    .wcc-visibility-actions {
        flex-direction: column;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wcc-visibility-rule {
        border-width: 2px;
    }
    
    .wcc-rule-remove {
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wcc-step-content,
    .wcc-field-container,
    .wcc-radio-option,
    .wcc-checkbox-option,
    .wcc-image-option {
        transition: none;
    }
    
    @keyframes wcc-spin {
        to {
            transform: none;
        }
    }
}

/* Debug mode styles */
.wcc-debug-mode .hidden-by-rule {
    display: block !important;
    opacity: 0.3 !important;
    border: 2px dashed #ff6b6b !important;
    background-color: rgba(255, 107, 107, 0.1) !important;
}

.wcc-debug-mode .hidden-by-rule::before {
    content: "HIDDEN BY RULE";
    position: absolute;
    top: 0;
    left: 0;
    background: #ff6b6b;
    color: white;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    z-index: 1000;
}

/* Print styles */
@media print {
    .hidden-by-rule {
        display: none !important;
    }
    
    .wcc-visibility-rules-section {
        display: none !important;
    }
}