html,body{
  margin:0;
  min-height:100%;
  scroll-behavior: smooth;
}

body{
  margin:0;
  font-family:'Poppins', sans-serif;
  background:linear-gradient(135deg,#0b0f2a,#2b1e5a);
  color:white;
  transition:
    background 0.35s ease,
    color 0.35s ease;
  min-height:100vh;
  overflow-x:hidden;
  overflow-y:auto;
}

.layout{
  display:flex;
  min-height:100vh;
}

/* SIDEBAR */
.sidebar{
  width:240px;
  background:#1a1140;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:20px;
  box-sizing:border-box;
  transition:background 0.35s ease;
}

.sidebar-toggle{
  display:none;
  width:46px;
  height:46px;
  border:none;
  border-radius:14px;
  background:rgba(255,255,255,0.08);
  cursor:pointer;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:5px;
  padding:0;
  flex-shrink:0;
}

.sidebar-toggle span{
  width:20px;
  height:2px;
  background:#fff;
  border-radius:999px;
  display:block;
  transition:transform 0.25s ease, opacity 0.25s ease, background 0.35s ease;
}

.top-section{
  display:flex;
  flex-direction:column;
  gap:30px;
}

.logo-link{
  text-decoration:none;
  display:inline-block;
}

.logo{
  font-family:'Press Start 2P', cursive;
  font-size:14px;
  line-height:1.5;
  background:linear-gradient(90deg,#ff982e 0%,#ff7c2e 28%,#ff4d95 68%,#ff4fb8 100%);
  -webkit-background-clip:text;
  background-clip:text;
  -webkit-text-fill-color:transparent;
  margin:0;
  cursor:pointer;
  transition:transform 0.25s ease;
  filter:
    drop-shadow(0 0 6px rgba(255,138,42,0.45))
    drop-shadow(0 0 14px rgba(255,46,151,0.28));
}

.logo-link:hover .logo{
  transform:scale(1.03);
}

.menu{
  display:flex;
  flex-direction:column;
  gap:30px;
  padding-top:14px;
}

.menu a{
  color:white;
  text-decoration:none;
  opacity:0.8;
  font-size:14px;
  line-height:1.2;
  padding:2px 0;
  transition:
    0.25s ease,
    color 0.35s ease;
}

.menu a:hover,
.menu a.active-link{
  opacity:1;
  transform:translateX(5px);
}

.bottom-section{
  padding-top:20px;
  border-top:1px solid rgba(255,255,255,0.1);
}

.logout-btn{
  width:100%;
  padding:12px;
  border:none;
  border-radius:12px;
  background:#ff2e97;
  color:white;
  cursor:pointer;
  font-weight:600;
  transition:
    transform 0.2s ease,
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.logout-btn:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 22px rgba(255,46,151,0.22);
  filter:brightness(1.05);
}

/* MAIN */
.main{
  flex:1;
  padding:24px;
  box-sizing:border-box;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  gap:20px;
  overflow-y:auto;
}

.main::-webkit-scrollbar{
  width:8px;
}

.main::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,0.18);
  border-radius:999px;
}

/* TOPBAR */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:20px;
  animation:fadeSlideUp 0.55s ease both;
}

.topbar-title{
  display:flex;
  align-items:flex-start;
  gap:12px;
}

.page-title{
  margin:0;
  font-size:32px;
}

.page-subtitle{
  margin:8px 0 0 0;
  opacity:0.82;
  font-size:14px;
}

.user-top{
  display:flex;
  align-items:center;
  gap:10px;
  background:rgba(255,255,255,0.06);
  padding:10px 14px;
  border-radius:14px;
  transition:
    background 0.35s ease,
    box-shadow 0.35s ease,
    transform 0.25s ease;
}

.user-top:hover{
  transform:translateY(-2px);
}

.user-top span{
  font-weight:600;
}

.user-top img{
  width:38px;
  height:38px;
  border-radius:50%;
  object-fit:cover;
}

/* CARDS */
.card{
  background:#3a2575;
  padding:20px;
  border-radius:18px;
  box-sizing:border-box;
  transition:
    transform 0.28s ease,
    box-shadow 0.3s ease,
    background 0.35s ease,
    color 0.35s ease;
}

.card:hover{
  transform:translateY(-4px);
  box-shadow:0 14px 28px rgba(0,0,0,0.16);
}

/* STATS */
.stats-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:20px;
}

.stat-card{
  min-height:140px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  animation:fadeSlideUp 0.55s ease both;
}

