/* ============================================================
   CSS Custom Properties (Theme Variables)
   ============================================================ */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-sidebar: #f0f2f5;
  --bg-sidebar-card: #ffffff;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-sidebar: #212529;
  --text-sidebar-muted: #6c757d;
  --text-sidebar-heading: #212529;
  --accent: #4a90d9;
  --accent-hover: #357abd;
  --accent-sidebar: #4a90d9;
  --border: #dee2e6;
  --border-sidebar: #dee2e6;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --card-bg: #ffffff;
  --tab-active-bg: #ffffff;
  --tab-inactive-bg: transparent;
  --tab-hover-bg: #f0f0f0;
  --toggle-bg: #e9ecef;
  --toggle-text: #495057;
  --scrollbar-thumb: #c0c0c0;
  --scrollbar-track: #f0f0f0;
  --divider-sidebar: rgba(0,0,0,0.1);
  --social-bg: #e9ecef;
  --social-color: #495057;
}

[data-theme="dark"] {
  --bg-primary: #1e1e2e;
  --bg-secondary: #252536;
  --bg-sidebar: #111122;
  --bg-sidebar-card: #1a1a30;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b8;
  --text-sidebar: #e0e0e0;
  --text-sidebar-muted: #a0a0b8;
  --text-sidebar-heading: #ffffff;
  --accent: #6db3f2;
  --accent-hover: #8ec8f8;
  --accent-sidebar: #6db3f2;
  --border: #3a3a4e;
  --border-sidebar: rgba(255,255,255,0.08);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --card-bg: #2a2a3e;
  --tab-active-bg: #2a2a3e;
  --tab-inactive-bg: transparent;
  --tab-hover-bg: #333350;
  --toggle-bg: #3a3a4e;
  --toggle-text: #c0c0d0;
  --scrollbar-thumb: #4a4a5e;
  --scrollbar-track: #2a2a3e;
  --divider-sidebar: rgba(255,255,255,0.1);
  --social-bg: rgba(255,255,255,0.08);
  --social-color: #a0a0b8;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--accent-hover);
}

.hidden {
  display: none !important;
}

/* ============================================================
   Top Bar
   ============================================================ */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--toggle-bg);
  color: var(--toggle-text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  user-select: none;
}
.toggle-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.toggle-btn i {
  font-size: 0.9rem;
}

#langToggle {
  min-width: 56px;
  justify-content: center;
  gap: 3px;
}
#langToggle .lang-zh::after {
  content: '/';
  margin: 0 2px;
  color: var(--text-secondary);
  font-weight: 300;
}
#langToggle:hover .lang-zh::after {
  color: rgba(255,255,255,0.7);
}
.active-lang {
  color: var(--accent);
  font-weight: 700;
}
#langToggle:hover .active-lang {
  color: #fff;
}

/* ============================================================
   Main Container
   ============================================================ */
.main-container {
  display: flex;
  min-height: 100vh;
  padding-top: 48px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  padding: 40px 24px 24px;
  transition: background 0.3s ease, color 0.3s ease;
  position: fixed;
  top: 48px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 50;
  border-right: 1px solid var(--border-sidebar);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar-wrapper {
  width: 150px;
  aspect-ratio: 5 / 7;
  border-radius: 0;
  overflow: hidden;
  border: 4px solid var(--accent-sidebar);
  margin-bottom: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-sidebar-heading);
}
.title {
  font-size: 0.9rem;
  color: var(--accent-sidebar);
  margin-bottom: 2px;
  font-weight: 500;
}
.affiliation {
  font-size: 0.85rem;
  color: var(--text-sidebar-muted);
  margin-bottom: 20px;
}

.contact-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--divider-sidebar);
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-sidebar-muted);
  word-break: break-all;
}
.contact-item a {
  color: var(--text-sidebar-muted);
  text-decoration: none;
}
.contact-item a:hover {
  color: var(--accent-sidebar);
}
.contact-item i {
  width: 18px;
  text-align: center;
  color: var(--accent-sidebar);
  flex-shrink: 0;
}

