/* ================================================================
   TTU Student Cloud — Base Styles & Desktop Layout
================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a    { color: inherit; text-decoration: none; }
img  { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
[hidden] { display: none !important; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ── Focus ── */
:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ── App shell: sidebar + content ── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--t3);
  overflow: hidden;
}
#sidebar.collapsed { width: var(--sidebar-coll); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 900; font-size: 18px;
  color: var(--primary-dark);
  flex-shrink: 0;
  letter-spacing: -1px;
}
.sidebar-brand {
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  transition: opacity var(--t2), width var(--t2);
}
.sidebar-brand-name {
  font-family: var(--font-display);
  font-weight: 800; font-size: 15px;
  color: white; white-space: nowrap;
  letter-spacing: -.3px;
}
.sidebar-brand-sub {
  font-size: 11px; color: rgba(255,255,255,.5);
  white-space: nowrap; margin-top: 1px;
}
#sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }

/* Toggle button */
.sidebar-toggle {
  margin-left: auto; flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1);
  border-radius: var(--r-sm); color: white;
  transition: background var(--t);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.2); }
.sidebar-toggle i { font-size: 18px; }
#sidebar.collapsed .sidebar-toggle { margin-left: 0; }

/* User info strip */
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; margin: 12px 10px;
  background: rgba(255,255,255,.08);
  border-radius: var(--r);
  overflow: hidden;
}
.sidebar-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
  color: var(--primary-dark); flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; overflow: hidden; transition: opacity var(--t2); }
.sidebar-user-name { font-weight: 700; font-size: 13px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.5); }
#sidebar.collapsed .sidebar-user-info { opacity: 0; }

/* Nav items */
.sidebar-nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: rgba(255,255,255,.35);
  padding: 14px 10px 6px; white-space: nowrap;
  overflow: hidden; transition: opacity var(--t2);
}
#sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.65); font-size: 13.5px; font-weight: 600;
  transition: all var(--t); cursor: pointer;
  white-space: nowrap; overflow: hidden;
  position: relative;
}
.nav-item i { font-size: 20px; flex-shrink: 0; }
.nav-item span { overflow: hidden; transition: opacity var(--t2); }
#sidebar.collapsed .nav-item span { opacity: 0; }
.nav-item:hover { background: rgba(255,255,255,.1); color: white; }
.nav-item.active {
  background: rgba(255,255,255,.15);
  color: white;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto; flex-shrink: 0;
  background: var(--crimson);
  color: white; font-size: 10px; font-weight: 800;
  padding: 1px 6px; border-radius: 99px;
  transition: opacity var(--t2);
}
#sidebar.collapsed .nav-badge { opacity: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .nav-item { color: rgba(255,255,255,.5); }
.sidebar-footer .nav-item:hover { color: rgba(255,255,255,.8); }

/* ════════════════════════════════════════
   MAIN CONTENT AREA
════════════════════════════════════════ */
#main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t3);
}
#main-wrap.sidebar-collapsed { margin-left: var(--sidebar-coll); }

/* ── Top bar ── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  letter-spacing: -.3px;
}

.topbar-search {
  flex: 1; max-width: 420px; margin-left: auto;
  position: relative;
}
.topbar-search i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--text-3); font-size: 18px;
  pointer-events: none;
}
.topbar-search input {
  width: 100%; padding: 9px 14px 9px 38px;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--r-full); font-size: 13.5px; color: var(--text);
  outline: none; transition: border-color var(--t), box-shadow var(--t);
}
.topbar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.topbar-search input::placeholder { color: var(--text-3); }

.topbar-actions {
  display: flex; align-items: center; gap: 6px;
}
.topbar-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--text-2);
  position: relative; transition: background var(--t);
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-btn i { font-size: 20px; }
.topbar-notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--crimson); border: 2px solid var(--surface);
}

.topbar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px; border-radius: var(--r);
  cursor: pointer; transition: background var(--t);
  border: 1.5px solid var(--border);
}
.topbar-user:hover { background: var(--surface-2); }
.topbar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; color: white; flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; font-weight: 700; color: var(--text); }
.topbar-user-role { font-size: 11px; color: var(--text-3); }

/* ── Page content ── */
#page-content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

/* ════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
════════════════════════════════════════ */
@media (max-width: 1200px) {
  :root { --sidebar-w: 220px; }
}

@media (max-width: 900px) {
  #sidebar { width: var(--sidebar-coll); }
  #sidebar .sidebar-brand,
  #sidebar .sidebar-user-info,
  #sidebar .nav-item span,
  #sidebar .nav-section-label,
  #sidebar .nav-badge { opacity: 0; pointer-events: none; }
  #main-wrap { margin-left: var(--sidebar-coll); }
  #sidebar .sidebar-toggle { display: none; }
}

@media (max-width: 600px) {
  #mobile-menu-btn { display: grid !important; }

  #sidebar {
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform var(--t3);
    z-index: 300;
  }
  #sidebar.mobile-open { transform: translateX(0); }
  /* On mobile the collapsed state is irrelevant — always show full labels when open */
  #sidebar.collapsed { width: min(280px, 82vw); }
  #sidebar .sidebar-brand,
  #sidebar .sidebar-user-info,
  #sidebar .nav-item span,
  #sidebar .nav-section-label,
  #sidebar .nav-badge { opacity: 1; pointer-events: auto; width: auto; }
  #sidebar .sidebar-toggle { display: none; }

  #sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 290;
  }
  #sidebar-overlay.open { display: block; animation: fadeIn .2s ease; }

  #main-wrap, #main-wrap.sidebar-collapsed { margin-left: 0; }
  #page-content { padding: 16px; }
  #topbar { padding: 0 12px; gap: 10px; }
  .topbar-title { font-size: 16px; }
  .topbar-search { display: none; }
  .topbar-user-info,
  .topbar-user > div:not(.topbar-avatar) { display: none; }
}

@media (max-width: 400px) {
  .topbar-user { padding: 5px; border: none; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }

/* ── Animate page transitions ── */
.page { animation: pageFade .2s ease; }
@keyframes pageFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
