:root {
  --primary: #5c6bc0;
  --primary-light: #7986cb;
  --highlight: #fbc02d;
  --dark: #222;
  --text: #333;
  --bg-main: #f0f4ff;
  --bg-content: #e6f0ff;
  --white: #fff;
  --shadow: rgba(0, 0, 0, 0.1);
  --select-arrow: url('data:image/svg+xml;utf8,<svg fill="gray" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M5 8.5l5 5 5-5z"/></svg>');
  --select-arrow-dark: url('data:image/svg+xml;utf8,<svg fill="white" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M5 8.5l5 5 5-5z"/></svg>');
}

/* === Base Styles === */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

.content {
  width: 60%;
  padding: 25px;
  background-color: var(--bg-content);
  border-radius: 15px;
  margin: 20px 0;
  box-shadow: 0 4px 12px var(--shadow);
}

.content p {
  text-align: justify;
}

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg-main);
  color: var(--text);
}

.container {
  display: flex;
  min-height: 100vh;
}

.ads,
.sidebar {
  width: 20%;
  padding: 15px;
  box-sizing: border-box;
}

/* === Title === */
h1 {
  text-align: center;
  background: linear-gradient(to right, #3f51b5, #1a237e);
  color: white;
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 6px 15px rgba(50, 50, 93, 0.3);
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 25px;
  letter-spacing: 1px;
}

/* === Ads === */
.ad {
  background: #e0e0e0;
  height: 120px;
  margin-bottom: 15px;
  text-align: center;
  line-height: 120px;
  border-radius: 12px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 2px 4px var(--shadow);
}

/* === Filters: Material Inputs with Selects perfectly aligned === */
input[type='text']#searchInput,
select#universityFilter,
select#yearFilter {
  font-family: inherit;
  font-size: 15px;
  border: 2px solid #1976d2;
  border-radius: 8px;
  background: #fff;
  color: #222;
  height: 44px !important;
  line-height: 44px !important;
  padding: 0 14px;
  box-sizing: border-box;
  box-shadow: 0 2px 7px var(--shadow);
  margin-bottom: 0;
  margin-right: 14px;
  transition: border 0.25s, box-shadow 0.25s;
  outline: none;
  appearance: none;
  vertical-align: middle;
}
select#universityFilter,
select#yearFilter {
  background: #fff var(--select-arrow) no-repeat right 12px center/20px 20px;
  padding: 0 40px 0 14px; /* more space for the arrow at right */
}
select#yearFilter {
  margin-right: 0;
}
input[type='text']#searchInput {
  margin-right: 14px;
}

select#universityFilter:focus,
select#yearFilter:focus,
input[type='text']#searchInput:focus {
  border-color: #13bab7;
  background-color: #f0f4ff;
  box-shadow: 0 0 0 2px #13bab75a;
}

body.dark-mode select#universityFilter,
body.dark-mode select#yearFilter {
  background: #23263b var(--select-arrow-dark) no-repeat right 12px center/20px
    20px;
  color: #f0f0f0;
  border: 2px solid #90caf9;
}
body.dark-mode input[type='text']#searchInput {
  background: #23263b;
  color: #f0f0f0;
  border: 2px solid #90caf9;
}
body.dark-mode select#universityFilter:focus,
body.dark-mode select#yearFilter:focus,
body.dark-mode input[type='text']#searchInput:focus {
  border-color: #13bab7;
  background-color: #181d30;
  box-shadow: 0 0 0 2px #13bab75a;
}

/* Remove default arrow in most browsers */
select::-ms-expand {
  display: none;
}
select:disabled {
  background-color: #eee;
  color: #aaa;
}

