/* =========================================
   VARIABLES
========================================= */
:root{
  --sidebar-width: 260px;
  --bg-dark: #0f0f1a;
  --panel: #1e1e2f;
  --panel-2: #2a2a40;
  --accent-1: #4a3bf3;
  --accent-2: #4a3bf3;
  --muted: #bdbdbd;
  --white: #f6f6f8;
  --danger: #e74c3c;
  --header-height: 56px;
}

/* =========================================
   GLOBAL
========================================= */
*{box-sizing:border-box}
html,body{
  height:100%; margin:0;
  font-family:"Poppins",sans-serif;
  background:var(--bg-dark);
  color:var(--white);
  -webkit-font-smoothing:antialiased;
}
a{color:inherit;text-decoration:none}
button{font-family:inherit}

::-webkit-scrollbar{height:8px;width:8px}
::-webkit-scrollbar-track{background:#12121a}
::-webkit-scrollbar-thumb{background:linear-gradient(var(--accent-1),var(--accent-2));border-radius:8px}

/* =========================================
   SIDEBAR — Desktop
========================================= */
.sidebar{
  width:var(--sidebar-width);
  min-height:100vh;
  position:fixed;
  left:0;top:0;
  background:linear-gradient(180deg,#151523,#121223);
  padding:24px 18px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
  z-index:1000;
  box-shadow:4px 0 18px rgba(0,0,0,0.45);
  transition:transform .25s ease;
}
.sidebar .logo-wrap{text-align:center;width:100%}
.sidebar .logo-wrap img{
  max-width:78px;max-height:78px;
  width:auto;height:auto;
  display:block;margin:0 auto 8px;
  object-fit:contain;border-radius:6px;
  background:rgba(255,255,255,0.02);padding:6px;
}
.sidebar h2{margin:0 0 8px;font-size:16px;color:var(--white);text-align:center;font-weight:600}
.sidebar ul{list-style:none;padding:0;margin:6px 0;width:100%}
.sidebar ul li{margin:8px 0}
.sidebar ul li a{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:10px;
  color:var(--white);transition:all .18s ease;background:transparent;
  font-size:14px;
}
.sidebar ul li a:hover,
.sidebar ul li a.active{
  background:linear-gradient(90deg,var(--accent-1),var(--accent-2));
  box-shadow:0 6px 18px rgba(106,13,173,0.18);
}

/* =========================================
   MOBILE TOPBAR + HAMBURGER
========================================= */
.mobile-topbar{
  display:none;
  position:fixed;top:0;left:0;right:0;
  height:var(--header-height);
  background:linear-gradient(180deg,#151523,#121223);
  z-index:1100;
  align-items:center;
  padding:0 16px;
  gap:12px;
  box-shadow:0 2px 12px rgba(0,0,0,0.4);
}
.mobile-topbar .mobile-logo{
  width:36px;height:36px;
  object-fit:contain;border-radius:6px;
}
.mobile-topbar .mobile-title{
  font-size:15px;font-weight:700;color:var(--white);flex:1;
}
.hamburger{
  background:none;border:none;cursor:pointer;
  padding:6px;border-radius:8px;
  display:flex;flex-direction:column;
  gap:5px;align-items:center;justify-content:center;
}
.hamburger span{
  display:block;width:22px;height:2px;
  background:var(--white);border-radius:2px;
  transition:all .25s ease;
}
.hamburger.open span:nth-child(1){transform:translateY(7px) rotate(45deg)}
.hamburger.open span:nth-child(2){opacity:0;transform:scaleX(0)}
.hamburger.open span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}

/* Sidebar overlay (mobile) */
.sidebar-overlay{
  display:none;
  position:fixed;inset:0;
  background:rgba(0,0,0,0.6);
  z-index:999;
  backdrop-filter:blur(2px);
}
.sidebar-overlay.show{display:block}

/* =========================================
   MAIN CONTENT
========================================= */
.main-content{
  margin-left:var(--sidebar-width);
  padding:30px;
  min-height:100vh;
  background:linear-gradient(180deg,var(--bg-dark),#07101a);
  transition:margin-left .15s ease;
}
.main-content > header{margin-bottom:18px}
.main-content header h1{
  margin:0;font-size:28px;
  color:var(--white);font-weight:700;letter-spacing:0.1px;
}

/* =========================================
   MESSAGE BOXES
========================================= */
.message-box{
  background:#2b2b3f;color:#fff;
  padding:12px 14px;border-radius:10px;
  margin-bottom:14px;box-shadow:0 6px 18px rgba(0,0,0,0.4);
}
.message-box.success{background:#163b2b;color:#bfeac9}

/* =========================================
   FORM CARDS
========================================= */
.forms-row{display:flex;gap:16px;flex-wrap:wrap;margin-bottom:18px}
.form-section{
  background:var(--panel);padding:14px;
  border-radius:12px;box-shadow:0 6px 18px rgba(0,0,0,0.45);
  color:var(--white);min-width:0;
}
.add-box{flex:1 1 420px;min-width:250px}
.remove-box{flex:1 1 280px;min-width:220px}
.search-box{flex:1 1 300px;min-width:220px}

.inline-form{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.inline-form input[type="text"],
.inline-form input[type="file"],
input[type="text"],
textarea{
  background:rgba(0,0,0,0.25);
  border:1px solid rgba(255,255,255,0.04);
  color:var(--white);padding:10px;border-radius:8px;flex:1;
}
.inline-form input:focus{outline:none;border-color:var(--accent-1);box-shadow:0 0 8px rgba(106,13,173,0.18)}
.form-section h3{margin:0 0 8px;font-size:16px;color:var(--white)}

/* Buttons */
.btn-primary,.btn-search{
  background:linear-gradient(135deg,var(--accent-1),var(--accent-2));
  color:#fff;border:none;padding:10px 14px;
  border-radius:10px;cursor:pointer;
  box-shadow:0 8px 20px rgba(106,13,173,0.12);
}
.btn-primary:hover,.btn-search:hover{transform:translateY(-2px)}
.btn-danger{background:var(--danger);color:#fff;border:none;padding:10px 12px;border-radius:10px;cursor:pointer}
.btn-reset{background:#3a3a4d;color:var(--muted);border:none;padding:10px 12px;border-radius:10px;cursor:pointer}

/* =========================================
   STUDENT CARDS
========================================= */
.student-cards h3{margin:6px 0 10px 0;color:var(--white)}
.cards-container{
  background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(0,0,0,0.02));
  border-radius:12px;padding:16px;
  box-shadow:0 8px 24px rgba(0,0,0,0.5);
  max-height:560px;overflow-y:auto;
}
.cards-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:14px}
.student-card{
  background:var(--panel-2);border-radius:10px;padding:12px;
  display:flex;flex-direction:column;align-items:center;gap:8px;
  transition:transform .18s ease,background .18s ease;text-align:center;
}
.student-card:hover{
  transform:translateY(-6px);
  background:linear-gradient(135deg,var(--accent-1),var(--accent-2));
  box-shadow:0 12px 30px rgba(106,13,173,0.18);
}
.photo-wrap{width:96px;height:96px;border-radius:10px;overflow:hidden;border:1px solid rgba(255,255,255,0.04)}
.photo-wrap img{width:100%;height:100%;object-fit:cover;display:block}
.student-card .name{font-weight:600;color:var(--white);font-size:0.95rem}
.student-card .sn{color:var(--muted);font-size:0.82rem}
.no-data{padding:14px;color:var(--muted)}

/* =========================================
   DASHBOARD CARDS
========================================= */
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:20px;margin:20px 0}
.card{background:var(--panel);padding:18px;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,0.45);transition:all .18s ease}
.card h3{margin:0 0 6px;color:var(--white)}
.card p{margin:0;color:var(--accent-2);font-weight:600}

/* =========================================
   LOGIN PAGE
========================================= */
body.login-page{
  display:flex;justify-content:center;align-items:center;
  height:100vh;margin:0;
  background:linear-gradient(135deg,#0a0a1a,#111122);
}
.login-container{width:100%;max-width:340px;padding:20px}
.login-box{
  background:rgba(0,0,0,0.6);padding:30px 20px;
  border-radius:12px;box-shadow:0px 8px 20px rgba(0,0,0,0.5);text-align:center;
}
.login-logo{width:80px;height:80px;margin-bottom:10px;object-fit:contain}
.login-box h2{color:#fff;margin:10px 0 20px;font-size:20px}
.form-group{margin-bottom:15px;text-align:left}
.form-group input{
  width:100%;padding:12px;border:none;border-radius:8px;
  background:#1a1a2e;color:#fff;font-size:14px;outline:none;
}
.form-group input::placeholder{color:#aaa}
.btn-login{
  width:100%;padding:12px;border:none;border-radius:8px;
  background:linear-gradient(90deg,#6a11cb,#2575fc);
  color:#fff;font-size:15px;font-weight:bold;cursor:pointer;transition:0.3s;
}
.btn-login:hover{opacity:0.9}
.extra-links{margin-top:12px}
.extra-links a{color:#aaa;font-size:13px;text-decoration:none}
.extra-links a:hover{color:#fff}
.extra-links .forgot-password{display:inline-block;font-size:14px;color:#007bff;text-decoration:none;transition:color 0.3s ease}
.extra-links .forgot-password:hover{color:#0056b3;text-decoration:underline}

/* =========================================
   LOGOUT PAGE
========================================= */
body.logout-page{
  display:flex;justify-content:center;align-items:center;
  height:100vh;margin:0;
  background:linear-gradient(135deg,#0a0a1a,#111122);
}
.logout-container{width:100%;max-width:400px;padding:20px}
.logout-box{
  background:rgba(0,0,0,0.65);padding:30px 20px;
  border-radius:12px;box-shadow:0px 8px 20px rgba(0,0,0,0.5);text-align:center;
}
.logout-box h2{color:#fff;margin-bottom:12px}
.logout-box p{color:#aaa;margin-bottom:20px;font-size:14px}
.btn-logout{
  display:inline-block;padding:10px 18px;border-radius:8px;
  background:linear-gradient(90deg,#6a11cb,#2575fc);
  color:#fff;text-decoration:none;font-size:14px;font-weight:bold;transition:0.3s;
}
.btn-logout:hover{opacity:0.85}

/* =========================================
   MODALS — Global responsive
========================================= */
.modal-overlay{
  display:none;position:fixed;z-index:9999;
  inset:0;background:rgba(0,0,0,0.7);
  backdrop-filter:blur(3px);
  align-items:center;justify-content:center;
  padding:16px;
}
.modal-overlay.active{display:flex}

/* =========================================
   TABLET — 980px
========================================= */
@media(max-width:980px){
  :root{--sidebar-width:220px}
  .sidebar{width:var(--sidebar-width);padding:18px}
  .main-content{margin-left:var(--sidebar-width);padding:20px}
  .cards-container{max-height:480px}
}

/* =========================================
   MOBILE — 768px
   Hamburger sidebar
========================================= */
@media(max-width:768px){
  /* Show mobile topbar */
  .mobile-topbar{display:flex}

  /* Hide sidebar by default, slide in when open */
  .sidebar{
    transform:translateX(-100%);
    top:0;
    min-height:100vh;
    padding-top:24px;
    width:260px;
  }
  .sidebar.open{transform:translateX(0)}

  /* Main content fills full width, pushed down by topbar */
  .main-content{
    margin-left:0;
    padding:16px;
    padding-top:calc(var(--header-height) + 16px);
  }

  /* Stack forms vertically */
  .forms-row{flex-direction:column}
  .add-box,.remove-box,.search-box{flex:1 1 100%;min-width:0}

  /* Smaller cards */
  .cards-container{max-height:420px}
  .cards-grid{grid-template-columns:repeat(auto-fill,minmax(120px,1fr))}

  /* Header font size */
  .main-content header h1{font-size:22px}

  /* Tables scroll horizontally */
  .students-table-wrap, table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch}

  /* Modals full width */
  .modal-box,.edit-modal-box{
    width:100%!important;
    max-width:100%!important;
    border-radius:12px;
    margin:0;
    max-height:90vh;
    overflow-y:auto;
  }

  /* Stat grids stack */
  .stats-grid{grid-template-columns:repeat(2,1fr)!important}
  .today-summary{grid-template-columns:repeat(2,1fr)!important}
}

/* =========================================
   SMALL MOBILE — 480px
========================================= */
@media(max-width:480px){
  .main-content{padding:12px;padding-top:calc(var(--header-height) + 12px)}
  .student-card .name{font-size:0.9rem}
  .student-card .sn{font-size:0.78rem}
  .cards-grid{grid-template-columns:repeat(auto-fill,minmax(110px,1fr))}
  .stats-grid{grid-template-columns:repeat(2,1fr)!important}
  .extra-links .forgot-password{font-size:13px;display:block;margin-top:10px}
  .main-content header h1{font-size:20px}

  /* Buttons stack on small screens */
  .count-bar-right{flex-wrap:wrap;justify-content:flex-end}

  /* Preview cards full width */
  .preview-cards-grid{grid-template-columns:1fr!important}
  .psc{flex-direction:column}
  .psc img{width:100%!important;height:160px!important;border-radius:8px}
}