<?php 
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
ob_start();
session_start();
include_once(__DIR__ . "/config.php");
include_once("functions.php");
$page_name = '';
$lang_code_global = "English";
$global_currency = "$";
$currency_position = "left";
$currency_sep = ".";
$localization = array();
$cookie_name = "ams_lang_code";
$cookie_name_branch = "ams_branch_code";

if(!check_login()){
	header("Location: ".WEB_URL."logout.php");
	die();
}
$super_admin_image = 'img/no_image.jpg';
$query_ams_settings = mysqli_query($link,"SELECT * FROM settings");
if($row_query_ams_core = mysqli_fetch_array($query_ams_settings)){
	$localization = $row_query_ams_core;
	$lang_code_global = $row_query_ams_core['lang_code'];
	$global_currency = $row_query_ams_core['currency'];
	$currency_position = $row_query_ams_core['currency_position'];
	$currency_sep = $row_query_ams_core['currency_seperator'];
	if($row_query_ams_core['super_admin_image'] != ''){
		$super_admin_image = WEB_URL . 'img/upload/' . $row_query_ams_core['super_admin_image'];
	}
}
//set lang from cookie
if(isset($_COOKIE[$cookie_name]) && !empty($_COOKIE[$cookie_name])) {
	$lang_code_global = $_COOKIE[$cookie_name];
}

include_once(ROOT_PATH.'language/'.$lang_code_global.'/lang_left_menu.php');
include_once(ROOT_PATH.'language/'.$lang_code_global.'/lang_common.php');
include_once(ROOT_PATH.'library/helper.php');
include_once(ROOT_PATH."library/maxPower.php");
//instance 
$ams_helper = new ams_helper();

