/* ==========================================================================
   CareerHub — Ultra-Fast Academic Directory
   Zero external dependencies. Pure vanilla CSS & JS.
   ========================================================================== */

:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-light: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --primary: #0f172a;
  --accent-gold: #f59e0b;
  --accent-blue: #0284c7;
  --accent-green: #059669;
  --accent-red: #dc2626;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.15);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Nirmala UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 24px;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--text-main);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-main);
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Search bar */
.search-wrapper {
  flex: 1;
  max-width: 600px;
  position: relative;
}

.search-input-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  font-size: 14px;
  font-family: inherit;
  background: #f1f5f9;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--text-main);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  display: none;
  line-height: 1;
}

.search-clear-btn:hover {
  color: var(--text-main);
}

/* Dropdown Search Results */
/* Dropdown Search Results (Expanded wide to the left) */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 980px;
  max-width: calc(100vw - 48px);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.05);
  max-height: 540px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}

.search-header-bar {
  position: sticky;
  top: 0;
  background: #ffffff;
  padding: 12px 20px 8px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.search-count {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.search-col-heads {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 2.2fr) 76px;
  gap: 16px;
  padding: 8px 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-light);
  background: #f8fafc;
  align-items: center;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 2.2fr) 76px;
  gap: 16px;
  padding: 9px 20px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease;
  align-items: center;
}

.search-action-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.search-row:hover {
  background: #f1f5f9;
}

