/* ============================================================
   University Success Tracker — Complete Theme
   Includes: layout, sidebar, navbar, cards, chips, forms,
             mobile nav, dark mode, print styles
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --brand:        #4F46E5;
  --brand-2:      #7C3AED;
  --brand-3:      #0891B2;
  --brand-soft:   rgba(79,70,229,.10);
  --brand-soft-2: rgba(79,70,229,.16);
  --radius:       14px;
  --radius-sm:    10px;
  --shadow-xs:    0 1px 2px rgba(16,24,40,.04);
  --shadow-sm:    0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md:    0 6px 16px rgba(16,24,40,.08);
  --shadow-lg:    0 12px 32px rgba(16,24,40,.12);
  --sidebar-w:    260px;
  --sidebar-w-c:  76px;
  --navbar-h:     58px;
}

html[data-bs-theme="dark"] {
  --bs-body-bg:      #0f1117;
  --bs-body-color:   #e5e7eb;
  --bs-border-color: #1f2330;
  --bs-tertiary-bg:  #171a23;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  margin: 0;
}

a { text-decoration: none; }

/* Nicer scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(120,120,140,.35) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(120,120,140,.30); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(120,120,140,.5); }

/* ============================================================
   NAVBAR
   ============================================================ */
.app-navbar {
  height: var(--navbar-h);
  background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--bs-border-color-translucent);
  padding: .35rem 1rem;
  z-index: 1030;
}

.app-navbar .navbar-brand {
  font-weight: 700;
  color: var(--bs-body-color);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

/* ============================================================
   LAYOUT (sidebar + main)
   ============================================================ */
.app-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--navbar-h));
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.5rem 1.75rem 4rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color-translucent);
  position: sticky;
  top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .22s ease, transform .22s ease;
  z-index: 1020;
}

/* Collapsed mode (desktop) */
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-c); }
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-logout,
body.sidebar-collapsed .sidebar-pill {
  opacity: 0; pointer-events: none; width: 0;
  overflow: hidden; height: 0; margin: 0; padding: 0;
}
body.sidebar-collapsed .sidebar-link { justify-content: center; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.15rem 1rem 1rem;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}
.sidebar-brand i { font-size: 1.6rem; color: var(--brand); }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand-text strong { font-size: .95rem; }
.sidebar-brand-text small { color: var(--bs-secondary-color); font-size: .72rem; }

/* Sidebar body */
.sidebar-body {
  padding: 1rem .75rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100% - 68px);
}

/* Sidebar section label */
.sidebar-section {
  padding: .85rem .65rem .35rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  transition: all .18s ease;
}
.sidebar-section:first-of-type { padding-top: .35rem; }

/* Sidebar link */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--bs-body-color);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.sidebar-link i {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  opacity: .85;
}
.sidebar-link:hover {
  background: var(--bs-tertiary-bg);
  color: var(--brand);
  transform: translateX(2px);
}
.sidebar-link:hover i { opacity: 1; }