////////////////////////////////////////////APARTMENT DETAILS/////////////////////////////////////////////////////////////////////////////////////
$building_rules = '';
$building_name = '';
$moderator_mobile = '';
$secrataty_mobile = '';
$security_guard_mobile = '';
$result_apartment = mysqli_query($link,"SELECT * FROM tblbranch LIMIT 1");
if($row_apartment = mysqli_fetch_array($result_apartment)){
	$building_rules = $row_apartment['building_rule'];
	$building_name = $row_apartment['branch_name'];
	$moderator_mobile = $row_apartment['moderator_mobile'];
	$secrataty_mobile = $row_apartment['secrataty_mobile'];
	$security_guard_mobile = $row_apartment['security_guard_mobile'];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////admin image/////////////////////////
$image = WEB_URL . 'img/no_image.jpg';	
if(isset($_SESSION['image'])){
	if(file_exists(ROOT_PATH . '/img/upload/' . $_SESSION['image']) && $_SESSION['image'] != ''){
		$image = WEB_URL . 'img/upload/' . $_SESSION['image'];
	}
}
if(isset($_SESSION['login_type']) && ((int)$_SESSION['login_type'] == 5)){
	$image = $super_admin_image;
}
/////////////////////////////////////////////////////////////

include_once(ROOT_PATH."library/encryption.php");
$converter = new Encryption;
$page_name = $ams_helper->curPageUrlInfo('page');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Property Management</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php include_once(ROOT_PATH.'/partial/header_script.php'); ?>
<style>
  /* ===== Neutral white theme + colored action keys ===== */
  :root{
    --white:#ffffff;
    --ink:#111111;
    --ink-2:#2b2b2b;
    --line:#e5e7eb;
    --shadow:0 6px 24px rgba(0,0,0,.08);

    /* Action palette */
    --accent:#4f46e5;   /* primary action indigo */
    --accent-700:#4338ca;
    --success:#22c55e;  /* green */
    --warning:#f59e0b;  /* amber */
    --danger:#ef4444;   /* red */
    --info:#0ea5e9;     /* cyan/sky */
    --muted:#eef2ff;    /* light indigo tint */
  }

  /* Base */
  html, body { background:#fff; color:var(--ink-2); }
  body.skin-blue.sidebar-mini{ background:#fff; }

  a, .nav>li>a, .sidebar a, .dropdown-menu>li>a { color:#334155; }
  a:hover, .nav>li>a:hover, .sidebar a:hover, .dropdown-menu>li>a:hover { color:var(--accent); text-decoration:none; }

  /* Header / Navbar */
  .main-header .logo,
  .main-header .navbar,
  nav.navbar-static-top{
    background:#fff !important;
    border:0;
    border-bottom:1px solid var(--line);
    box-shadow:var(--shadow);
    color:var(--ink);
  }
  .main-header .logo { color:var(--ink) !important; }
  .main-header .logo .logo-mini,
  .main-header .logo .logo-lg { color:var(--ink); font-weight:bold; }
  .sidebar-toggle { color:var(--accent) !important; }
  .sidebar-toggle:hover { background:var(--muted) !important; }

  /* Let inline-colored action pills in navbar keep their color */
  .navbar-custom-menu .navbar-nav>li[style]{
    border-radius:10px;
    margin:6px 6px;
    overflow:hidden;
  }
  .navbar-custom-menu .navbar-nav>li[style] > a{
    color:#fff !important;
    font-weight:700;
  }
  .navbar-custom-menu .navbar-nav>li > a:hover{ opacity:.9; }

  /* Keep the rest neutral */
  .navbar-custom-menu .navbar-nav>li:not([style]) > a { color:var(--ink) !important; }

  /* Sidebar — white with subtle active color */
  .main-sidebar{
    background:#fff !important;
    color:var(--ink);
    border-right:1px solid var(--line);
    box-shadow:var(--shadow);
  }
  .user-panel{ background:#fff !important; border-bottom:1px solid var(--line); }
  .user-panel .info p{ color:var(--ink); font-weight:bold; }
  .user-panel .info a{ color:var(--success); }

  .sidebar { color:var(--ink-2); }
  .sidebar-menu>li>a{
    color:#334155 !important;
    background:#fff !important;
    border-radius:10px;
    margin:4px 10px;
    font-weight:700;
  }
  .sidebar-menu>li>a .fa{ color:var(--accent); }
  .sidebar-menu>li>a:hover{
    background:var(--muted) !important;
    color:var(--accent) !important;
  }
  .sidebar-menu>li.active>a,
  .treeview.active>a{
    background:var(--muted) !important;
    color:var(--accent) !important;
    border-left:4px solid var(--accent);
    border-radius:10px;
  }
  .treeview-menu{
    background:#fff !important;
    border:1px solid var(--line);
    border-radius:10px;
    margin:0 10px 10px 10px;
    padding:6px 0;
  }
  .treeview-menu>li>a{
    color:#334155 !important;
    padding:8px 12px;
    border-radius:8px;
  }
  .treeview-menu>li>a:hover{
    background:var(--muted) !important; color:var(--accent) !important;
  }

  /* Content shell */
  .content-wrapper{ background:#fff; }

  /* Cards/boxes */
  .box{
    background:#fff;
    border:1px solid var(--line);
    border-radius:12px;
    box-shadow:var(--shadow);
  }
  .box .box-header{
    background:#fff;
    border-bottom:1px solid var(--line);
  }
  .box .box-header h3, .box .box-header h4, .box .box-header h2{
    color:#0f172a; /* deep slate */
    font-weight:bold;
  }
  .box .box-body{ color:#334155; }

  /* Tables */
  .table { background:#fff; }
  .table>thead>tr>th{
    background:#fff;
    color:#0f172a;
    border-bottom:2px solid var(--line);
    font-weight:800;
  }
  .table>tbody>tr>td{
    border-top:1px solid var(--line);
    color:#334155;
  }
  .table>tbody>tr:hover{ background:#f8fafc; }

  /* === Action keys (buttons/CTAs) — colored === */
  .btn{
    border:1px solid var(--line);
    border-radius:10px;
    font-weight:700;
    box-shadow:none;
    transition:transform .08s ease, box-shadow .12s ease, opacity .12s ease, background .12s ease;
  }
  .btn:hover{ transform:translateY(-1px); box-shadow:0 6px 16px rgba(0,0,0,.06); }

  .btn-primary,
  .btn.btn-info.btn-flat[data-target],
  .navbar .btn-primary{
    background:var(--accent) !important;
    border-color:var(--accent) !important;
    color:#fff !important;
  }
  .btn-primary:hover,
  .btn.btn-info.btn-flat[data-target]:hover{
    background:var(--accent-700) !important;
    border-color:var(--accent-700) !important;
  }

  .btn-success{
    background:var(--success) !important;
    border-color:var(--success) !important;
    color:#fff !important;
  }
  .btn-success:hover{ opacity:.95; }

  .btn-warning{
    background:var(--warning) !important;
    border-color:var(--warning) !important;
    color:#111 !important;
  }
  .btn-danger{
    background:var(--danger) !important;
    border-color:var(--danger) !important;
    color:#fff !important;
  }
  .btn-info{
    background:var(--info) !important;
    border-color:var(--info) !important;
    color:#fff !important;
  }

  /* Flat variant still colored */
  .btn.btn-flat{
    border-width:0 !important;
    color:#fff !important;
  }

  /* Dropdowns / user menu */
  .dropdown-menu, .user-menu .dropdown-menu{
    background:#fff;
    border:1px solid var(--line);
    border-radius:12px;
    box-shadow:var(--shadow);
  }
  .user-menu .user-header{
    background:#fff;
    color:#334155;
    border-bottom:1px solid var(--line);
  }
  .user-menu .user-footer{ background:#fff; border-top:1px solid var(--line); }

  /* Modals */
  .modal-content{
    background:#fff;
    color:#334155;
    border:1px solid var(--line);
    border-radius:12px;
    box-shadow:var(--shadow);
  }
  .modal-header{
    background:#fff;
    border-bottom:1px solid var(--line);
    color:#0f172a;
  }
  .modal-footer{ background:#fff; border-top:1px solid var(--line); }

  /* Header sizing kept the same as your original */
  nav.navbar-static-top{ height:50px; padding:0 1rem; }
  .nav>li>a{ padding:10px 15px; }

  @media (max-width: 991px){
    .navbar-custom-menu .navbar-nav > li > a {
      padding-top: 15px;
      padding-bottom: 15px;
      line-height: 20px;
    }
  }
  @media (min-width: 768px){
    .navbar-nav>li>a { padding-top: 15px; padding-bottom: 15px; }
  }
</style>
</head>
<body class="skin-black sidebar-mini" style="background:linear-gradient(180deg,#0b1220 0%, #070b14 500%);">

<!-- Site wrapper -->
<div class="wrapper">
<header class="main-header">
  <!-- Logo -->
  <a class="logo">
  <!-- mini logo for sidebar mini 50x50 pixels -->
  <span class="logo-mini"><i class="fa fa-bank"></i></span> <span class="logo-lg" style="text-transform:uppercase;font-weight:bold;overflow:hidden;"><i class="fa fa-bank"></i> <?= $building_name; ?> </a>
  <!-- Header Navbar: style can be found in header.less -->
  <nav class="navbar navbar-static-top" role="navigation">
    <!-- Sidebar toggle button-->
    <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a>
    <div class="navbar-custom-menu">
      <ul class="nav navbar-nav list-group list-group-horizontal">
        <li class="hidden-xs" style="background:#000;"> <a href="<?= WEB_URL; ?>dashboard.php"> <i style="font-size:18px;" class="fa fa-home"></i></a> </li>
        <li class="hidden-xs" style="background:#e08e0b;"> <a href="<?= WEB_URL; ?>mailsms/mailsms.php"><i style="font-size:18px;" class="fa fa-envelope-o"></i></a> </li>
		<!-- User Account: style can be found in dropdown.less -->
        <li class="dropdown user user-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">  <span class="hidden-xs"> <?= $_SESSION['name']; ?> </span> </a>
          <ul class="dropdown-menu">
            <!-- User image -->
            <li class="user-header"> <img src="<?= $image; ?>" class="img-circle" alt="User Image" />
              <p> <?= $_SESSION['name']; ?> <small>
                <?php if($_SESSION['login_type'] == '1'){echo $_data['user_admin'];} else {echo $_data['user_super_admin'];}?>
                <br/>
              </p>
              </small> 
            </li>
            <!-- Menu Body -->
            <!-- Menu Footer-->
            <li class="user-footer">
              <div class="col-md-12" style="margin-bottom: 10px;">
                <div style="margin-bottom:7px;"><a href="javascript:;" data-toggle="modal" data-target="#switch_language" class="btn btn-info btn-flat" style="width:100%"><?= $_data['user_lang_switch']; ?></a></div>
                <?php if((int)$_SESSION['login_type'] == 5){ ?><div><a href="javascript:;" data-toggle="modal" data-target="#switch_branch" class="btn btn-warning btn-flat" style="width:100%"><?= $_data['user_branch_switcher']; ?></a></div><?php } ?>
              </div>
              <div class="pull-left"><a data-target="#user_profile" data-toggle="modal" class="btn btn-success btn-flat"><?= $_data['lang_profile']; ?></a></div>
              <div class="pull-right"> <a href="<?= WEB_URL; ?>logout.php" class="btn btn-danger btn-flat"><?= $_data['lang_signout']; ?></a> </div>
            </li>
          </ul>
        </li>
        <?php if((int)$_SESSION['login_type'] == 5){ ?>
        <li class="hidden-xs"> <a href="<?= WEB_URL; ?>setting/language.php"><i class="fa fa-gears"></i></a> </li>
        <?php } ?>
      </ul>
    </div>
  </nav>
</header>
<!-- =============================================== -->
<!-- Left side column. contains the sidebar -->
<aside class="main-sidebar">
  <!-- sidebar: style can be found in sidebar.less -->
  <div class="user-panel" style="background:#000;">
    <div class="pull-left image"> <img src="<?= $image; ?>" class="img-circle" alt="User Image"> </div>
    <div class="pull-left info">
      <p><?= $_SESSION['name']; ?></p>
      <a href="#"><i class="fa fa-circle text-success" style="color:#00a65a !important;"></i> <?= $_data['lang_online']; ?></a> </div>
  </div>
  <section class="sidebar">
    <!-- sidebar menu: : style can be found in sidebar.less -->
    <ul class="sidebar-menu">
      <li class="<?php if($page_name != '' && $page_name == 'dashboard'){echo 'active';}?>"><a href="<?= WEB_URL; ?>dashboard.php"><i class="fa fa-line-chart"></i> <span><?= $_data['menu_dashboard']; ?></span></a> </li>
     <li class="<?php if($page_name != '' && $page_name == 'dollar_dashboard'){echo 'active';}?>"><a href="<?= WEB_URL; ?>foreign_currency_dashboard.php"><i class="fa fa-line-chart"></i> <span><?= $_data['menu_dashboard_2'] ?></span></a> </li>
      
    <li class="treeview <?php if($page_name != '' && $page_name == 'addtenant' || $page_name == 'tenantlist'){echo 'active';}?>">
  <a href="#" style="font-weight:800;">
    <i class="fa fa-users"></i>
    <span><strong><?= $_data['menu_renter_information']; ?></strong></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>
  <ul class="treeview-menu">
    <li class="<?php if($page_name != '' && $page_name == 'tenantlist'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>tenant/tenantlist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_renter_list']; ?></strong>
      </a>
    </li>
    <li class="<?php if($page_name != '' && $page_name == 'addtenant'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>tenant/addtenant.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_renter']; ?></strong>
      </a>
    </li>
    <li class="<?php if($page_name != '' && $page_name == 'tenantalist'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>tenant/tenantalist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_renterr_list']; ?></strong>
      </a>
    </li>
  </ul>
</li>


      <li class="treeview <?php if($page_name != '' && $page_name == 'addbuyer' || $page_name == 'buyerlist'){echo 'active';}?>">
  <a href="#" style="font-weight:800;">
    <i class="fa fa-users"></i>
    <span><strong><?= $_data['menu_buyer_information']; ?></strong></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>
  <ul class="treeview-menu">
    <li class="<?php if($page_name != '' && $page_name == 'buyerlist'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>buyer/buyerlist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_buyer_list']; ?></strong>
      </a>
    </li>
    <li class="<?php if($page_name != '' && $page_name == 'addbuyer'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>buyer/addbuyer.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_buyer']; ?></strong>
      </a>
    </li>
    </ul>
</li>


      <!--<li class="treeview <?php if($page_name != '' && $page_name == 'addbuyer' || $page_name == 'buyerlist'){echo 'active';}?>"> <a href="#"> <i class="fa fa-users"></i> <span><?= $_data['menu_buyer_information']; ?></span> <i class="fa fa-angle-left pull-right"></i> </a>-->
      <!--  <ul class="treeview-menu">-->
      <!--    <li class="<?php if($page_name != '' && $page_name == 'buyerlist'){echo 'active';}?>"><a href="<?= WEB_URL; ?>buyer/buyerlist.php"><i class="fa fa-angle-double-right"></i><?= $_data['menu_buyer_list']; ?></a></li>-->
      <!--    <li class="<?php if($page_name != '' && $page_name == 'addbuyer'){echo 'active';}?>"><a href="<?= WEB_URL; ?>buyer/addbuyer.php"><i class="fa fa-angle-double-right"></i><?= $_data['menu_add_buyer']; ?></a></li>-->
      <!--  </ul>-->
      <!--</li>-->
      <!-- <li class="treeview <?php if($page_name != '' && $page_name == 'addtenant' || $page_name == 'tenantlist'){echo 'active';}?>"> <a href="#"> <i class="fa fa-users"></i> <span><?= $_data['menu_renter_information']; ?></span> <i class="fa fa-angle-left pull-right"></i> </a>
        <ul class="treeview-menu">
          <li class="<?php if($page_name != '' && $page_name == 'tenantlist'){echo 'active';}?>"><a href="<?= WEB_URL; ?>tenant/tenantlist.php"><i class="fa fa-angle-double-right"></i>Tenant List</a></li>
          <li class="<?php if($page_name != '' && $page_name == 'addtenant'){echo 'active';}?>"><a href="<?= WEB_URL; ?>tenant/addtenant.php"><i class="fa fa-angle-double-right"></i>Add Tenant</a></li>
        </ul>
      </li> -->
       <!-- Floors / Blocks -->
  <li class="treeview <?php if ($page_name !== '' && ($page_name === 'blocklist' || $page_name === 'addblock')) { echo 'active'; } ?>">
    <a href="#">
      <i class="fa fa-building"></i>
      <span><?= $_data['menu_floor']; ?></span>
      <i class="fa fa-angle-left pull-right"></i>
    </a>
    <ul class="treeview-menu">
      <li class="<?php if ($page_name === 'blocklist') { echo 'active'; } ?>">
        <a href="<?= WEB_URL; ?>block/blocklist.php" style="font-weight:800;">
          <i class="fa fa-angle-double-right"></i>
          <strong><?= $_data['menu_floor_list']; ?></strong>
        </a>
      </li>
      <li class="<?php if ($page_name === 'addblock') { echo 'active'; } ?>">
        <a href="<?= WEB_URL; ?>block/addblock.php" style="font-weight:800;">
          <i class="fa fa-angle-double-right"></i>
          <strong><?= $_data['menu_floor_add']; ?></strong>
        </a>
      </li>
    </ul>
  </li> 
      
      <li class="treeview <?php if ($page_name !== '' && ($page_name === 'addunit' || $page_name === 'unitlist')) { echo 'active'; } ?>">
  <a href="#">
    <i class="fa fa-cubes"></i>
    <span><?= $_data['menu_unit_information']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>
  <ul class="treeview-menu">
    <li class="<?php if ($page_name === 'unitlist') { echo 'active'; } ?>">
      <a href="<?= WEB_URL; ?>unit/unitlist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_unit_list']; ?></strong>
      </a>
    </li>
    <li class="<?php if ($page_name === 'addunit') { echo 'active'; } ?>">
      <a href="<?= WEB_URL; ?>unit/addunit.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_unit']; ?></strong>
      </a>
    </li>
  </ul>
</li>

 <li class="treeview <?php if($page_name != '' && ($page_name == 'addrent' || $page_name == 'rentlist')){echo 'active';}?>">
  <a href="#" style="font-weight:800;">
    <i class="fa fa-money"></i>
    <span><strong><?= $_data['menu_rent_collection']; ?></strong></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>
  <ul class="treeview-menu">
    <li class="<?php if($page_name != '' && $page_name == 'rentlist'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>rent/rentlist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_rent_list']; ?></strong>
      </a>
    </li>
    <li class="<?php if($page_name != '' && $page_name == 'addrent'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>rent/addrent.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_rent']; ?></strong>
      </a>
    </li>
    <li class="<?php if($page_name != '' && $page_name == 'addrentt'){echo 'active';}?>">
      <a href="<?= WEB_URL; ?>rent/addrentt.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_rentt']; ?></strong>
      </a>
    </li>
  </ul>
</li>


        <li class="treeview <?= ($page_name !== '' && ($page_name === 'addservicefee' || $page_name === 'servicelist')) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:700;">
    <i class="fa fa-money"></i>
    <span><?= $_data['menu_service_collection']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'service_list') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>service_fee/servicelist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_service_list']; ?></strong>
      </a>
    </li>
    <li class="<?= ($page_name === 'addsecuritydeposit') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>service_fee/addservicefee.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_service']; ?></strong>
      </a>
    </li>
  </ul>
</li>

     <li class="treeview <?= ($page_name !== '' && ($page_name === 'addsecuritydeposit' || $page_name === 'security_deposit_list')) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:700;">
    <i class="fa fa-money"></i>
    <span><?= $_data['menu_security_deposit_collection']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'security_deposit_list') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>security_deposit/security_deposit_list.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_security_deposit_list']; ?></strong>
      </a>
    </li>
    <li class="<?= ($page_name === 'addsecuritydeposit') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>security_deposit/addsecuritydeposit.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_security_deposit']; ?></strong>
      </a>
    </li>
  </ul>
</li>

  <li class="treeview <?= ($page_name !== '' && in_array($page_name, ['add_maintenance_cost','maintenance_cost_list'])) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:700;">
    <i class="fa fa-cut"></i>
    <span><?= $_data['menu_maintenance_cost']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'maintenance_cost_list') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>maintenance/maintenance_cost_list.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_maintenance_cost_list']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'add_maintenance_cost') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>maintenance/add_maintenance_cost.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_maintenance_cost']; ?></strong>
      </a>
    </li>
  </ul>
</li>

     
      
     <li class="treeview <?= ($page_name !== '' && in_array($page_name, ['addmeeting','meetinglist'])) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:700;">
    <i class="fa fa-handshake-o"></i>
    <span><?= $_data['menu_meeting']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'meetinglist') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>meeting/meetinglist.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_meeting_list']; ?></strong>
      </a>
    </li>
    <li class="<?= ($page_name === 'addmeeting') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>meeting/addmeeting.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_add_meeting']; ?></strong>
      </a>
    </li>
  </ul>
</li>

  <!-- Mail / SMS -->
<li class="treeview <?= ($page_name !== '' && $page_name === 'mailsms') ? 'active' : ''; ?>">
  <a href="<?= WEB_URL; ?>mailsms/mailsms.php" style="font-weight:800;">
    <i class="fa fa-envelope-o" aria-hidden="true"></i>
    <strong><?= $_data['email_sms']; ?></strong>
  </a>
</li>

<!-- Reports -->
<li class="treeview <?= ($page_name !== '' && in_array($page_name, ['rent_report','tenant_report','security_deposit_report','unit_inventory_report','unit_report','maintenace'])) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:700;">
    <i class="fa fa-bar-chart-o"></i>
    <span><?= $_data['menu_report']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'rent_report') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/rent_report.php" style="font-weight:800;">
        <i class="fa fa-money"></i>
        <strong>Rent Report</strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'tenant_report') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/tenant_report.php" style="font-weight:800;">
        <i class="fa fa-users"></i>
        <strong>Tenant Report</strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'security_deposit_report') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/security_deposit_report.php" style="font-weight:800;">
        <i class="fa fa-users"></i>
        <strong>Security Deposit Report</strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'maintenace') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/maintenance_report.php" style="font-weight:800;">
        <i class="fa fa-cogs"></i>
        <strong><?= $_data['menu_maintenace_report']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'unit_inventory_report') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/unit_inventory_report.php" style="font-weight:800;">
        <i class="fa fa-users"></i>
        <strong>Unit Inventory Report</strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'unit_report') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>report/unit_report.php" style="font-weight:800;">
        <i class="fa fa-building"></i>
        <strong><?= $_data['menu_unit_status_report']; ?></strong>
      </a>
    </li>
  </ul>