.social-links {
  display: flex;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--divider-sidebar);
  width: 100%;
  justify-content: center;
}
.social-link {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--social-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--social-color);
  font-size: 1rem;
  transition: all 0.2s ease;
}
.social-link:hover {
  background: var(--accent-sidebar);
  color: #fff;
}

/* ============================================================
   Content Area
   ============================================================ */
.content {
  flex: 1;
  margin-left: 300px;
  padding: 32px 40px;
  min-height: calc(100vh - 48px);
  transition: background 0.3s ease;
}

/* ============================================================
   Tab Navigation
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 24px;
  border: none;
  background: var(--tab-inactive-bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s ease;
  position: relative;
  bottom: -2px;
  border: 2px solid transparent;
}
.tab-btn:hover {
  color: var(--accent);
  background: var(--tab-hover-bg);
}
.tab-btn.active {
  color: var(--accent);
  background: var(--tab-active-bg);
  border-color: var(--border);
  border-bottom-color: var(--tab-active-bg);
  font-weight: 600;
}

/* ============================================================
   Tab Content
   ============================================================ */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}
.tab-content.active {
  display: block;
}

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

/* ============================================================
   CV Styles
   ============================================================ */
.cv-content {
  max-width: 800px;
}

.cv-section {
  margin-bottom: 28px;
}
.cv-section:last-child {
  margin-bottom: 0;
}

.cv-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cv-section-title i {
  font-size: 1.1rem;
}

/* Education */
.cv-edu-item {
  margin-bottom: 16px;
}
.cv-edu-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.cv-edu-school {
  font-weight: 700;
  font-size: 1.05rem;
}
.cv-edu-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cv-edu-degree {
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.cv-edu-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Publications */
.cv-pub-item {
  margin-bottom: 14px;
}
.cv-pub-title {
  font-weight: 700;
}
.cv-pub-authors {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.cv-pub-venue {
  font-style: italic;
  color: var(--accent);
  font-size: 0.9rem;
}
.cv-pub-link {
  font-size: 0.85rem;
  word-break: break-all;
}

/* List items */
.cv-list {
  list-style: none;
  padding: 0;
}
.cv-list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.cv-list li::before {
  content: '•';
  position: absolute;
  left: 2px;
  color: var(--accent);
  font-weight: bold;
}

.cv-item-title {
  font-weight: 600;
}

.cv-dated-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.cv-dated-line .cv-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cv-experience-item {
  margin-bottom: 12px;
}
.cv-experience-item .cv-item-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding-left: 18px;
  margin-top: 2px;
}

.cv-sub-section {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  margin-bottom: 12px;
}

.cv-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  padding-left: 18px;
}

/* ============================================================
   Gallery
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1000px;
}

.gallery-item {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card-bg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.gallery-item img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}
.gallery-caption {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ============================================================
   Scrollbar Styling
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ============================================================
   ICP Footer
   ============================================================ */
.icp-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 4px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 90;
}
.icp-footer a {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.icp-footer a:hover {
  color: var(--accent);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    width: 260px;
    min-width: 260px;
    padding: 30px 18px 18px;
  }
  .content {
    margin-left: 260px;
    padding: 24px 20px;
  }
  .avatar-wrapper {
    width: 120px;
  }
  .name {
    font-size: 1.3rem;
  }
  .sidebar {
    bottom: 24px;
  }
}

@media (max-width: 700px) {
  .main-container {
    flex-direction: column;
  }
  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    min-width: 100%;
    height: auto;
    padding: 24px 20px;
  }
  .content {
    margin-left: 0;
    padding: 20px 16px;
  }
  .avatar-wrapper {
    width: 100px;
  }
  .sidebar-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    text-align: center;
  }
  .contact-info, .social-links {
    border-top: none;
    padding-top: 0;
  }
  .top-bar {
    padding: 0 12px;
  }
  .tab-nav {
    overflow-x: auto;
    white-space: nowrap;
  }
}