.stat-card:nth-child(1){ animation-delay:0.05s; }
.stat-card:nth-child(2){ animation-delay:0.14s; }
.stat-card:nth-child(3){ animation-delay:0.23s; }

.stat-card h3{
  margin:0 0 10px 0;
  font-size:16px;
  font-weight:600;
}

.stat-card p{
  margin:0;
  font-size:28px;
  font-weight:700;
}

/* SUBJECTS GRID */
.subjects-grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:22px;
}

.subject-card{
  min-height:380px;
  display:flex;
  flex-direction:column;
  gap:14px;
  justify-content:flex-start;
  cursor:pointer;
  position:relative;
  overflow:hidden;
  animation:cardPopIn 0.6s ease both;
}

.subject-card:nth-child(1){ animation-delay:0.10s; }
.subject-card:nth-child(2){ animation-delay:0.20s; }

.subject-card::before{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(135deg,rgba(255,255,255,0.06),transparent 45%);
  pointer-events:none;
}

.subject-card:hover{
  transform:translateY(-6px) scale(1.01);
  box-shadow:0 18px 34px rgba(0,0,0,0.2);
}

.subject-card-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}

.subject-icon{
  font-size:34px;
  width:58px;
  height:58px;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,0.08);
  transition:
    transform 0.25s ease,
    box-shadow 0.28s ease,
    background 0.35s ease;
}

.subject-card:hover .subject-icon{
  transform:scale(1.07);
  box-shadow:0 0 18px rgba(0,229,255,0.16);
}

.subject-badge{
  padding:8px 12px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  background:linear-gradient(135deg,#00e5ff,#00ffcc);
  color:#081228;
  box-shadow:0 0 16px rgba(0,229,255,0.16);
  animation:badgeGlow 2.2s ease-in-out infinite;
}

.subject-card h3{
  margin:0;
  font-size:22px;
  line-height:1.3;
}

.subject-description{
  margin:0;
  opacity:0.86;
  font-size:14px;
  line-height:1.6;
  min-height:66px;
}

.subject-meta{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:4px;
}

.meta-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  font-size:14px;
}

.meta-row strong{
  font-size:14px;
}

/* PROGRESS */
.progress-bar{
  height:12px;
  background:rgba(255,255,255,0.18);
  border-radius:10px;
  overflow:hidden;
  position:relative;
}

.progress-fill{
  height:100%;
  background:linear-gradient(90deg,#00e5ff,#00ffcc);
  transition:width 1s cubic-bezier(0.22, 1, 0.36, 1);
  position:relative;
}

.progress-fill::after{
  content:"";
  position:absolute;
  top:0;
  right:0;
  width:38px;
  height:100%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,0.42));
  filter:blur(2px);
  opacity:0.7;
}

/* BUTTON */
.subject-open-btn{
  margin-top:auto;
  border:none;
  border-radius:12px;
  padding:13px 16px;
  background:#ff2e97;
  color:white;
  cursor:pointer;
  font-weight:600;
  transition:
    transform 0.22s ease,
    box-shadow 0.28s ease,
    filter 0.25s ease;
}

.subject-card:hover .subject-open-btn{
  transform:translateY(-2px);
  box-shadow:0 12px 24px rgba(255,46,151,0.2);
  filter:brightness(1.05);
}

/* THEME BUTTON */
.theme-toggle{
  position:fixed;
  bottom:20px;
  right:20px;
  width:55px;
  height:55px;
  border:none;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  cursor:pointer;
  background:linear-gradient(135deg,#00e5ff,#00ffcc);
  color:#000;
  box-shadow:0 0 15px #00e5ff;
  transition:
    transform 0.28s ease,
    box-shadow 0.35s ease,
    background 0.35s ease,
    color 0.35s ease;
  z-index:1000;
}

.theme-toggle:hover{
  transform:scale(1.1) rotate(10deg);
  box-shadow:0 0 24px rgba(0,229,255,0.45);
}

/* POPUP */
.popup{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.65);
  display:flex;
  justify-content:center;
  align-items:center;
  opacity:0;
  pointer-events:none;
  transition:0.25s;
  z-index:1200;
}

.popup.active{
  opacity:1;
  pointer-events:auto;
}

.popup-box{
  width:360px;
  max-width:90%;
  background:#1a1140;
  border-radius:18px;
  padding:24px;
  box-shadow:0 0 35px rgba(255,46,151,0.45);
  text-align:center;
  transition:
    background 0.35s ease,
    color 0.35s ease,
    box-shadow 0.35s ease;
}

.popup-box h3{
  margin:0 0 12px 0;
}

.popup-box p{
  margin:0;
  line-height:1.6;
  font-size:14px;
  opacity:0.95;
}