</li>

      
	   <?php if($_SESSION['login_type'] === "super"){ ?>
        <li class="treeview <?= ($page_name !== '' && in_array($page_name, [
  'bill_setup','utility_bill_setup','templates','month_setup','year_setup',
  'language','admin','add_building_info','branchlist','addbranch',
  'currency_setup','language_setup'
])) ? 'active' : ''; ?>">
  <a href="#" style="font-weight:800;">
    <i class="fa fa-wrench"></i>
    <span><?= $_data['menu_settings']; ?></span>
    <i class="fa fa-angle-left pull-right"></i>
  </a>

  <ul class="treeview-menu">
    <li class="<?= ($page_name === 'admin') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/admin.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_admin_setup']; ?></strong>
      </a>
    </li>

    <li style="display:none;" class="<?= ($page_name === 'add_building_info') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>building/add_building_info.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_building_info']; ?></strong>
      </a>
    </li>

    <li class="treeview <?= ($page_name !== '' && in_array($page_name, ['branchlist','addbranch'])) ? 'active' : ''; ?>">
      <a href="#" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <span><?= $_data['branch']; ?></span>
        <i class="fa fa-angle-left pull-right"></i>
      </a>
      <ul class="treeview-menu">
        <li class="<?= ($page_name === 'branchlist') ? 'active' : ''; ?>">
          <a href="<?= WEB_URL; ?>branch/branchlist.php" style="font-weight:800;">
            <i class="fa fa-angle-double-right"></i>
            <strong><?= $_data['branch_list']; ?></strong>
          </a>
        </li>
        <li class="<?= ($page_name === 'addbranch') ? 'active' : ''; ?>">
          <a href="<?= WEB_URL; ?>branch/addbranch.php" style="font-weight:800;">
            <i class="fa fa-angle-double-right"></i>
            <strong><?= $_data['add_branch']; ?></strong>
          </a>
        </li>
      </ul>
    </li>

    <li class="<?= ($page_name === 'templates') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>mailsms/templates.php" style="font-weight:800;">
        <i class="fa fa-folder" aria-hidden="true"></i>
        <strong>Templates</strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'bill_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/bill_setup.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_bill_setup']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'utility_bill_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/utility_bill_setup.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_utility_bill']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'month_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/month_setup.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_month_setup']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'year_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/year_setup.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_year_setup']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'currency_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/currency_setup.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_currency_setup']; ?></strong>
      </a>
    </li>

    <li class="<?= ($page_name === 'language' || $page_name === 'language_setup') ? 'active' : ''; ?>">
      <a href="<?= WEB_URL; ?>setting/language.php" style="font-weight:800;">
        <i class="fa fa-angle-double-right"></i>
        <strong><?= $_data['menu_language_setup']; ?></strong>
      </a>
    </li>
  </ul>