.sidebar-link.active {
  background: linear-gradient(90deg, var(--brand-soft), transparent);
  color: var(--brand);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 20%;
  bottom: 20%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.sidebar-link.active i { opacity: 1; }

/* Pill badge on link */
.sidebar-pill {
  margin-left: auto;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .12rem .45rem;
  border-radius: 999px;
  background: var(--brand-soft-2);
  color: var(--brand);
}

/* Sidebar user footer */
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .65rem;
  border-top: 1px solid var(--bs-border-color-translucent);
  margin-top: 1.5rem;
}
.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(79,70,229,.25);
}
.sidebar-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  flex: 1;
}
.sidebar-user-info strong {
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-info small {
  color: var(--bs-secondary-color);
  font-size: .72rem;
}
.sidebar-logout {
  color: var(--bs-secondary-color);
  padding: .35rem;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.sidebar-logout:hover {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--bs-border-color-translucent);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .18s ease, transform .18s ease;
  background: var(--bs-body-bg);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color-translucent);
  font-weight: 600;
  padding: .85rem 1rem;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(79,70,229,.18);
  transition: transform .18s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card .stat-label {
  opacity: .9;
  font-size: .82rem;
  margin-top: 2px;
}

.stat-card.secondary { background: linear-gradient(135deg, #059669, #0891B2); box-shadow: 0 6px 18px rgba(8,145,178,.18); }
.stat-card.warning   { background: linear-gradient(135deg, #D97706, #DC2626); box-shadow: 0 6px 18px rgba(217,119,6,.18); }
.stat-card.success   { background: linear-gradient(135deg, #059669, #10B981); box-shadow: 0 6px 18px rgba(5,150,105,.18); }

/* ============================================================
   SUBJECT CHIPS
   ============================================================ */
.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1.5px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  font-size: .87rem;
  font-weight: 500;
  transition: all .15s ease;
  user-select: none;
}
.subject-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.subject-chip.selected {
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.subject-chip.selected .chip-dot { background: #fff !important; }

.chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   QUICK ADD TILES
   ============================================================ */
.quick-add-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  padding: 1.1rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color-translucent);
  transition: transform .15s ease, border-color .15s, box-shadow .15s;
  font-size: .9rem;
  font-weight: 500;
}
.quick-add-tile i {
  font-size: 1.65rem;
  color: var(--brand);
}
.quick-add-tile:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  color: var(--brand);
}

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--bs-border-color-translucent);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
}
.mobile-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .68rem;
  text-decoration: none;
  color: var(--bs-secondary-color);
  padding: .35rem .5rem;
  border-radius: 10px;
  min-width: 56px;
  transition: color .15s;
}
.mobile-bottom-nav a i { font-size: 1.15rem; }
.mobile-bottom-nav a:hover,
.mobile-bottom-nav a.active { color: var(--brand); }

.mobile-bottom-nav .nav-plus {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 54px;
  height: 54px;
  font-size: 1.7rem;
  font-weight: 300;
  line-height: 1;
  transform: translateY(-16px);
  box-shadow: 0 8px 22px rgba(79,70,229,.45);
  transition: transform .18s ease;
}
.mobile-bottom-nav .nav-plus:hover {
  transform: translateY(-16px) scale(1.06);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-weight: 600;
  letter-spacing: .01em;
}

/* ============================================================
   ATTENDANCE BAR
   ============================================================ */
.attendance-bar {
  height: 8px;
  background: var(--bs-tertiary-bg);
  border-radius: 999px;
  overflow: hidden;
}
.attendance-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}

/* ============================================================
   STREAK FLAME
   ============================================================ */
.streak-flame {
  font-size: 2rem;
  line-height: 1;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 992px) {
  .mobile-bottom-nav { display: none !important; }
  body { padding-bottom: 0 !important; }
}

@media (max-width: 991.98px) {
  .app-layout { display: block; }
  .app-sidebar {
    position: fixed;
    width: 280px;
    height: 100vh;
    top: 0;
    left: 0;
    border-right: 1px solid var(--bs-border-color-translucent);
    box-shadow: var(--shadow-lg);
  }
  .app-main { padding: 1rem; }
  .sidebar-brand { display: none; }
  .sidebar-body { min-height: 100%; }
  body { padding-bottom: 72px; }
}

@media (max-width: 576px) {
  .stat-card .stat-value { font-size: 1.35rem; }
  .app-main { padding: .75rem; }
  .card-header { padding: .65rem .85rem; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .app-sidebar,
  .app-navbar,
  .mobile-bottom-nav,
  .sidebar-toggle,
  .theme-toggle,
  .dropdown,
  .modal,
  .btn { display: none !important; }
  .app-main { padding: 0; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.shadow-hover:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-2px);
}

.rounded-xl { border-radius: var(--radius) !important; }
.rounded-lg { border-radius: var(--radius-sm) !important; }