<!DOCTYPE html>
<html lang="bn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>লগইন — বধুবরণ জুয়েলার্স</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%;width:100%}
body{
  min-height:100vh;
  background: radial-gradient(circle at 50% 30%, #142850 0%, #0F1A30 50%, #080F1E 100%);
  font-family:'Hind Siliguri','Segoe UI',Arial,sans-serif;
  color:#fff;
  display:flex;flex-direction:column;
  overflow-x:hidden;
}

/* Top spiritual banner */
.spiritual{
  width:100%;
  background:linear-gradient(135deg, rgba(245,184,0,0.12), rgba(245,184,0,0.05));
  border-bottom:1.5px solid rgba(245,184,0,0.25);
  padding:14px 16px;
  text-align:center;
}
.spiritual-line1{
  font-size:18px;font-weight:700;color:#F5B800;
  letter-spacing:1.5px;margin-bottom:6px;
}
.spiritual-line2{
  font-size:14px;color:#FFD580;font-weight:600;
  line-height:1.6;
}
.spiritual-line2 .pledge{
  display:block;color:#8AAFD4;font-size:13px;
  font-weight:500;margin-top:3px;
}

/* Main center wrapper */
.main-wrap{
  flex:1;width:100%;
  display:flex;align-items:center;justify-content:center;
  padding:20px 16px;
}

.card{
  width:100%;max-width:440px;
  background:rgba(17,29,53,0.85);
  backdrop-filter:blur(10px);
  border:1.5px solid #1A2D50;
  border-radius:24px;
  padding:32px 24px;
  box-shadow:0 25px 50px rgba(0,0,0,.6);
  position:relative;
}
.card::before{
  content:'';position:absolute;top:0;left:15%;right:15%;height:3px;
  background:linear-gradient(90deg,transparent,#F5B800,transparent);
  border-radius:3px;
}

.logo-wrap{text-align:center;margin-bottom:24px}
.logo{
  width:90px;height:90px;
  background:linear-gradient(135deg,#F5B800,#D4780A);
  border-radius:24px;
  display:inline-flex;align-items:center;justify-content:center;
  font-size:48px;
  margin-bottom:16px;
  box-shadow:0 12px 30px rgba(245,184,0,0.35);
}
.brand{font-size:26px;font-weight:800;color:#fff;margin-bottom:6px}
.brand-sub{font-size:15px;color:#8AAFD4;font-weight:500;line-height:1.5}

.divider{
  display:flex;align-items:center;gap:12px;margin:28px 0 22px;
}
.divider::before,.divider::after{
  content:'';flex:1;height:1px;background:#1A2D50;
}
.divider span{font-size:13px;color:#5C7DA8;white-space:nowrap}

.field{margin-bottom:20px}
.field label{
  display:block;font-size:15px;font-weight:600;
  color:#8AAFD4;margin-bottom:10px;
}

.input-wrap{position:relative}
.input-icon{
  position:absolute;left:16px;top:50%;transform:translateY(-50%);
  font-size:20px;pointer-events:none;
}

input{
  width:100%;
  background:#080F1E;
  border:1.5px solid #1A2D50;
  border-radius:14px;
  color:#fff;
  font-size:17px;
  padding:16px 16px 16px 50px;
  outline:none;
  transition:all .25s ease;
  font-family:inherit;
}
input:focus{
  border-color:#F5B800;
  box-shadow:0 0 0 4px rgba(245,184,0,0.12);
}
input::placeholder{color:#3E5878}

.eye-btn{
  position:absolute;right:14px;top:50%;transform:translateY(-50%);
  background:none;border:none;cursor:pointer;
  font-size:22px;color:#5C7DA8;
  width:36px;height:36px;
  display:flex;align-items:center;justify-content:center;
}

.btn{
  width:100%;
  background:linear-gradient(135deg,#F5B800,#D4780A);
  border:none;border-radius:15px;
  color:#080F1E;
  font-size:19px;font-weight:800;
  padding:18px;
  cursor:pointer;
  margin-top:14px;
  transition:all .2s ease;
  box-shadow:0 8px 20px rgba(245,184,0,0.3);
  font-family:inherit;
}
.btn:active{transform:scale(.97)}
.btn:disabled{opacity:.7;cursor:not-allowed}

.error-box{
  display:none;background:rgba(239,68,68,0.15);
  border:1px solid #ef4444;
  border-radius:12px;padding:14px;margin-bottom:18px;
  font-size:15px;color:#ef4444;text-align:center;
  font-weight:600;
}

.footer{
  text-align:center;
  margin-top:24px;
  font-size:13px;color:#5C7DA8;
}

/* Small screens */
@media(max-width:380px){
  .spiritual-line1{font-size:16px;letter-spacing:1px}
  .spiritual-line2{font-size:13px}
  .card{padding:24px 20px}
  .logo{width:80px;height:80px;font-size:42px}
  .brand{font-size:22px}
  input{font-size:16px;padding:14px 14px 14px 46px}
  .btn{font-size:17px;padding:16px}
}

/* Tablet/Desktop */
@media(min-width:768px){
  .card{padding:40px 36px}
}
</style>
</head>
<body>

<!-- Spiritual Header -->
<div class="spiritual">
  <div class="spiritual-line1">ঔঁ 🪔 তৎ 🧘 সৎ 🙏</div>
  <div class="spiritual-line2">
    সমস্ত নিয়ম আমার নিয়ম
    <span class="pledge">আমি সবকিছুর জন্য দায়বদ্ধ</span>
  </div>
</div>

<!-- Main Card -->
<div class="main-wrap">
  <div class="card">
    <div class="logo-wrap">
      <div class="logo">💎</div>
      <div class="brand">বধুবরণ জুয়েলার্স</div>
      <div class="brand-sub">স্বর্ণ ব্যবসার আধুনিক ERP সমাধান</div>
    </div>

    <div class="divider"><span>আপনার অ্যাকাউন্টে লগইন করুন</span></div>

    <div class="error-box" id="errBox"></div>

    <div class="field">
      <label>ইমেইল বা ইউজারনেম</label>
      <div class="input-wrap">
        <span class="input-icon">📧</span>
        <input type="email" id="username" placeholder="ইমেইল লিখুন" autocomplete="email">
      </div>
    </div>

    <div class="field">
      <label>পাসওয়ার্ড</label>
      <div class="input-wrap">
        <span class="input-icon">🔒</span>
        <input type="password" id="password" placeholder="পাসওয়ার্ড লিখুন" autocomplete="current-password">
        <button class="eye-btn" id="eyeBtn" type="button" onclick="togglePass()">👁️</button>
      </div>
    </div>

    <button class="btn" id="loginBtn" onclick="doLogin()">লগইন করুন</button>

    <div class="footer">বধুবরণ জুয়েলার্স ERP © 2026</div>
  </div>
</div>

<script>
function togglePass(){
  var inp=document.getElementById('password');
  var btn=document.getElementById('eyeBtn');
  if(inp.type==='password'){inp.type='text';btn.textContent='🙈';}
  else{inp.type='password';btn.textContent='👁️';}
}

function showError(msg){
  var box=document.getElementById('errBox');
  box.textContent=msg;box.style.display='block';
}

async function doLogin(){
  var box=document.getElementById('errBox');
  box.style.display='none';

  var username=document.getElementById('username').value.trim();
  var password=document.getElementById('password').value.trim();

  if(!username||!password){showError('সবগুলো ঘর পূরণ করুন');return;}

  var btn=document.getElementById('loginBtn');
  btn.disabled=true;
  btn.innerHTML='প্রসেসিং...';

  try{
    var res=await fetch('../api/auth/login.php',{
      method:'POST',
      headers:{'Content-Type':'application/json'},
      body:JSON.stringify({email:username,password:password})
    });
    var data=await res.json();

    if(data.success){
      btn.innerHTML='✅ সফল!';
      setTimeout(function(){window.location.href='dashboard.html';},500);
    }else{
      showError(data.message||'ভুল ইউজারনেম বা পাসওয়ার্ড');
      btn.disabled=false;btn.innerHTML='লগইন করুন';
    }
  }catch(e){
    showError('সার্ভার ত্রুটি, আবার চেষ্টা করুন');
    btn.disabled=false;btn.innerHTML='লগইন করুন';
  }
}

// Enter key support
document.addEventListener('keypress',function(e){
  if(e.key==='Enter')doLogin();
});
</script>
</body>
</html>