/* =============================================================================
   QuadHub Campus Portal — Core Stylesheet
   Design: Refined Academic
   Typography: Playfair Display + Source Sans 3
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* =============================================================================
   CSS VARIABLES
   ============================================================================= */
:root {
  /* Colors */
  --navy:         #1a2744;
  --navy-dark:    #111c33;
  --navy-light:   #243358;
  --gold:         #c9a84c;
  --gold-light:   #dfc078;
  --gold-pale:    #f5ecd4;
  --white:        #ffffff;
  --bg:           #f8f6f1;
  --bg-card:      #ffffff;
  --border:       #ddd8ce;
  --border-light: #eceae4;
  --text:         #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted:   #8a8a8a;
  --success:      #2d6a4f;
  --warning:      #b5622a;
  --danger:       #8b2020;
  --info:         #1a4a6e;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Sans 3', 'Helvetica Neue', sans-serif;

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --content-max:   1200px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);

  /* Transitions */
  --transition: 0.2s ease;
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--navy); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

img { max-width: 100%; display: block; }

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  color: var(--navy);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-gold      { color: var(--gold); }
.text-navy      { color: var(--navy); }
.text-sm        { font-size: 0.8125rem; }
.text-xs        { font-size: 0.75rem; }
.text-uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.font-display   { font-family: var(--font-display); }

/* =============================================================================
   LAYOUT — PORTAL SHELL
   ============================================================================= */
.portal-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.sidebar-brand .brand-name span { color: var(--gold); }

.sidebar-brand .brand-institution {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-section { margin-bottom: 0.25rem; }

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  padding: 0.75rem 1.5rem 0.375rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.5rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.nav-item.active {
  color: var(--white);
  background: rgba(201,168,76,0.12);
  border-left-color: var(--gold);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; stroke-width: 1.5; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user { display: flex; align-items: center; gap: 0.75rem; }

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--navy-light);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white);
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main content area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top header bar */
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-search {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 1rem 0 2.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.topbar-search input:focus { border-color: var(--navy); }
.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-search .search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.topbar-btn svg { width: 18px; height: 18px; }

.topbar-btn:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--navy);
}

.topbar-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
}

/* Page content */
.page-content {
  flex: 1;
  padding: 2rem;
  max-width: var(--content-max);
  width: 100%;
}

.page-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.625rem;
  color: var(--navy);
  font-weight: 600;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* =============================================================================
   CARDS
   ============================================================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
}

.card-body { padding: 1.5rem; }

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* =============================================================================
   RESOURCE TILES
   ============================================================================= */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.resource-tile {
  background: var(--bg-card);
  padding: 1.25rem;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.resource-tile:hover { background: var(--gold-pale); }

.resource-tile.is-favorite::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--gold);
}

.resource-icon {
  width: 36px;
  height: 36px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.resource-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
}

.resource-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.resource-rating {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 600;
}

.resource-actions {
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.resource-tile:hover .resource-actions { opacity: 1; }

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary   { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: var(--white); }

.btn-gold      { background: var(--gold); color: var(--navy-dark); border-color: var(--gold); font-weight: 600; }
.btn-gold:hover { background: var(--gold-light); border-color: var(--gold-light); color: var(--navy-dark); }

.btn-outline   { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--navy); }

.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: transparent; padding: 0.375rem 0.75rem; }
.btn-ghost:hover { background: var(--bg); color: var(--navy); }

.btn-sm        { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-icon      { padding: 0.375rem; width: 32px; height: 32px; justify-content: center; }

/* =============================================================================
   BADGES
   ============================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid currentColor;
}

.badge-navy    { color: var(--navy); background: rgba(26,39,68,0.06); }
.badge-gold    { color: #8a6a1e; background: var(--gold-pale); }
.badge-success { color: var(--success); background: rgba(45,106,79,0.08); }
.badge-warning { color: var(--warning); background: rgba(181,98,42,0.08); }
.badge-danger  { color: var(--danger); background: rgba(139,32,32,0.08); }

/* =============================================================================
   ALERTS
   ============================================================================= */
.alert {
  padding: 0.875rem 1.25rem;
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.alert-info      { border-left-color: var(--info); }
.alert-warning   { border-left-color: var(--warning); }
.alert-danger    { border-left-color: var(--danger); }
.alert-success   { border-left-color: var(--success); }
.alert-emergency {
  border-left-color: var(--danger);
  background: #fff5f5;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0%, 100% { border-left-color: var(--danger); }
  50%       { border-left-color: #d4a0a0; }
}

.alert-title { font-weight: 600; font-size: 0.875rem; color: var(--navy); }
.alert-body  { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.2rem; }

/* =============================================================================
   SEARCH RESULTS DROPDOWN
   ============================================================================= */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.search-results.visible { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--gold-pale); }

.search-result-icon {
  width: 30px;
  height: 30px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.search-result-title    { font-size: 0.875rem; font-weight: 500; color: var(--navy); }
.search-result-category { font-size: 0.75rem; color: var(--text-muted); }
.search-no-results      { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; }

/* =============================================================================
   STAT CARDS
   ============================================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}

.stat-card { background: var(--bg-card); padding: 1.5rem; }

.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1;
}

.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.375rem; }

.stat-card.highlighted { background: var(--navy); }
.stat-card.highlighted .stat-label { color: rgba(255,255,255,0.5); }
.stat-card.highlighted .stat-value { color: var(--gold); }
.stat-card.highlighted .stat-sub   { color: rgba(255,255,255,0.4); }

/* =============================================================================
   FORMS
   ============================================================================= */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  background: var(--white);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.form-control:focus { border-color: var(--navy); }
.form-control::placeholder { color: var(--text-muted); }

textarea.form-control {
  height: auto;
  padding: 0.75rem 0.875rem;
  resize: vertical;
  min-height: 80px;
}

/* =============================================================================
   TABLES
   ============================================================================= */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* =============================================================================
   UTILITY
   ============================================================================= */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1           { gap: 0.5rem; }
.gap-2           { gap: 1rem; }
.gap-3           { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden          { display: none; }
.w-full          { width: 100%; }
.divider         { border: none; border-top: 1px solid var(--border-light); margin: 1.5rem 0; }
.divider-gold    { border-top: 2px solid var(--gold); width: 40px; margin: 1rem 0; }

/* =============================================================================
   LOADING
   ============================================================================= */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
}

@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
.fade-in { animation: fadeIn 0.35s ease forwards; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-delay-1 { animation-delay: 0.05s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.10s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.15s; opacity: 0; }
.fade-in-delay-4 { animation-delay: 0.20s; opacity: 0; }

/* =============================================================================
   TOAST
   ============================================================================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--navy-dark);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  animation: toastIn 0.25s ease;
}

.toast.success { border-left: 3px solid #4caf85; }
.toast.error   { border-left: 3px solid #c94c4c; }
.toast.warning { border-left: 3px solid var(--gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .page-content { padding: 1.5rem; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .resource-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
