<?php

function logingpower_loginsec_styles() {
		if ( !empty(get_option('logingpower_settings')['logingpower_loginsec_bgcolor'] )){
	 	$logingpower_style =' body.login div#login {  background-color:'.  esc_attr( get_option('logingpower_settings')['logingpower_loginsec_bgcolor'] ).'!important; }';
	 	wp_add_inline_style('login',$logingpower_style);
		}
		// section position
		if ( !empty(get_option('logingpower_settings')['logingpower_loginsec_position'] )){

			$position=sanitize_text_field( get_option('logingpower_settings')['logingpower_loginsec_position']);
			$loginsec_style='';
			$sec_width=  absint(get_option('logingpower_settings')['logingpower_loginsec_width'] ??320);
			switch ($position) {
				case 'None':
				 	$loginsec_style=' auto ';
					break;
				case 'Top-Left':
				 	$loginsec_style='0 100% 0 0  ';
					break;
				case 'Top-Center':
					$loginsec_style=' 0 auto 0 auto ';
					break;
				case 'Top-Right':
				 	$loginsec_style=' 0 0 0 auto ';
					break;
				case 'Left-Center':
				 	$loginsec_style=' 5% auto 5% 0 ';
					break;
				case 'Center-Center':
					$loginsec_style=' 5%  auto ';
					break;
				case 'Right-Center':
				 	$loginsec_style=' 5% 0 5% auto ';
					break;
				case 'Bottom-Left':
					$loginsec_style=' 5% auto 0 0 ';
					break;
				case 'Bottom-Center':
				 	$loginsec_style=' 5% auto 0 ';
					break;
				case 'Bottom-Right':
				 	$loginsec_style='5% 0 0 auto ';
					break;
				default:
					$loginsec_style='auto ';
					break;
			}	
			$logingpower_style = ' body.login div#login { 
				width:'.esc_attr($sec_width).'px;
				padding: 5% 0 0;
				margin: '.esc_attr($loginsec_style).'!important ;
				}';
			wp_add_inline_style('login',$logingpower_style);
		}

		//Section image 
		if ( !empty(get_option('logingpower_settings')['logingpower_loginsec_bgimg_show']) ) :	
			 $logingpower_style="body.login div#login{ background-image:url(". esc_url( get_option('logingpower_settings')['logingpower_loginsec_bgimg'] ) ." )!important;}";
			wp_add_inline_style('login',$logingpower_style);
		endif;
		$loginsec_bgimg_style='auto';

		if (!empty(get_option('logingpower_settings')['logingpower_loginsec_bgimg_size'])) 
			$loginsec_bgimg_size=  sanitize_text_field(get_option('logingpower_settings')['logingpower_loginsec_bgimg_size']);
			
			switch ($loginsec_bgimg_size) {
				case 'auto':
				 	$loginsec_bgimg_style='auto';
					break;
				case 'width':
				 $loginsec_bgimg_style='100%  auto';
					break;
				case 'height':
					$loginsec_bgimg_style='auto 100%';
					break;
				case 'both':
				 $loginsec_bgimg_style='100%  100%';
					break;
				default:
					$loginsec_bgimg_style='auto';
					break;
			}
		
			
			$logingpower_loginsec_bgimg_repeat='no-repeat';
			if(!empty(get_option('logingpower_settings')[ 'logingpower_loginsec_bgimg_repeat' ])) 
			$logingpower_loginsec_bgimg_repeat=get_option('logingpower_settings')[ 'logingpower_loginsec_bgimg_repeat' ];
			$logingpower_style= ' body.login div#login { 
			
			background-position: center top !important;
			background-repeat: ' . esc_attr( $logingpower_loginsec_bgimg_repeat) . '!important;
		  	display:block;   
		  	background-attachment: fixed !important;

		  	 background-size:'.esc_attr($loginsec_bgimg_style).'!important; 
		  	 }';
		  	 wp_add_inline_style('login',$logingpower_style);
		
		$sec_border_radius_topleft=absint( get_option('logingpower_settings')[ 'logingpower_loginsec_border_radius_topleft' ]?? 0) ;
		$sec_border_radius_topright=absint(get_option('logingpower_settings')[ 'logingpower_loginsec_border_radius_topright' ]?? 0) ;
		$sec_border_radius_bottomright= absint(get_option('logingpower_settings')[ 'logingpower_loginsec_border_radius_bottomright' ]?? 0 );
		$sec_border_radius_bottomleft=absint(get_option('logingpower_settings')[ 'logingpower_loginsec_border_radius_bottomleft' ]?? 0 );
		$logingpower_style= ' body.login div#login { 
				border-radius:' . esc_attr( $sec_border_radius_topleft ) .'px '. esc_attr( $sec_border_radius_topright ) .'px '. esc_attr(  $sec_border_radius_bottomright) .'px '. esc_attr($sec_border_radius_bottomleft  ) .'px !important;
				} 	';
		wp_add_inline_style('login',$logingpower_style);
	}add_action( 'login_enqueue_scripts', 'logingpower_loginsec_styles') ;
	// add_action( 'login_head', 'logingpower_loginsec_styles') ;