/**
 * Flavors Theme Builder - Frontend Styles
 * 
 * @package Flavors Engine
 * @since 4.0.0
 */

/* Theme Builder Container Styles */
.flavor-theme-builder-header,
.flavor-theme-builder-footer,
.flavor-theme-builder-content {
    width: 100%;
    position: relative;
    z-index: 1;
}

.flavor-theme-builder-header {
    top: 0;
    left: 0;
    right: 0;
}

.flavor-theme-builder-footer {
    bottom: 0;
    left: 0;
    right: 0;
}

/* Sticky Header Support */
.flavor-theme-builder-header.flavor-sticky {
    position: fixed;
    top: 0;
    z-index: 9999;
    width: 100%;
    transition: all 0.3s ease;
}

.flavor-theme-builder-header.flavor-sticky.flavor-scrolled {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Transparent Header Support */
.flavor-theme-builder-header.flavor-transparent {
    position: absolute;
    background: transparent;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .flavor-theme-builder-header .flavor-mobile-hidden {
        display: none !important;
    }
    
    .flavor-theme-builder-header .flavor-mobile-visible {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .flavor-theme-builder-header .flavor-desktop-hidden {
        display: none !important;
    }
    
    .flavor-theme-builder-header .flavor-desktop-visible {
        display: block !important;
    }
}

/* Popup Styles */
.flavor-theme-builder-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

.flavor-theme-builder-popup.flavor-popup-active {
    display: flex;
}

.flavor-theme-builder-popup-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.flavor-theme-builder-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.flavor-theme-builder-popup-close:hover {
    background: rgba(0, 0, 0, 0.7);
}



.flavor-slide-up {
    animation: flavorSlideUp 0.3s ease-in-out;
}

@keyframes flavorFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes flavorFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes flavorSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes flavorSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Template Preview Styles */
.flavor-template-preview {
    border: 2px dashed var(--fl-line, #e7e2d7);
    padding: 20px;
    text-align: center;
    background: var(--fl-page, #f4f1ea);
    color: #666;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flavor-template-preview.flavor-template-active {
    border-color: #007cba;
    background: #f0f8ff;
    color: #007cba;
}

.flavor-template-preview-text {
    font-size: 14px;
    font-weight: 500;
}

/* Conditional Display */
.flavor-condition-hidden {
    display: none !important;
}

.flavor-condition-visible {
    display: block !important;
}

/* Loading States */
.flavor-template-loading {
    position: relative;
    opacity: 0.6;
}

.flavor-template-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--fl-line, #e7e2d7);
    border-top-color: #007cba;
    border-radius: 50%;
    animation: flavorSpin 1s linear infinite;
    z-index: 1;
}

@keyframes flavorSpin {
    to { transform: rotate(360deg); }
}

/* Error States */
.flavor-template-error {
    border: 2px solid var(--fl-stop, #a83a31);
    background: #fff0f0;
    color: var(--fl-stop, #a83a31);
    padding: 15px;
    border-radius: 4px;
    text-align: center;
}

/* Theme Compatibility */
body.flavor-theme-builder-active {
    --Flavor-header-height: auto;
    --Flavor-footer-height: auto;
}

/* Hide default theme elements when templates are active */
body.flavor-has-header-template .site-header,
body.flavor-has-header-template header {
    display: none !important;
}

body.flavor-has-footer-template .site-footer,
body.flavor-has-footer-template footer {
    display: none !important;
}

/* Elementor Integration */
.elementor-location-header .flavor-theme-builder-header,
.elementor-location-footer .flavor-theme-builder-footer {
    width: 100%;
}

/* Print Styles */
@media print {
    .flavor-theme-builder-popup,
    .flavor-theme-builder-header.flavor-sticky {
        display: none !important;
    }
    
    .flavor-theme-builder-header,
    .flavor-theme-builder-footer {
        position: static !important;
    }
}

/* Accessibility */
.flavor-theme-builder-popup:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.flavor-theme-builder-popup-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .flavor-template-preview {
        border-color: #000;
        background: #fff;
        color: #000;
    }
    
    .flavor-theme-builder-popup {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .flavor-theme-builder-header.flavor-sticky,
    .flavor-fade-in,
    .flavor-fade-out,
    .flavor-slide-down,
    .flavor-slide-up,
    .flavor-template-loading::before {
        animation: none !important;
        transition: none !important;
    }
}
