/* Theme overrides to match a modern dashboard look */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b; /* slate-500 */
  --primary: #2563eb; /* blue-600 */
  --primary-700: #1d4ed8;
  --success: #16a34a; /* green-600 */
  --warning: #f59e0b; /* amber-500 */
  --violet: #7c3aed; /* violet-600 */
  --ring: rgba(37, 99, 235, 0.25);
  --shadow: 0 10px 25px rgba(2, 6, 23, 0.08);
  --radius: 16px;
  --container: 1160px;
}

body { background: var(--bg); color: var(--text); }
/* Softer background gradient for depth */
body { background: linear-gradient(180deg, #f6f9ff 0%, #f3f6fb 100%); }

/* Top navigation bar */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: linear-gradient(90deg, #1f3fb3 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 6, 23, 0.12);
}
.topbar .tb-inner {
  max-width: var(--container); margin: 0 auto; padding: 16px 16px;
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
}
.topbar .brand { font-weight: 700; color: #fff; letter-spacing: .3px; }
.topbar .brand:hover { color: #eef2ff; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.topbar .hello { opacity: .9; font-weight: 500; }
/* Welcome-only variant */
.topbar .welcome-text { font-weight: 800; font-size: 30px; letter-spacing: .3px; }

/* Buttons */
.btn { 
  display: inline-flex; align-items: center; gap: 6px; 
  padding: 8px 12px; border-radius: 10px; 
  background: rgba(255,255,255,0.12); color: #fff; 
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 1px 2px rgba(2,6,23,0.08);
  transition: all .2s ease;
}
.btn:hover { background: rgba(255,255,255,0.18); }
.btn.success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.success:hover { background: #15803d; }
.btn.ghost { background: #111827; border-color: #111827; }
.btn.ghost:hover { background: #0b1220; }

/* Make legacy table layout feel like cards */
/* Use collapse + row padding to avoid table height > tbody height caused by border-spacing top/bottom halves */
 table { max-width: var(--container); margin-top: 0; border-spacing: 0 !important; border-collapse: collapse !important; }
 /* Simulate vertical gaps between rows without border-spacing overflow */
 tr + tr td { padding-top: 16px; }
 table td { vertical-align: top; }
 td[width="250"] { border-radius: var(--radius); padding: 14px; }
 /* For the left content column (not the top header cell), remove top padding so photo aligns */
 td[width="250"]:not([height]) { padding-top: 0 !important; }
 td[width="700"] { border-radius: var(--radius); }

/* Align header row blocks (left Menu and right Name) */
td[width="250"][height="120"] { 
  padding: 16px !important; 
  height: 80px !important; /* Reduced height to match right cell */
  vertical-align: middle !important;
}
td[width="700"][valign="bottom"] { 
  padding: 16px !important; 
  height: 80px !important; /* Match left cell height */
  vertical-align: middle !important;
}

/* Align photo with the main content card top */
td[width="250"] td[background] { padding-top: 12px !important; }
/* Remove the extra <br> the HTML has before the image */
td[width="250"] td[background] > br:first-child { display: none !important; }
/* Photo alignment: nudge up to match the COORDINATES card top */
a[name="index"] img { margin-top: 0; display: block; }
/* Remove residual spacing coming from <center> wrapper */
td[width="250"] td[background] center { display: block; margin: 0; line-height: 0; }

/* Remove leading <br>s inside the main content card to align tops */
td[width="700"] > br { display: none !important; }
/* Ensure the first section heading sits flush at the top */
h1.coord { margin-top: 0 !important; }

/* Remove noisy legacy cell backgrounds and use clean surfaces */
td[background], td[bgcolor] {
  background: transparent;
}
td[background="resurse/bg.jpg"] { background: transparent !important; }
/* Main content card uses same gray as page sides with top padding to align with left photo */
td[width="700"] { background: #f3f6fb !important; padding-top: 12px !important; }
td[width="700"][background], td[width="700"][rowspan], td[width="700"][valign] { background: #f3f6fb !important; padding-top: 12px !important; }
td[width="250"] { background: linear-gradient(180deg, rgba(36,50,147,0.95) 0%, rgba(36,50,147,0.70) 100%); color: #eef2ff; }
/* soften the gradient */
td[width="250"] { background: linear-gradient(180deg, rgba(36,50,147,0.92) 0%, rgba(36,50,147,0.65) 100%); }

/* Card-like sections and subtle borders */
.card, td[width="700"], td[width="250"] {
  border: 1px solid rgba(2,6,23,0.06);
  box-shadow: 0 6px 18px rgba(2,6,23,0.06);
}

/* Make the small header cell (name) blend with the page background (light gray) */
td[width="700"][valign="bottom"] {
  background: #f3f6fb !important; /* same tint as page sides */
  padding: 12px !important; /* reduce height */
  height: 80px !important; /* reduced height to be consistent */
  vertical-align: middle !important; /* center text vertically */
  text-align: center !important; /* center the name horizontally */
  border-radius: var(--radius) !important;
  box-shadow: 0 2px 6px rgba(2,6,23,0.04) !important;
}

/* Harmonize the big title style */
.textAntet {
  font-size: 24px !important;
  font-weight: 800 !important;
  color: #0b1220 !important;
  letter-spacing: .2px;
  margin: 0 !important;
}

/* Sidebar header "Menu" – nicer styling inside the top left gradient card */
td[width="250"][height="120"] .textAntet {
  display: block;
  color: #ffffff !important;
  font-size: 22px !important;
  font-weight: 700 !important; /* match Contact/Home */
  letter-spacing: .2px;
  text-shadow: none;
  border-bottom: none !important;
  padding: 6px 10px 8px 10px; /* match Contact/Home */
  margin: 8px 0 10px 0; /* consistent spacing */
}
td[width="250"][height="120"] .textAntet::before {
  content: none !important;
  display: none !important;
}

/* Remove decorative icon before ALL left titles (Menu, Contact, Home) */
td[width="250"] .textAntet::before {
  content: none !important;
  display: none !important;
}
td[width="250"][height="120"] .textAntet::after {
  content: "";
  height: 1px;
  flex: 1;
  margin-left: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.35), rgba(255,255,255,0));
}

/* Menu links look cleaner */
 td[width="250"] a { font-weight: 600; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; }
 td[width="250"] a:hover { transform: translateY(-1px); background: rgba(255,255,255,0.10); }
 td[width="250"] a[data-active="true"] { outline: 2px solid rgba(255,255,255,0.22); }

/* Headings like dashboard */
 h1 { font-size: 2rem; margin: 6px 10px; }
 h2 { color: #0b1220; margin: 6px 10px; }
 h1.coord { 
   color: #0b1220; 
   text-align: center; 
   font-size: 2.25rem; 
   font-weight: 800; 
   letter-spacing: .3px; 
   margin: 8px 10px 14px 10px; 
 }
 h1.coord::after {
   content: "";
   display: block;
   width: 72px;
   height: 3px;
   margin: 10px auto 0 auto;
   border-radius: 999px;
   background: linear-gradient(90deg, rgba(37,99,235,.6), rgba(37,99,235,0));
 }
 h2.coord { 
   color: #334155; /* slate-700 */
   text-align: center; 
   font-size: 1.125rem; 
   font-weight: 600; 
   line-height: 1.6; 
   margin: 6px 10px; 
 }

/* Normalize legacy <font> headings inside the right content card across all pages */
td[width="700"] font[size="6"] {
  display: block;
  font-size: 2.25rem !important; /* match h1.coord */
  font-weight: 800 !important;
  color: #0b1220 !important;
  letter-spacing: .3px;
  text-align: center;
  margin: 8px 10px 14px 10px;
}
td[width="700"] font[size="5"] {
  display: block;
  font-size: 1.25rem !important; /* match secondary heading */
  font-weight: 600 !important;
  color: #334155 !important; /* slate-700 */
  text-align: center;
  margin: 6px 10px 8px 10px;
}

/* Sidebar section titles (Menu, Contact, Home) – same look */
td[width="250"] font.textAntet, td[width="250"] .textAntet {
  display: block;
  margin: 8px 10px 10px 10px;
  padding: 6px 0 8px 0;
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  background: none;
  border-radius: 0;
  box-shadow: none;
  border: 0 !important;
}
/* Soft fading divider under all left titles */
td[width="250"] .textAntet::after, td[width="250"] font.textAntet::after {
  content: "";
  display: block;
  height: 1px;
  margin-left: 12px;
  margin-top: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.35), rgba(255,255,255,0));
}

/* Sidebar dividers subtler */
td[bgcolor="#191970"], td[background="resurse/headerbg.gif"] { display: none; }

/* Contact list clean spacing */
#contact { line-height: 1.9; }
#contact img { width: 18px; height: 18px; filter: drop-shadow(0 1px 0 rgba(0,0,0,.08)); }
/* nicer link color and hover in content */
td[width="700"] a { color: #2563eb; }
td[width="700"] a:hover { color: #1e40af; }

/* Research page links styling */
td[width="700"] ul.research-links {
  list-style: none;
  margin: 0 10px 10px 10px;
  padding: 0 20px;
}
td[width="700"] ul.research-links li { margin: 12px 0; }
td[width="700"] ul.research-links h2 { margin: 0; font-weight: 700; }
td[width="700"] ul.research-links a {
  color: #0b1220;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
td[width="700"] ul.research-links a::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #94a3b8; /* slate-400 */
}
td[width="700"] ul.research-links a:hover { color: #1e40af; }
/* Ordered link list (used on research.html to mimic teaching page) */
td[width="700"] ol.list-links {
  margin: 0 10px 10px 36px;
  padding-left: 18px; /* ensure numbers align nicely */
}
td[width="700"] ol.list-links li { margin: 6px 0; }
td[width="700"] ol.list-links a { color: #2563eb; text-decoration: none; }
td[width="700"] ol.list-links a:hover { color: #1e40af; text-decoration: underline; }

/* Breadcrumb styling (used on papers.html) */
td[width="700"] nav.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 10px 10px 10px;
  color: #64748b; /* slate-500 */
}
td[width="700"] nav.breadcrumb a {
  color: #2563eb; text-decoration: none; font-weight: 600;
}
td[width="700"] nav.breadcrumb a:hover { color: #1e40af; }
td[width="700"] nav.breadcrumb .sep { color: #94a3b8; }
td[width="700"] nav.breadcrumb .current { color: #0b1220; font-weight: 700; }

/* Media tweaks to ensure layout breathes on mobile */
@media (max-width: 900px) {
  td[width="250"] { padding: 12px; }
  td[width="700"] { padding: 16px; }
}

/* Enhanced mobile layout (small phones) */
@media (max-width: 640px) {
  /* Stack table columns */
  table { width: 100%; }
  tr, td { display: block; width: 100% !important; }
  /* Remove fixed heights for header cells and relax spacing */
  td[width="250"][height="120"], td[width="700"][valign="bottom"] {
    height: auto !important;
    padding: 12px !important;
  }
  /* Make name header centered and slightly smaller on phones */
  td[width="700"][valign="bottom"] .textAntet { font-size: 20px !important; }

  /* Reduce large headings a bit for narrow screens */
  h1 { font-size: 1.6rem; }
  h1.coord { font-size: 1.8rem; }
  h2, h2.coord { font-size: 1rem; }

  /* Fluid images in the left column */
  a[name="index"] img { width: 100%; height: auto; max-width: 260px; margin: 0 auto; }
  td[width="250"] center { display: flex; justify-content: center; }

  /* Increase tap target and spacing for menu items */
  td[width="250"] a { padding: 10px 12px; font-size: 16px; }
  #contact { line-height: 1.8; font-size: 16px; }

  /* Breadcrumb spacing tighter */
  td[width="700"] nav.breadcrumb { gap: 6px; margin: 0 10px 6px 10px; }
}

/* Pills/badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.success { background: rgba(22,163,74,.12); color: #166534; }
.badge.warning { background: rgba(245,158,11,.12); color: #92400e; }
.badge.violet { background: rgba(124,58,237,.12); color: #4c1d95; }

/* Smooth transitions */
* { transition: color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s ease; }

@media (max-width: 900px) {
  .topbar .tb-inner { padding: 10px 12px; }
}

/* Hamburger button (hidden on desktop) */
.hamburger { display: none; align-items: center; justify-content: center; flex-direction: column; width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; border-radius: 8px; }
.hamburger:focus { outline: 2px solid rgba(255,255,255,0.6); outline-offset: 2px; }
.hamburger .bar { display: block; width: 22px; height: 2px; background: #fff; margin: 3px 0; border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }

/* Drawer and backdrop */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease; z-index: 999; }
.mobile-drawer { position: fixed; top: 0; left: 0; height: 100%; width: 80%; max-width: 320px; background: #ffffff; color: #0b1220; box-shadow: 0 10px 30px rgba(0,0,0,.25); transform: translateX(-100%); transition: transform .25s ease; z-index: 1000; padding: 16px; display: flex; flex-direction: column; }
.mobile-drawer .drawer-title { font-weight: 800; font-size: 20px; margin: 6px 2px 10px; }
.mobile-drawer .drawer-menu { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
.mobile-drawer .drawer-menu a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #1e40af; padding: 10px 12px; border-radius: 10px; }
.mobile-drawer .drawer-menu a:hover { background: rgba(37,99,235,0.08); }
.mobile-drawer .drawer-menu a[data-active="true"] { background: rgba(37,99,235,0.12); color: #1e3a8a; font-weight: 700; }
.mobile-drawer .drawer-menu img { width: 18px; height: 18px; }
.mobile-drawer .drawer-footer { margin-top: auto; font-size: 12px; color: #64748b; }

/* Open states */
body.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }
body.drawer-open .mobile-drawer { transform: translateX(0); }

/* Mobile: hide legacy left sidebar, show hamburger */
@media (max-width: 768px) {
  td[width="250"] { display: none !important; }
  /* Also hide the left content column that lacks width attr (Geometry-1 and similar) */
  table > tbody > tr > td[valign="top"]:not([width]) { display: none !important; }
  .hamburger { display: inline-flex; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); z-index: 2; }
  /* Center welcome text on mobile while keeping hamburger at left */
  .topbar .tb-inner { position: relative; justify-content: center !important; padding-top: 16px; padding-bottom: 16px; min-height: 56px; }
  .topbar .welcome-text { position: absolute; left: 50%; transform: translateX(-50%); margin: 0; font-size: 20px; text-align: center; }
  .topbar .brand { font-size: 20px; }
}

/* Focus-swap cards (opt-in) */
.focus-card {
  background: #f3f6fb; /* muted */
  border: 2px solid rgba(2,6,23,0.06);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(2,6,23,0.04);
}
.focus-card.is-primary {
  background: #ffffff; /* highlighted */
  border-color: rgba(37,99,235,0.35); /* blue accent */
  box-shadow: var(--shadow), 0 0 0 3px var(--ring); /* soft focus ring */
}
/* Slight lift on hover for affordance */
.focus-card:hover { transform: translateY(-1px); }

/* Pure CSS highlight when interacting */
.focus-card:focus-within { 
  background: #ffffff; 
  border-color: rgba(37,99,235,0.35); 
  box-shadow: var(--shadow), 0 0 0 3px var(--ring); 
}