.search-file-cell {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-path-cell {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

mark {
  background: #fef08a;
  color: #0f172a;
  padding: 0 2px;
  border-radius: 2px;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-heading {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

/* ==========================================================================
   MASTERCARD FLIP CARDS GRID (MAX 4 PER ROW)
   ========================================================================== */
.mastercards-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

@media (max-width: 1240px) {
  .mastercards-container {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 940px) {
  .mastercards-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .mastercards-container {
    grid-template-columns: 1fr;
  }
}

/* Uiverse.io Flip Card CSS (Adapted & Enhanced) */
.flip-card {
  background-color: transparent;
  width: 100%;
  height: 184px;
  perspective: 1000px;
  color: white;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: left;
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.3), 0 2px 6px -1px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Theme Gradients */
.theme-black   .flip-card-front, .theme-black   .flip-card-back { background: linear-gradient(135deg, #1c1917 0%, #09090b 100%); }
.theme-navy    .flip-card-front, .theme-navy    .flip-card-back { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.theme-emerald .flip-card-front, .theme-emerald .flip-card-back { background: linear-gradient(135deg, #064e3b 0%, #022c22 100%); }
.theme-ruby    .flip-card-front, .theme-ruby    .flip-card-back { background: linear-gradient(135deg, #881337 0%, #4c0519 100%); }
.theme-titanium .flip-card-front, .theme-titanium .flip-card-back { background: linear-gradient(135deg, #27272a 0%, #18181b 100%); }
.theme-amethyst .flip-card-front, .theme-amethyst .flip-card-back { background: linear-gradient(135deg, #4c1d95 0%, #2e1065 100%); }
.theme-petrol  .flip-card-front, .theme-petrol  .flip-card-back { background: linear-gradient(135deg, #134e4a 0%, #042f2e 100%); }
.theme-bronze  .flip-card-front, .theme-bronze  .flip-card-back { background: linear-gradient(135deg, #78350f 0%, #451a03 100%); }
.theme-cobalt  .flip-card-front, .theme-cobalt  .flip-card-back { background: linear-gradient(135deg, #1e3a8a 0%, #172554 100%); }
.theme-rose    .flip-card-front, .theme-rose    .flip-card-back { background: linear-gradient(135deg, #701a75 0%, #4a044e 100%); }
.theme-slate   .flip-card-front, .theme-slate   .flip-card-back { background: linear-gradient(135deg, #334155 0%, #1e293b 100%); }
.theme-stealth .flip-card-front, .theme-stealth .flip-card-back { background: linear-gradient(135deg, #111827 0%, #030712 100%); }
.theme-cardinal .flip-card-front, .theme-cardinal .flip-card-back { background: linear-gradient(135deg, #7f1d1d 0%, #450a0a 100%); }

/* Subtle overlay pattern */
.flip-card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.12), transparent 60%);
  pointer-events: none;
}

.heading_8264 {
  position: absolute;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 800;
  top: 1.3rem;
  left: 1.3rem;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
}

.logo {
  position: absolute;
  top: 1.1rem;
  right: 1.3rem;
  width: 36px;
  height: 24px;
}

.chip {
  position: absolute;
  top: 3.4rem;
  left: 1.3rem;
  width: 30px;
  height: 30px;
}

.contactless {
  position: absolute;
  top: 3.8rem;
  left: 3.8rem;
  width: 18px;
  height: 18px;
}

.name {
  position: absolute;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.3;
  bottom: 1.2rem;
  left: 1.3rem;
  right: 1.3rem;
  color: #ffffff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Card Back */
.flip-card-back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
}

.strip {
  position: absolute;
  background-color: #000;
  width: 100%;
  height: 32px;
  top: 1.5rem;
  background: repeating-linear-gradient(
    45deg,
    #18181b,
    #18181b 10px,
    #09090b 10px,
    #09090b 20px
  );
}

.back-content {
  position: absolute;
  top: 4.1rem;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.back-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
}

.back-stat-item {
  display: flex;
  flex-direction: column;
}

.back-stat-lbl {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.65);
}

.back-stat-val {
  font-size: 12.5px;
  font-weight: 800;
  color: #ffffff;
  font-family: var(--font-mono);
}

.card-explore-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.2s ease;
}

.card-explore-btn:hover {
  background: #ffffff;
  color: #0f172a;
}

/* ==========================================================================
   FULL DIRECTORY SECTION — SQUARE FOLDER CARDS
   ========================================================================== */
.directory-section {
  margin-top: 10px;
}

.course-group-block {
  margin-bottom: 36px;
}

.course-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
}

.course-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.course-code-pill {
  font-size: 11px;
  font-weight: 800;
  background: var(--text-main);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.course-group-stats {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* SQUARE TYPE FOLDER CARDS GRID */
.square-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.square-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.square-card:hover {
  border-color: var(--text-main);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  background: #ffffff;
}

.square-card-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.square-folder-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.square-card-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: auto;
  padding-top: 10px;
}

.video-count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.badge-has-videos {
  background: #09090b;
  color: #ffffff;
  border: 1px solid #09090b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.badge-pdf-only {
  background: #ffffff;
  color: #09090b;
  border: 1.5px solid #09090b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.square-card:hover .badge-has-videos {
  background: #27272a;
  border-color: #27272a;
  transform: translateY(-1px);
}

.square-card:hover .badge-pdf-only {
  background: #09090b;
  color: #ffffff;
  transform: translateY(-1px);
}


/* ==========================================================================
   POPUP MODAL (FOLD / UNFOLD)
   CLICKING OUTSIDE WILL NOT CLOSE! ONLY "✕" BUTTON CLOSES!
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 900px;
  height: 85vh;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-header-left {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.05);
}

.modal-toolbar {
  padding: 10px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  align-items: center;
}

.modal-filter-input {
  flex: 1;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  outline: none;
}

.modal-filter-input:focus {
  border-color: var(--text-main);
}

.modal-btn {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-btn:hover {
  background: var(--text-main);
  color: #ffffff;
}

.modal-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  background: #fafafa;
}

/* MODAL TREE STYLES */
.modal-tree details {
  margin: 4px 0;
}

.modal-tree summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  user-select: none;
  transition: background 0.15s ease;
}

.modal-tree summary::-webkit-details-marker {
  display: none;
}

.modal-tree summary:hover {
  background: #f1f5f9;
}

.modal-tree summary::before {
  content: "▶";
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.modal-tree details[open] > summary::before {
  transform: rotate(90deg);
}

.tree-sub-body {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--border-light);
  margin-top: 4px;
}

/* Tree files */
.tree-file-list {
  list-style: none;
  margin: 4px 0;
}

.tree-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 12.5px;
  border-radius: 4px;
  transition: background 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
}

.tree-file-row:hover {
  background: #f1f5f9;
}

.ext-badge {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ext-video { background: #fed7aa; color: #9a3412; }
.ext-pdf   { background: #fecdd3; color: #9f1239; }
.ext-audio { background: #e9d5ff; color: #6b21a8; }
.ext-other { background: #e2e8f0; color: #475569; }

.file-row-name {
  flex: 1;
  word-break: break-word;
  color: var(--text-main);
}

.file-row-size {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.file-row-locked {
  font-size: 9px;
  font-weight: 800;
  background: #fee2e2;
  color: #b91c1c;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Highlight for file targeted from global search */
@keyframes targetGlow {
  0% {
    background: #fef08a;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.6);
  }
  50% {
    background: #fde047;
    box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.85);
  }
  100% {
    background: #fef9c3;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.4);
  }
}

.tree-file-row.target-file-highlight {
  animation: targetGlow 1.2s ease-in-out infinite alternate;
  background: #fef08a !important;
  border-radius: 6px;
  position: relative;
  z-index: 10;
  border: 1px solid #ca8a04;
}

.tree-file-row.target-file-highlight .file-row-name {
  font-weight: 800;
  color: #713f12;
}


/* Drive folder open button (drive-links patch) */
.drive-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 5px;
  padding: 3px 9px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.drive-open-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25);
}
.tree-file-row .drive-open-btn { margin-left: 8px; }