</li>

	   <?php } ?>
    </ul>
  </section>
  <!-- /.sidebar -->
</aside>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Add the sidebar's background. This div must be placed
 immediately after the control sidebar -->
<!--common lang text for js-->
<input type="hidden" id="email_validate_text" value="<?= $_data['valid_email'];?>">
<?php
// Build current avatar
$image = WEB_URL . 'img/no_image.jpg';
if (isset($_SESSION['image']) && $_SESSION['image'] !== '') {
  $candidate = ROOT_PATH . '/img/upload/' . $_SESSION['image'];
  if (file_exists($candidate)) {
    $image = WEB_URL . 'img/upload/' . $_SESSION['image'];
  }
}
if (isset($_SESSION['login_type']) && (string)$_SESSION['login_type'] === 'superadmin') {
  // If you set $super_admin_image elsewhere, keep honoring it
  $image = $super_admin_image ?? $image;
}
?>
<form id="updateprofile" action="<?= WEB_URL; ?>ajax/updateProfile.php" method="post" novalidate>
  <div class="modal fade profile-modal" id="user_profile" tabindex="-1" role="dialog" aria-labelledby="profileTitle" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content">

        <!-- Header / Hero -->
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="<?= htmlspecialchars($_data['close'] ?? 'Close'); ?>">
            <span aria-hidden="true">&times;</span>
          </button>

          <div class="profile-hero">
            <div class="avatar-wrap">
              <img class="avatar"
                   src="<?= htmlspecialchars($image); ?>"
                   alt="Profile photo"
                   onerror="this.onerror=null;this.src='<?= WEB_URL; ?>img/no_image.jpg';">
            </div>

            <div class="hero-meta">
              <h4 class="name" id="profileTitle"><?= htmlspecialchars($_SESSION['name'] ?? '—'); ?></h4>
              <div class="role">
                <i class="fa fa-id-badge"></i>
                <?php
                  if (($_SESSION['login_type'] ?? '') === 'admin') {
                    echo htmlspecialchars($_data['user_admin']);
                  } elseif (($_SESSION['login_type'] ?? '') === 'superadmin') {
                    echo htmlspecialchars($_data['user_super_admin']);
                  } else {
                    echo htmlspecialchars(ucfirst($_SESSION['login_type'] ?? 'user'));
                  }
                ?>
              </div>
            </div>
          </div>
        </div>

        <!-- Body -->
        <div class="modal-body">
          <div class="grid-2">
            <!-- Left column -->
            <div class="card">
              <div class="card-header">
                <i class="fa fa-user"></i>
                <span><?= htmlspecialchars($_data['profile_update_title']); ?></span>
              </div>
              <div class="card-body">

                <!-- Name -->
                <div class="form-group has-icon">
                  <label for="txtProfileName"><?= htmlspecialchars($_data['profile_update_name']); ?></label>
                  <div class="input-wrap">
                    <i class="fa fa-user"></i>
                    <input type="text"
                           class="form-control"
                           id="txtProfileName"
                           name="txtProfileName"
                           autocomplete="name"
                           placeholder="e.g. Ama K."
                           value="<?= htmlspecialchars($_SESSION['name'] ?? ''); ?>"
                           required>
                  </div>
                </div>

                <!-- Email -->
                <div class="form-group has-icon">
                  <label for="txtProfileEmail"><?= htmlspecialchars($_data['profile_update_email']); ?></label>
                  <div class="input-wrap">
                    <i class="fa fa-envelope-o"></i>
                    <input type="email"
                           class="form-control"
                           id="txtProfileEmail"
                           name="txtProfileEmail"
                           autocomplete="email"
                           placeholder="you@example.com"
                           value="<?= htmlspecialchars($_SESSION['email'] ?? ''); ?>"
                           required>
                  </div>
                </div>

                <!-- Contact -->
                <div class="form-group has-icon">
                  <label for="txtProfileContact"><?= htmlspecialchars($_data['profile_update_contact']); ?></label>
                  <div class="input-wrap">
                    <i class="fa fa-phone"></i>
                    <input type="tel"
                           class="form-control"
                           id="txtProfileContact"
                           name="txtProfileContact"
                           autocomplete="tel"
                           placeholder="+233 20 000 0000"
                           value="<?= htmlspecialchars($_SESSION['contact'] ?? ''); ?>">
                  </div>
                </div>

              </div>
            </div>

            <!-- Right column -->
            <div class="card">
              <div class="card-header">
                <i class="fa fa-lock"></i>
                <span><?= htmlspecialchars($_data['profile_update_password']); ?></span>
              </div>
              <div class="card-body">

                <!-- Password -->
                <div class="form-group has-icon">
                  <label for="txtProfilePassword"><?= htmlspecialchars($_data['profile_update_password']); ?></label>
                  <div class="input-wrap">
                    <i class="fa fa-key"></i>
                    <input type="password"
                           class="form-control"
                           id="txtProfilePassword"
                           name="txtProfilePassword"
                           autocomplete="current-password"
                           placeholder="Enter your current password"
                           required>
                    <button type="button" class="btn btn-soft btn-icon" tabindex="-1" aria-label="Toggle password visibility" onclick="togglePwd('txtProfilePassword', this)">
                      <i class="fa fa-eye"></i>
                    </button>
                  </div>
                  <small class="hint"><?= htmlspecialchars($_data['profile_update_information']); ?></small>
                </div>

                <!-- Optional: new password fields (comment out if not needed) -->
                <!--
                <div class="form-group has-icon">
                  <label for="txtNewPassword">New Password</label>
                  <div class="input-wrap">
                    <i class="fa fa-shield"></i>
                    <input type="password" class="form-control" id="txtNewPassword" name="txtNewPassword" autocomplete="new-password" placeholder="Leave blank to keep current">
                    <button type="button" class="btn btn-soft btn-icon" tabindex="-1" aria-label="Toggle password visibility" onclick="togglePwd('txtNewPassword', this)">
                      <i class="fa fa-eye"></i>
                    </button>
                  </div>
                </div>
                <div class="form-group has-icon">
                  <label for="txtNewPassword2">Confirm New Password</label>
                  <div class="input-wrap">
                    <i class="fa fa-check-circle"></i>
                    <input type="password" class="form-control" id="txtNewPassword2" name="txtNewPassword2" autocomplete="new-password" placeholder="Re-type new password">
                    <button type="button" class="btn btn-soft btn-icon" tabindex="-1" aria-label="Toggle password visibility" onclick="togglePwd('txtNewPassword2', this)">
                      <i class="fa fa-eye"></i>
                    </button>
                  </div>
                </div>
                -->

              </div>
            </div>
          </div>
        </div>

        <!-- Footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">
            <i class="fa fa-times"></i> <?= htmlspecialchars($_data['close'] ?? 'Close'); ?>
          </button>
          <button type="submit" class="btn btn-success" id="profileSaveBtn">
            <span class="btn-spinner" aria-hidden="true"></span>
            <i class="fa fa-save"></i> <?= htmlspecialchars($_data['profile_update_button']); ?>
          </button>
        </div>
      </div>
    </div>
  </div>
  <!-- Hidden -->
  <input type="hidden" name="user_id" value="<?= htmlspecialchars($_SESSION['user_id'] ?? ''); ?>">
