<?php

/*----------------------------------------------------------------------------------*/

$elite_security_guard_common_inline_css = '';

// Allow preloader fadeOut animation to work properly
$elite_security_guard_common_inline_css .= ".loading {
    transition: opacity 0.5s ease-in-out;
}
.loading:hidden {
    opacity: 0;
    visibility: hidden;
}";

$elite_security_guard_scroll_top_alignment = get_theme_mod('elite_security_guard_scroll_top_alignment', 'Right');

$elite_security_guard_alignment_styles = [
    'Left' => 'left: 20px;',
    'Center' => 'right: 0; left: 0; margin: 0 auto;',
    'Right' => 'right: 20px;'
];

$alignment_style = $elite_security_guard_alignment_styles[$elite_security_guard_scroll_top_alignment] ?? $elite_security_guard_alignment_styles['Right'];

$elite_security_guard_common_inline_css .= "a.scrollup,button#scroll_2 { $alignment_style }";

/*----------------------------------------------------------------------------------*/


$elite_security_guard_footer_background_color = get_theme_mod('elite_security_guard_footer_background_color', '#242424');

if (!empty($elite_security_guard_footer_background_color)) {
    $elite_security_guard_common_inline_css .= ".footer-widgets { background: " . esc_attr($elite_security_guard_footer_background_color) . "}";
}

/*----------------------------------------------------------------------------------*/

$elite_security_guard_footer_background_image = get_theme_mod('elite_security_guard_footer_background_image', '');

if (!empty($elite_security_guard_footer_background_image)) {
    $elite_security_guard_common_inline_css .= ".footer-widgets { background-image: url('" . esc_url($elite_security_guard_footer_background_image) . "') !important; background-size: cover; background-repeat: no-repeat; }";
}

/*----------------------------------------------------------------------------------*/

$elite_security_guard_copyright_alignment = get_theme_mod('elite_security_guard_copyright_alignment', 'Center');

$elite_security_guard_copyright_alignment_styles = [
    'Left' => 'text-align: left;',
    'Center' => 'text-align: center;',
    'Right' => 'text-align: right;'
];

$alignment_style = $elite_security_guard_copyright_alignment_styles[$elite_security_guard_copyright_alignment] ?? $elite_security_guard_copyright_alignment_styles['Center'];

$elite_security_guard_common_inline_css .= "#footer-copyright p { $alignment_style }";

/*----------------------------------------------------------------------------------*/

$elite_security_guard_container_width = get_theme_mod('elite_security_guard_container_width');

if (!empty($elite_security_guard_container_width)) {
    $elite_security_guard_common_inline_css .= "@media (min-width: 1024px) { 
        body, .navbar-area.header-fixed, .admin-bar .header-fixed,.loading { 
            width: " . esc_attr($elite_security_guard_container_width) . "%; 
            margin: 0 auto; 
        } 
        .admin-bar .header-fixed { 
            margin-top: 32px; 
        } 
    }";
}  

/*----------------------------------------------------------------------------------*/

$elite_security_guard_responsive_scroll_to_top_setting = get_theme_mod( 'elite_security_guard_responsive_scroll_to_top_setting', false );

if ( $elite_security_guard_responsive_scroll_to_top_setting == true && get_theme_mod( 'elite_security_guard_scroll_to_top_setting', false ) != true ) {
    $elite_security_guard_common_inline_css .= "a.scrollup,button#scroll_2 {
        display: none !important;
    }";
}

if ( $elite_security_guard_responsive_scroll_to_top_setting == true ) {
    $elite_security_guard_common_inline_css .= "@media screen and (max-width: 768px) {
        a.scrollup,button#scroll_2 {
            display: block !important;
        }
    }";
} elseif ( $elite_security_guard_responsive_scroll_to_top_setting == false ) {
    $elite_security_guard_common_inline_css .= "@media screen and (max-width: 768px) {
        a.scrollup,button#scroll_2 {
            display: none !important;
        }
    }";
}

/*---------------------------Responsive Preloader-------------------*/

$elite_security_guard_responsive_preloader_setting = get_theme_mod( 'elite_security_guard_responsive_preloader_setting', false );
$elite_security_guard_preloader_setting = get_theme_mod( 'elite_security_guard_preloader_setting', false );

// If only responsive preloader is enabled (desktop preloader disabled)
if ( $elite_security_guard_responsive_preloader_setting == true && $elite_security_guard_preloader_setting == false ) {
    $elite_security_guard_common_inline_css .= "@media screen and (min-width: 769px) {
        .loading {
            display: none;
        }
    }";
}
// If only desktop preloader is enabled (responsive disabled)
elseif ( $elite_security_guard_preloader_setting == true && $elite_security_guard_responsive_preloader_setting == false ) {
    $elite_security_guard_common_inline_css .= "@media screen and (max-width: 768px) {
        .loading {
            display: none;
        }
    }";
}
// If both are disabled
elseif ( $elite_security_guard_preloader_setting == false && $elite_security_guard_responsive_preloader_setting == false ) {
    $elite_security_guard_common_inline_css .= ".loading {
        display: none;
    }";
}
// If both are enabled, show on all devices (no additional CSS needed)

/*---------------------------Global Color-------------------*/

$elite_security_guard_theme_color_1 = get_theme_mod('elite_security_guard_theme_color_1');

/*--- First Global Color ---*/

if ($elite_security_guard_theme_color_1) {
  $elite_security_guard_common_inline_css .= ':root {';
  $elite_security_guard_common_inline_css .= '--first-color: ' . esc_attr($elite_security_guard_theme_color_1) . ' !important;';
  $elite_security_guard_common_inline_css .= '} ';
}