:root {
  /* Light Theme */
  --bg-color: #ffffff;
  --sidebar-bg: #ffffff;
  --text-primary: #1f1f1f;
  --text-secondary: #444746;
  --border-color: #e2e8f0;
  --hover-bg: #e8eaed;
  --card-bg: #ffffff;
  --input-bg: #f0f4f9;
  --accent-blue: #0b57d0;
  --accent-light: #eff6ff;
  --font-main: 'Outfit', sans-serif;
  --font-serif: 'Merriweather', serif;

  --tag-bg: #e0e7ff;
  --tag-text: #3730a3;
  --sidebar-width: 300px;
  --sidebar-collapsed-width: 0px;
  --header-blur: rgba(255, 255, 255, 0.95);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-color: #121212;
  --sidebar-bg: #18181b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --border-color: #27272a;
  --hover-bg: #3f3f46;
  --card-bg: #1e1e1e;
  --input-bg: #1e1e1e;
  --accent-blue: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  --tag-bg: #312e81;
  --tag-text: #e0e7ff;
  --header-blur: #18181b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* --- SIDEBAR --- */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 150;
  overflow-x: hidden;
  overflow-y: auto;
  white-space: nowrap;
}

.sidebar-header {
  padding-left: 20px;
  display: flex;
  align-items: center;
  height: 64px;
  border-bottom: 1px solid var(--border-color);
}

.brand-text {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.5px;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 24px;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  margin-top: 8px;
  padding-left: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: 0.2s;
}

.nav-item:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-blue);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

body.desktop-collapsed #sidebar {
  width: var(--sidebar-collapsed-width);
  border-right: none;
}

#mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
  display: none;
  backdrop-filter: blur(2px);
  transition: opacity 0.3s;
}

/* --- MAIN CONTENT --- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
  background: var(--bg-color);
  transition: background-color 0.3s;
  min-width: 0;
  overflow: hidden;
}

header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  background: var(--header-blur);
  backdrop-filter: blur(8px);
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  height: 64px;
  transition: background-color 0.3s, border-color 0.3s;
}

.header-left-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-search-wrapper {
  flex: 1;
  margin: 0 24px;
  display: flex;
  justify-content: center;
}

.header-right-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#menuBtn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#menuBtn:hover {
  background: var(--hover-bg);
}

.header-archive-text {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
  margin-left: 8px;
}

.search-bar {
  background: var(--input-bg);
  border-radius: 24px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
  border: 1px solid transparent;
  transition: 0.2s;
}

.search-bar:focus-within {
  background: var(--card-bg);
  border-color: var(--accent-blue);
}

.search-input {
  border: none;
  background: transparent;
  flex: 1;
  outline: none;
  font-family: var(--font-main);
  font-size: 15px;
  margin-left: 8px;
  color: var(--text-primary);
}

.header-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-accent {
  color: var(--accent-blue);
}

.theme-btn {
  background: transparent;
  border: none;
  /* width: 40px;
  height: 40px; */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
  padding: 8px;
}

.theme-btn:hover {
  background: var(--hover-bg);
  border-radius: 8px;
}

.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  transition: 0.2s;
}

.back-btn:hover {
  background: var(--hover-bg);
  color: var(--accent-blue);
}

#content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scroll-behavior: smooth;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

.section-headline {
  font-family: var(--font-serif);
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.section-subhead {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 15px;
}

/* Folder Card Styles */
.archive-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 32px;
  overflow: hidden;
  transition: 0.3s;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sidebar-bg);
}

.year-title {
  font-family: 'Merriweather', serif;
  font-size: 24px;
  font-weight: 900;
}