</form>
<!-- Language Switch Modal -->
<div class="modal fade" id="switch_language" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" align="center"><strong><?= $_data['user_lang_switcher']; ?></strong></h4>
      </div>
      <div class="modal-body">
        <?php
			$dir    = ROOT_PATH . 'language/';
			$files1 = scandir($dir);
			foreach($files1 as $folder){
				if($folder != '' && $folder != '.' && $folder != '..'){
					if(trim($folder) == $lang_code_global){
						echo '<button onclick="set_language(this);" lang="'.$folder.'" class="btn btn-default btn-lg btn-lang-selected"><img style="width:24px;" src="'.WEB_URL.'language/'.$folder.'/flag.png"> '.$folder.'</button>&nbsp;&nbsp;&nbsp;';
					}
					else{
						echo '<button onclick="set_language(this);" lang="'.$folder.'" class="btn btn-default btn-lg"><img style="width:24px;" src="'.WEB_URL.'language/'.$folder.'/flag.png"> '.$folder.'</button>&nbsp;&nbsp;&nbsp;';
					}
				}
			}
			?>
      </div>
      <div class="modal-footer"> </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->


<!-- Language Switch Modal -->
<div class="modal fade" id="switch_branch" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" align="center"><strong style="text-transform:uppercase;"><?= $_data['user_branch_switcher']; ?></strong></h4>
      </div>
      <div class="modal-body clearfix">
        <?php
			$result_branch = mysqli_query($link,"SELECT * FROM tblbranch LIMIT 1");
			while($row_branch = mysqli_fetch_array($result_branch)){ 
				$img_branch = '';
				if(file_exists(ROOT_PATH . '/img/upload/' . $row_branch['building_image']) && $row_branch['building_image'] != ''){
					$img_branch = WEB_URL . 'img/upload/' . $row_branch['building_image'];
				}
			?>
        <?php if(true) { ?>
        <div class="col-md-4" style="margin-bottom:20px;border:solid 2px #d73925;padding:15px;cursor:pointer;text-align:center;" onClick="setBranch(<?= $row_branch['branch_id']; ?>);">
          <?php if(!empty($img_branch)) { ?>
          <div><img class="img-thumbnail" style="width:200px;height:200px;" src="<?= $img_branch; ?>"></div>
          <?php }?>
          <div style="text-align:center;font-weight:bold;font-size:18px;"><?= $row_branch['branch_name']; ?></div>
        </div>
        <?php } else { ?>
        <div class="col-md-4" style="margin-bottom:20px;padding:15px;cursor:pointer;text-align:center;" onClick="setBranch(<?= $row_branch['branch_id']; ?>);">
          <?php if(!empty($img_branch)) { ?>
          <div><img class="img-thumbnail" style="width:200px;height:200px;" src="<?= $img_branch; ?>"></div>
          <?php }?>
          <div style="text-align:center;font-weight:bold;font-size:18px;"><?= $row_branch['branch_name']; ?></div>
        </div>
        <?php }?>
        <?php }?>
      </div>
      <div class="modal-footer"> </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<style>
  /* ===== Modern, soft UI for profile modal ===== */
  .profile-modal .modal-content{
    border-radius:16px; border:1px solid #e5e7eb;
    box-shadow:0 18px 60px rgba(2,6,23,.18);
    font-family:'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    color:#0f172a;
  }
  .profile-modal .modal-header{
    background:linear-gradient(135deg,#f8fafc,#eef2ff);
    border:none; padding:16px 18px;
  }
  .profile-hero{ display:flex; align-items:center; gap:14px; }
  .avatar-wrap{ position:relative; }
  .avatar{
    width:64px; height:64px; border-radius:16px; object-fit:cover;
    border:1px solid #e5e7eb; background:#fff; box-shadow:0 6px 16px rgba(2,6,23,.08);
  }
  .hero-meta .name{ margin:0; font-weight:900; letter-spacing:.2px; }
  .hero-meta .role{
    margin-top:2px; color:#475569; font-weight:700; font-size:12px; display:flex; gap:6px; align-items:center;
  }

  .grid-2{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; }
  @media (max-width: 768px){ .grid-2{ grid-template-columns: 1fr; } }

  .card{
    border:1px solid #e5e7eb; border-radius:14px; background:#fff;
    box-shadow:0 10px 26px rgba(2,6,23,.06); overflow:hidden;
  }
  .card-header{
    display:flex; align-items:center; gap:8px;
    background:linear-gradient(180deg,#f8fafc,#ffffff);
    font-weight:900; color:#0f172a; padding:10px 12px; border-bottom:1px solid #eef2f7;
  }
  .card-header i{ color:#64748b; }
  .card-body{ padding:12px; }

  .form-group{ margin-bottom:12px; }
  .form-group label{ font-weight:800; color:#334155; margin-bottom:6px; }
  .has-icon .input-wrap{ position:relative; display:flex; align-items:center; }
  .has-icon .input-wrap i{
    position:absolute; left:10px; color:#64748b;
  }
  .has-icon .form-control{
    padding-left:32px; padding-right:40px;
  }
  .form-control{
    border:1px solid #e5e7eb; border-radius:12px; height:40px;
    box-shadow:none; outline:none; color:#0f172a;
  }
  .form-control:focus{
    border-color:#93c5fd; box-shadow:0 0 0 3px rgba(59,130,246,.15);
  }
  .hint{ color:#64748b; font-size:12px; display:block; margin-top:6px; }

  .btn{ border-radius:10px; font-weight:800; }
  .btn-soft{
    background:#fff; color:#0f172a; border:1px solid #e5e7eb;
  }
  .btn-soft:hover{ background:#f8fafc; }
  .btn-icon{ position:absolute; right:6px; top:50%; transform:translateY(-50%); height:28px; padding:0 8px; }

  .btn-spinner{
    width:14px; height:14px; border-radius:50%;
    border:2px solid rgba(255,255,255,.5); border-top-color:#fff; display:none;
    margin-right:6px; vertical-align:middle; animation:spin .8s linear infinite;
  }
  .btn--loading .btn-spinner{ display:inline-block; }
  @keyframes spin{ to{ transform: rotate(360deg); } }
</style>

<script>
  // Toggle password visibility
  function togglePwd(id, btn){
    var input = document.getElementById(id);
    if (!input) return;
    var icon = btn && btn.querySelector('i');
    if (input.type === 'password') {
      input.type = 'text';
      if (icon) icon.className = 'fa fa-eye-slash';
    } else {
      input.type = 'password';
      if (icon) icon.className = 'fa fa-eye';
    }
    input.focus();
  }

  // Basic client-side UX: block double submits & quick validation
  (function(){
    var form = document.getElementById('updateprofile');
    var saveBtn = document.getElementById('profileSaveBtn');
    if (!form || !saveBtn) return;

    form.addEventListener('submit', function(e){
      // HTML5 validity check
      if (!form.checkValidity()) {
        // Let browser show native messages
        return;
      }
      // Prevent double-clicks
      saveBtn.classList.add('btn--loading');
      saveBtn.setAttribute('disabled', 'disabled');
    });
  })();
</script>









<!-- /.modal -->    
