/* ==========================================================================
   MASAGANA HIGH SCHOOL — UNIFIED PORTAL DESIGN SYSTEM
   ========================================================================== */

:root {
  /* Core Light Palette (Heritage Gold & Crimson) */
  --bg-page:        #FBF1DE;
  --bg-card:        #FFFFFF;
  --bg-card-subtle: #F7EEDB;
  --bg-hover:       #EFE4CC;
  --bg-input:       #FFFFFF;
  --maroon-deep:    #5C0F1B;
  --maroon-main:    #7A1B2B;
  --maroon-mid:     #8E2236;
  --maroon-light:   #A13447;
  --banana-gold:    #D9A632;
  --banana-soft:    #E8CB87;
  --banana-pale:    #F5E9C3;
  --ink-primary:    #241A12;
  --ink-secondary:  #5A3E34;
  --ink-muted:      #8C7268;
  --line-color:     #DED2B8;
  --line-subtle:    #EAE0CA;
  --green-leaf:     #2E7D32;
  --green-bg:       #DCFCE7;
  --green-text:     #166534;
  --danger-red:     #D32F2F;
  --danger-bg:      #FEE2E2;
  --danger-text:    #991B1B;
  --sidebar-bg:     #5C0F1B;
  --sidebar-line:   rgba(232, 203, 135, 0.2);
  --shadow-sm:      0 2px 10px rgba(42, 10, 16, 0.06);
  --shadow-md:      0 10px 30px -8px rgba(42, 10, 16, 0.14);
  --sidebar-width:  245px;
}

[data-theme="dark"],
html[data-theme="dark"],
body[data-theme="dark"] {
  /* Core Dark Palette — Premium Deep Obsidian & Warm Gold */
  --bg-page:        #0D0F12;
  --bg-card:        #15181E;
  --bg-card-subtle: #1C2028;
  --bg-hover:       #242934;
  --bg-input:       #111317;
  --maroon-deep:    #F0CC65;
  --maroon-main:    #E6B800;
  --maroon-mid:     #8E2236;
  --maroon-light:   #A13447;
  --banana-gold:    #E6B800;
  --banana-soft:    #F0CC65;
  --banana-pale:    #262218;
  --ink-primary:    #F4F5F7;
  --ink-secondary:  #CBD1DC;
  --ink-muted:      #8E96A6;
  --line-color:     #262A35;
  --line-subtle:    #1E222B;
  --green-leaf:     #4ADE80;
  --green-bg:       #0E331B;
  --green-text:     #86EFAC;
  --danger-red:     #F87171;
  --danger-bg:      #3B1216;
  --danger-text:    #FCA5A5;
  --sidebar-bg:     #111317;
  --sidebar-line:   #222631;
  --shadow-sm:      0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md:      0 10px 30px -8px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body.portal-body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--ink-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ==========================================================================
   Left Sidebar Navigation & Mobile Drawer
   ========================================================================== */

.portal-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  border-right: 1px solid var(--sidebar-line);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sidebar-line);
  background: rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, var(--banana-soft), var(--banana-gold) 60%, #8a6c25);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4), 0 4px 10px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 20px;
  height: 20px;
}

.sidebar-brand-title {
  font-family: 'Source Serif 4', serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.sidebar-brand-title span {
  display: block;
  font-family: 'Spectral SC', serif;
  font-size: 0.62rem;
  color: var(--banana-soft);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-profile-card {
  padding: 0.85rem 1rem;
  background: rgba(251, 241, 222, 0.05);
  border-bottom: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.sidebar-profile-card:hover {
  background: rgba(251, 241, 222, 0.12);
}

.sidebar-pfp-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--banana-soft);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--maroon-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-pfp-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-pfp-initials {
  font-family: 'Source Serif 4', serif;
  color: var(--banana-soft);
  font-weight: 700;
  font-size: 1rem;
}

.sidebar-profile-meta {
  overflow: hidden;
  flex: 1;
}

.sidebar-user-name {
  font-family: 'Source Serif 4', serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-sub {
  font-size: 0.72rem;
  color: var(--banana-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sidebar-role-badge {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--banana-gold);
  color: #121316;
  padding: 1px 5px;
  border-radius: 4px;
}

.sidebar-nav {
  padding: 0.65rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: rgba(251, 241, 222, 0.85);
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: 42px;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  color: var(--banana-soft);
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(251, 241, 222, 0.12);
  color: #ffffff;
}

.nav-item.active {
  background: var(--banana-gold);
  color: #121316;
  font-weight: 700;
}

.nav-item.active svg {
  color: #121316;
}

.sidebar-footer {
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--sidebar-line);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.8rem;
  color: rgba(251, 241, 222, 0.85);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  min-height: 38px;
}

.footer-nav-link:hover {
  background: rgba(251, 241, 222, 0.12);
  color: #ffffff;
}

.footer-nav-link.active {
  background: var(--banana-gold);
  color: #121316;
}

.btn-signout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.8rem;
  background: transparent;
  border: 1px solid rgba(255, 150, 150, 0.3);
  color: #ffb3b3;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
}

.btn-signout:hover {
  background: rgba(211, 47, 47, 0.25);
  color: #ffffff;
  border-color: rgba(255, 150, 150, 0.6);
}

/* ==========================================================================
   Main Content & Topbar Layout
   ========================================================================== */

.portal-main {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.portal-topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--line-color);
  padding: 0.85rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.portal-topbar-burger {
  display: none;
  background: var(--bg-card-subtle);
  border: 1px solid var(--line-color);
  color: var(--ink-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-title-group h1 {
  font-family: 'Source Serif 4', serif;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  color: var(--maroon-deep);
  font-weight: 700;
  line-height: 1.2;
}

.topbar-subtext {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 1px;
}

.portal-container {
  padding: 1.5rem 1.8rem;
  flex-grow: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--line-color);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.portal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  border-bottom: 1px dashed var(--line-color);
  padding-bottom: 0.7rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.portal-card-title {
  font-family: 'Source Serif 4', serif;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--maroon-deep);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-select {
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line-color);
  background: var(--bg-input);
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--ink-primary);
  outline: none;
  cursor: pointer;
  min-height: 38px;
  transition: border-color 0.2s ease;
}

.filter-select:focus {
  border-color: var(--banana-gold);
}

.btn-primary {
  background: #5C0F1B;
  color: #ffffff;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.84rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  min-height: 38px;
}
.btn-primary:hover { background: #7A1B2B; transform: translateY(-1px); }

[data-theme="dark"] .btn-primary {
  background: #252A36;
  color: #F4F5F7;
  border: 1px solid var(--line-color);
}
[data-theme="dark"] .btn-primary:hover {
  background: #313746;
}

.btn-gold {
  background: var(--banana-gold);
  color: #121316;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  min-height: 38px;
}
.btn-gold:hover { background: #f0c544; transform: translateY(-1px); }

/* Table System */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.portal-table th {
  text-align: left;
  padding: 0.75rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--line-color);
  color: var(--maroon-deep);
}
.portal-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line-color);
  color: var(--ink-primary);
}

/* ==========================================================================
   Mobile Touch Responsiveness
   ========================================================================== */

@media (max-width: 880px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-main {
    margin-left: 0;
    width: 100%;
  }

  .portal-topbar-burger {
    display: inline-flex;
  }

  .portal-topbar {
    padding: 0.75rem 1rem;
  }

  .portal-container {
    padding: 1rem 0.8rem;
  }
}