.card-body {
  padding: 24px;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.sub-section-details {
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.sub-section-summary {
  padding: 14px 20px;
  background: var(--bg-color);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.2s;
}

.sub-section-summary:hover {
  background: var(--hover-bg);
}

.sub-section-summary::after {
  content: '+';
  font-size: 18px;
  color: var(--text-secondary);
}

details[open] .sub-section-summary::after {
  content: '−';
}

.sub-section-content {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* PDF Grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
  cursor: pointer;
  transition: 0.2s;
}

.file-item:hover {
  border-color: var(--accent-blue);
  background: var(--hover-bg);
  transform: translateY(-1px);
}

.icon-box {
  width: 32px;
  height: 32px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 900;
  margin-right: 12px;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.save-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  transition: 0.2s;
}

.save-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

/* --- PDF MODAL --- */
#pdfModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

#pdfModal.active {
  display: flex;
}

.pdf-content {
  width: 90%;
  height: 90%;
  background: var(--card-bg);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.pdf-header {
  padding: 12px 24px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pdf-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.pdf-filename {
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
  color: var(--text-primary);
}

.btn-modal-action {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--accent-blue);
  color: white;
  transition: 0.2s;
  flex-shrink: 0;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-left: 12px;
}

.btn-close-modal:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

#pdfFrame {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: #ececec;
}

@media (max-width: 1024px) {
  #sidebar {
    position: fixed;
    height: 100%;
    transform: translateX(-100%);
    width: 280px;
  }

  body.mobile-sidebar-open #sidebar {
    transform: translateX(0);
  }

  body.mobile-sidebar-open #mobile-overlay {
    display: block;
  }

  header {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px 16px;
    height: auto;
    align-items: center;
  }

  .header-left-group {
    order: 1;
    margin-right: auto;
  }

  .header-right-group {
    order: 2;
    margin-left: 0;
  }

  .header-search-wrapper {
    order: 3;
    width: 100%;
    margin-top: 12px;
  }

  .header-archive-text {
    display: block;
    font-size: 18px;
  }

  #content-scroll {
    padding: 16px;
  }

  .pdf-content {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .pdf-filename {
    max-width: 45%;
    font-size: 14px;
  }
}

/* --- EXCEL-STYLE TAB BAR --- */
.tab-bar-wrapper {
  position: sticky;
  top: 64px; /* Adjusted to match your header's min-height */
  z-index: 99;
  background: var(--header-blur);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.tab-bar-wrapper::before, .tab-bar-wrapper::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40px;
  pointer-events: none; z-index: 10; opacity: 0; transition: opacity 0.3s ease;
}
.tab-bar-wrapper::before { left: 0; background: linear-gradient(to right, var(--bg-color) 0%, transparent 100%); }
.tab-bar-wrapper::after { right: 0; background: linear-gradient(to left, var(--bg-color) 0%, transparent 100%); }
.tab-bar-wrapper.can-scroll-left::before { opacity: 1; }
.tab-bar-wrapper.can-scroll-right::after { opacity: 1; }

.excel-tab-bar { display: flex; overflow-x: auto; scrollbar-width: none; }
.excel-tab-bar::-webkit-scrollbar { display: none; }
.tab-link {
  padding: 14px 20px; white-space: nowrap; color: var(--text-secondary);
  font-size: 14px; font-weight: 600; border-bottom: 3px solid transparent;
  cursor: pointer; transition: all 0.2s ease; display: flex;
  align-items: center; gap: 6px; background: transparent; border-top: none;
  border-left: none; border-right: none; font-family: var(--font-main); text-decoration: none;
}
.tab-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.tab-link.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); background: rgba(37, 99, 235, 0.05); }

/* --- QUICK READS DROPDOWN --- */
.tab-dropdown { position: relative; display: inline-block; }
.tab-dropdown-menu {
  display: none; position: fixed; transform: translateX(-50%);
  background: var(--card-bg); min-width: 250px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color); border-radius: 12px; z-index: 1000;
  flex-direction: column; overflow: hidden;
}
.tab-dropdown-menu.show { display: flex; animation: fadeIn 0.2s ease-in-out; }
.tab-dropdown-menu a { padding: 12px 16px; color: var(--text-secondary); font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--border-color); transition: 0.2s; text-decoration: none; }
.tab-dropdown-menu a:hover { background: var(--accent-light); color: var(--accent-blue); }
.tab-dropdown-menu a:last-child { border-bottom: none; }
.dropdown-toggle.open svg { transform: rotate(180deg); }
.dropdown-toggle svg { transition: transform 0.3s ease; }

/* --- UPCOMING MODAL STYLES --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 999;
  display: none; justify-content: center; align-items: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-content {
  background: var(--card-bg); width: 90%; max-width: 500px;
  border-radius: 20px; display: flex; flex-direction: column;
  border: 1px solid var(--border-color); box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 18px; margin: 0; color: var(--text-primary); font-family: var(--font-main); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-secondary); line-height: 1; }
.modal-body { padding: 24px; font-size: 14px; line-height: 1.6; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