/* === Material Field Styles for Inputs and Selects === */
.material-setup {
  padding: 18px 0 18px 0;
  max-width: 420px;
  margin: 0 auto 28px auto;
}
.material-field {
  position: relative;
  margin-bottom: 28px;
  min-width: 220px;
}
.material-field input[type='text'],
.material-field select {
  font-family: inherit;
  font-size: 16px;
  width: 100%;
  padding: 18px 12px 7px 12px;
  border: none;
  border-bottom: 2.5px solid #bbb;
  background: none;
  color: var(--text);
  outline: none;
  border-radius: 0;
  transition: border-color 0.28s;
  background-color: transparent;
  appearance: none;
  box-shadow: none;
}
.material-field input[type='text']:focus,
.material-field select:focus {
  border-bottom: 2.5px solid var(--primary);
}
.material-field label {
  position: absolute;
  left: 12px;
  top: 19px;
  color: #666;
  font-size: 1rem;
  pointer-events: none;
  transition: all 0.17s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
}
.material-field input[type='text']:focus + label,
.material-field input[type='text']:not(:placeholder-shown) + label,
.material-field input[type='text']:valid + label,
.material-field select:focus + label,
.material-field select:valid + label {
  top: -8px;
  left: 6px;
  font-size: 0.88rem;
  color: var(--primary);
  background: var(--bg-content);
  padding: 0 3px;
  font-weight: 600;
  border-radius: 3px;
}
.material-field select {
  /* Show custom arrow from theme if desired */
  background: transparent var(--select-arrow) no-repeat right 8px center/20px
    20px;
  padding-right: 32px;
}
.material-bar {
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2.5px;
  width: 0;
  background: var(--primary);
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
}
.material-field input[type='text']:focus ~ .material-bar,
.material-field select:focus ~ .material-bar {
  width: 100%;
}
.material-field input[type='text']:invalid,
.material-field select:invalid {
  color: #888;
}
.material-field select option[disabled][selected] {
  display: none;
}

body.dark-mode .material-field input[type='text'],
body.dark-mode .material-field select {
  color: #f0f0f0;
  border-bottom-color: #8fa6ff;
  background-color: transparent;
}
body.dark-mode .material-field input[type='text']:focus,
body.dark-mode .material-field select:focus {
  border-bottom-color: var(--primary);
}
body.dark-mode .material-field label {
  color: #aaa;
  background: transparent;
}
body.dark-mode .material-bar {
  background: var(--primary);
}
body.dark-mode .material-field input[type='text']:focus + label,
body.dark-mode
  .material-field
  input[type='text']:not(:placeholder-shown)
  + label,
body.dark-mode .material-field select:focus + label,
body.dark-mode .material-field select:valid + label {
  color: #90caf9;
  background: var(--bg-content);
}

.material-field input[type='text']:invalid ~ .material-bar,
.material-field select:invalid ~ .material-bar {
  background: #c62828;
}

/* === Section === */
.about-section {
  background-color: var(--bg-content);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 6px var(--shadow);
  margin-top: 30px;
}
.about-section h2,
.about-section h3 {
  color: var(--primary);
  margin-top: 0;
}
.about-section p {
  line-height: 1.6;
  font-size: 15px;
  color: var(--text);
  text-align: justify;
}