.popup-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:18px;
}

.popup-actions button{
  border:none;
  border-radius:12px;
  padding:12px;
  cursor:pointer;
  font-weight:600;
  background:#ff2e97;
  color:white;
}

.popup-actions .secondary-btn{
  background:transparent;
  border:2px solid #00e5ff;
  color:#00e5ff;
}

/* ANIMATIONS */
@keyframes fadeSlideUp{
  from{
    opacity:0;
    transform:translateY(18px);
  }
  to{
    opacity:1;
    transform:translateY(0);
  }
}

@keyframes cardPopIn{
  from{
    opacity:0;
    transform:translateY(18px) scale(0.97);
  }
  to{
    opacity:1;
    transform:translateY(0) scale(1);
  }
}

@keyframes badgeGlow{
  0%,100%{
    box-shadow:0 0 12px rgba(0,229,255,0.12);
  }
  50%{
    box-shadow:0 0 22px rgba(0,229,255,0.22);
  }
}

/* LIGHT MODE */
body.light-mode{
  background:#f4f6fb;
  color:#222;
}

body.light-mode .sidebar{
  background:white;
}

body.light-mode .sidebar-toggle{
  background:rgba(108,76,255,0.1);
}

body.light-mode .sidebar-toggle span{
  background:#1a1140;
}

body.light-mode .menu a{
  color:#222;
}

body.light-mode .card{
  background:white;
  color:#222;
  box-shadow:0 5px 15px rgba(0,0,0,0.1);
}

body.light-mode .progress-bar{
  background:#ddd;
}

body.light-mode .user-top{
  background:#ffffff;
  box-shadow:0 5px 15px rgba(0,0,0,0.08);
}

body.light-mode .subject-icon{
  background:#f3f4f8;
}

body.light-mode .subject-badge{
  background:linear-gradient(135deg,#ff2e97,#ff8c00);
  color:white;
  box-shadow:0 0 16px rgba(255,46,151,0.16);
}

body.light-mode .popup-box{
  background:white;
  color:#222;
  box-shadow:0 10px 30px rgba(0,0,0,0.15);
}

body.light-mode .popup-actions .secondary-btn{
  color:#0077ff;
  border-color:#0077ff;
}

body.light-mode .theme-toggle{
  background:linear-gradient(135deg,#ff2e97,#ff8c00);
  color:white;
  box-shadow:0 0 15px rgba(255,46,151,0.35);
}

/* RESPONSIVE */
@media(max-width:1100px){
  .stats-grid,
  .subjects-grid{
    grid-template-columns:1fr;
  }
}

@media(max-width:900px){
  .layout{
    flex-direction:column;
    position:relative;
  }

  .sidebar-toggle{
    display:inline-flex;
  }

  .sidebar{
    display:none;
    position:fixed;
    top:84px;
    left:12px;
    right:12px;
    width:auto;
    min-height:auto;
    max-height:calc(100vh - 108px);
    overflow:auto;
    border-radius:22px;
    box-shadow:0 18px 42px rgba(6,8,28,0.4);
    border:1px solid rgba(255,255,255,0.08);
    z-index:1200;
  }

  .layout.mobile-nav-open .sidebar{
    display:flex;
  }

  .layout.mobile-nav-open .sidebar-toggle span:nth-child(1){
    transform:translateY(7px) rotate(45deg);
  }

  .layout.mobile-nav-open .sidebar-toggle span:nth-child(2){
    opacity:0;
  }

  .layout.mobile-nav-open .sidebar-toggle span:nth-child(3){
    transform:translateY(-7px) rotate(-45deg);
  }

  .main{
    padding:20px;
  }

  .topbar{
    flex-direction:row;
    align-items:center;
    justify-content:space-between;
    flex-wrap:nowrap;
  }

  .user-top{
    margin-left:auto;
    align-self:auto;
    flex-shrink:0;
  }
}

@media(max-width:600px){
  .main{
    padding:16px 12px 24px;
  }

  .topbar{
    gap:10px;
  }

  .topbar-title{
    flex:1;
    min-width:0;
  }

  .page-title{
    font-size:28px;
  }

  .page-subtitle{
    display:none;
  }

  .user-top{
    padding:8px 10px;
    gap:8px;
  }

  .user-top span{
    font-size:13px;
    white-space:nowrap;
  }

  .user-top img{
    width:34px;
    height:34px;
  }

  .sidebar{
    top:72px;
    left:10px;
    right:10px;
    padding:18px;
  }

  .menu{
    gap:20px;
    padding-top:8px;
  }
}