/* === Navigation Container === */
.nav {
  text-align: center;
  background: transparent;
  padding: 16px 15px;
  border-radius: 15px;
  margin-bottom: 25px;
  margin-top: -5px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px var(--shadow);
}
/* === Navigation Buttons === */
.nav a {
  display: inline-block;
  margin: 8px 12px;
  text-decoration: none;
  background: linear-gradient(135deg, #13bab7, #02967d);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  transition: background 0.4s ease;
}
.nav a::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: scale(0);
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.nav a:active::after {
  transform: scale(2);
  opacity: 0;
}
.nav a:hover {
  background: linear-gradient(135deg, #00c9a7, #3ddad7);
}
.nav a::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Ripple Button animation & Download PDF (Material) */
.qp-card a.ripple-btn,
.ripple-btn {
  display: inline-block;
  min-width: 140px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #1976d2, #13bab7 85%);
  color: #fff !important;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  margin-top: 12px;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.qp-card a.ripple-btn:hover,
.ripple-btn:hover {
  background: linear-gradient(90deg, #13bab7 40%, #1976d2 90%);
  color: #fff;
  box-shadow: 0 4px 14px #13bab77a;
}
.qp-card a.ripple-btn:focus,
.ripple-btn:focus {
  outline: 2px solid #fbc02d;
}
/* "Download PDF" icon enhancement (accessibility) */
.qp-card a.ripple-btn::before {
  content: '⬇️ ';
  font-size: 17px;
  margin-right: 2px;
  vertical-align: middle;
}
.qp-card a.ripple-btn:active {
  background: linear-gradient(90deg, #1976d2 60%, #13bab7 100%);
  color: #fff;
}
body.dark-mode .qp-card a.ripple-btn,
body.dark-mode .ripple-btn {
  background: linear-gradient(90deg, #90caf9, #13bab7 85%);
  color: #111 !important;
  box-shadow: 0 2px 9px rgba(40, 40, 40, 0.13);
}
body.dark-mode .qp-card a.ripple-btn:hover,
body.dark-mode .ripple-btn:hover {
  background: linear-gradient(90deg, #13bab7 40%, #90caf9 100%);
  color: #222;
}
body.dark-mode .qp-card a.ripple-btn:focus,
body.dark-mode .ripple-btn:focus {
  outline: 2px solid #ffd54f;
}
.ripple-btn::after,
.qp-card a.ripple-btn::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: scale(0);
  pointer-events: none;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.ripple-btn:active::after,
.qp-card a.ripple-btn:active::after {
  transform: scale(2);
  opacity: 0;
}

/* === Card Grid Styles === */
.qp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.qp-card {
  background: var(--card-bg, #fff);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: 0.3s;
}
.qp-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
.qp-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}
.qp-card a {
  display: inline-block;
  margin-top: 8px;
  color: #1976d2;
  font-weight: bold;
}

/* === Material-style Search Input: width and margin only ==== */
input[type='text']#searchInput {
  width: 100%;
  margin-bottom: 15px;
}

/* === Alphabets === */
.alphabet-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
  justify-content: center;
}
.alphabet-button {
  background: white;
  border: none;
  padding: 10px 16px;
  font-size: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}
.alphabet-button:hover {
  background-color: #f0f0f0;
  transform: translateY(-1px);
}
.alphabet-button.active-letter {
  background-color: #1976d2;
  color: white;
  box-shadow: 0 3px 8px rgba(25, 118, 210, 0.3);
}
.alphabet-button:focus {
  outline: none;
}
.alphabet-group summary {
  font-weight: bold;
  font-size: 1.2rem;
  background: var(--primary-light);
  color: var(--text-dark);
  padding: 12px;
  margin: 10px 0;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.alphabet-group summary::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s linear;
}
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* === Notifications === */
.notifications {
  background-color: white;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px var(--shadow);
  border-left: 4px solid var(--highlight);
}
.notifications::before {
  content: '📢 Notifications';
  font-weight: bold;
  margin-bottom: 8px;
  display: block;
  color: var(--primary);
}
.notifications ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.notifications li {
  font-size: 14px;
  margin: 6px 0;
}
.notifications a {
  color: var(--primary);
  text-decoration: none;
}
.notifications a:hover {
  text-decoration: underline;
}

/* === Leaderboard === */
.leaderboard {
  background-color: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}
.leaderboard::before {
  content: '📊 Weekly Leaderboard';
  font-weight: bold;
  margin-bottom: 8px;
  display: block;
  color: var(--primary);
}
.leaderboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.leaderboard th,
.leaderboard td {
  border: 1px solid #ccc;
  padding: 6px 10px;
  text-align: center;
}
.leaderboard th {
  background-color: var(--primary-light);
  color: white;
}
.leaderboard tbody tr:nth-child(1) {
  background-color: #ffeaa7;
  font-weight: bold;
}
.leaderboard tbody tr:nth-child(2) {
  background-color: #fab1a0;
  font-weight: bold;
}
.leaderboard tbody tr:nth-child(3) {
  background-color: #a29bfe;
  font-weight: bold;
}

/* === Chatbot (if any) === */
.chatbot {
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #ccc;
}

/* === Footer === */
footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: var(--dark);
  color: white;
  text-align: center;
  padding: 8px 0;
  font-size: 15px;
  z-index: 1000;
}
footer a {
  color: #ffcc00;
  text-decoration: none;
  margin: 0 15px;
}
footer a:hover {
  text-decoration: underline;
}

/* === Footer Bar === */
.footer-bar.hide {
  transform: translateY(100px); /* slide down out of view */
  opacity: 0;
}
.footer-bar {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  justify-content: center;
  display: flex;
  gap: 12px;
  z-index: 9999;
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.footer-bar a {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 30px;
  color: white;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 8px var(--shadow);
  font-size: 14px;
}
.youtube-bar {
  background-color: #ff0000;
}
.contact-bar {
  background-color: #4caf50;
}
.youtube-bar:hover {
  background-color: #d50000;
}
.contact-bar:hover {
  background-color: #388e3c;
}
.yt-logo,
.contact-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .container {
    display: flex;
    flex-direction: column;
  }
  .ads,
  .sidebar,
  .content {
    width: 100%;
    order: 1;
  }
  .sidebar {
    order: 2;
  }
  .ads {
    order: 3;
    padding: 10px 15px;
  }
  .content {
    margin: 10px 0;
  }
  .chatbot {
    height: 200px;
  }
  .notifications {
    height: auto;
  }
  .nav a {
    margin: 6px 8px;
  }
  .youtube-bar .yt-logo {
    width: 24px;
    height: 24px;
  }
  .youtube-bar span {
    font-size: 16px;
  }
  input[type='text']#searchInput,
  select#universityFilter,
  select#yearFilter {
    font-size: 14px;
    height: 38px !important;
    line-height: 38px !important;
    min-width: 100px;
    padding: 0 10px;
    margin-right: 8px;
  }
  select#universityFilter,
  select#yearFilter {
    padding: 0 28px 0 10px;
    background-position: right 7px center;
    background-size: 18px 18px;
  }
  select#yearFilter {
    margin-right: 0;
  }
}

.toast {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 30px;
  padding: 12px 24px;
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 100px;
  font-size: 16px;
  transition: opacity 0.5s, visibility 0.5s;
  opacity: 0;
}

.toast.show {
  visibility: visible;
  opacity: 1;
}

/* === Definition cards === */
.definition-card {
  background-color: white;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px var(--shadow);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.definition-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-4px);
}
.definition-card details {
  transition: all 0.4s ease-in-out;
}
.definition-card summary {
  font-weight: bold;
  cursor: pointer;
  outline: none;
  margin-bottom: 8px;
}
.definition-card p {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.6;
  text-align: justify;
}
.definition-card button {
  margin-top: 10px;
  padding: 6px 12px;
  border: none;
  background: linear-gradient(to right, #13bab7, #02967d);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: background 0.3s ease;
}
.definition-card button::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: scale(0);
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.definition-card button:active::after {
  transform: scale(2);
  opacity: 0;
}

/*== Privacy Policy and Terms ===*/
.privacy-content {
  display: flex;
  flex-direction: column; /* stack items top to bottom */
  gap: 1.5rem; /* space between sections */
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}
.terms-content {
  display: flex;
  flex-direction: column; /* stack items top to bottom */
  gap: 1.5rem; /* space between sections */
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

/* === Dark Mode === */
body.dark-mode {
  --primary: #90caf9;
  --primary-light: #bbdefb;
  --highlight: #ffd54f;
  --dark: #181d30;
  --text: #f0f0f0;
  --bg-main: #121212;
  --bg-content: #1e1e1e;
  --white: #333;
  --shadow: rgba(255, 255, 255, 0.08);
  background-color: var(--bg-main);
  color: var(--text);
}
body.dark-mode .content,
body.dark-mode .about-section,
body.dark-mode .notifications,
body.dark-mode .leaderboard,
body.dark-mode .ad {
  background-color: var(--bg-content);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
}
body.dark-mode footer {
  background: #222;
  color: #eee;
}
body.dark-mode .nav a {
  color: white;
}
body.dark-mode .nav a:hover {
  background: linear-gradient(135deg, #66bb6a, #43a047);
}
.mode-toggle {
  margin-left: 12px;
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 6px var(--shadow);
  transition: background 0.3s ease;
}
.mode-toggle:hover {
  background: var(--primary-light);
}
