/* --- :ROOT CSS VARIABLES --- */
/* All site colors and styles are controlled from here */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --text-dark: #111827;
  --text-normal: #1e293b;
  --text-light: #64748b;
  --bg-main: #f8fafc;        /* Main background (light gray) */
  --bg-content: #ffffff;      /* Content background (white) */
  --bg-card: #f1f5f9;         /* Card background (lightest gray) */
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  /* NEW: Optimized Footer Colors for high contrast */
  --footer-bg: var(--primary-dark);      /* Dark Navy Blue */
  --footer-text: #f3f4f6;                 /* Very light gray for body text */
  --footer-heading: #fff;                /* White for headers */
  --footer-bottom-bg: var(--text-dark);  /* Very dark gray/almost black */
}

/* --- Global & Typography --- */
* {
  box-sizing: border-box;
  text-decoration: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-normal);
  background-color: var(--bg-main);
  margin: 0;
  padding-top: 80px; /* Space for the sticky header */
  line-height: 1.6;
}

h1, h2, h3 {
  color: var(--text-dark);
  margin-top: 0;
  margin-bottom: 1rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

p {
  margin-top: 0;
  /* Keep default bottom margin for general paragraphs, 
     but specific forum elements override this below */
  margin-bottom: 1rem; 
}

/* --- Header & Navigation (STICKY) --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 2rem;
  width: 100%;
  height: 80px; /* Fixed height for sticky header */
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-color);
  
  /* Sticky Header */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  
  /* Glassmorphism Effect */
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

/* Logo styling */
.logo-link {
    display: flex;
    align-items: center;
    height: 100%; /* For vertical alignment inside the 80px header */
}

.site-logo {
  height: 60px; /* Set desired logo height */
  width: auto;
  display: block;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  font-weight: 500;
  color: var(--text-normal);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

nav a:hover {
  color: var(--primary-color);
}

/* --- Active Page Link Styling --- */
#page-home .nav-home,
#page-materials .nav-materials,
#page-quizzes .nav-quizzes,
#page-blogs .nav-blogs,
#page-events .nav-events,
#page-forum .nav-forum,
#page-careers .nav-careers,
#page-about .nav-about {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

/* --- Main Content Area --- */
main {
  max-width: 1140px; /* Wider layout */
  margin: 2rem auto;
  background: var(--bg-content);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

/* --- Button Styles --- */
.btn {
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-dark);
}
.btn-secondary:hover {
  background: #cbd5e1;
  transform: translateY(-2px);
}

/* --- Card Style (General) --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 1.25rem;  /* CORRECTED SMALLER PADDING */
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  overflow-wrap: break-word; /* CORRECTED TEXT WRAPPING */
}

/* NEW: Global Grid Layouts for large screens (>900px) and consistency */
#three-column-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columns for Vision/Mission/Values */
    gap: 1.5rem;
    margin-top: 2rem;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for Why Choose MetaVirta */
    gap: 1.5rem;
    margin-top: 2rem;
}
/* END NEW GRID LAYOUTS */


/* --- Form Elements --- */
input[type="text"],
textarea,
select {
  width: 100%;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
  font-family: inherit;
  font-size: 1rem;
  background-color: #fff;
  transition: all 0.2s ease;
}
textarea {
  /* Set min-height to allow automatic expansion based on content */
  min-height: 1.4rem; /* Height equivalent to roughly one line of text (1.4 * 1rem) */
  resize: vertical;
}
select {
  width: auto;
}
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* --- Quiz Page Styles --- */
#quiz-filters {
  background: var(--bg-content);
  padding-bottom: 1.5rem;
  border: none;
  box-shadow: none;
}
#quiz-list { /* Explicitly define 3 columns for consistency with large quiz list view */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
#quiz-list .quiz-card {
  margin-bottom: 0;
  height: 100%;
  transition: all 0.2s ease-in-out;
}
#quiz-list .quiz-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.quiz-card {
  border-left: 5px solid var(--primary-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.quiz-card.completed {
    border-left-color: #10b981; /* Green color for completed quiz */
    background-color: #ecfdf5; /* Light green background */
}
.topic-tag {
  display: inline-block;
  background: #dbeafe;
  color: var(--primary-dark);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  margin-bottom: 0.75rem; /* Reduced margin */
  align-self: flex-start;
}
.quiz-card .btn {
  width: 100%;
}
#quiz-container .btn-option {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text-normal);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}
#quiz-container .btn-option:hover {
  background: #eef2ff;
  border-color: var(--primary-color);
}
#quiz-container .btn-option:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
#quiz-feedback {
  font-weight: 600;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
}
.feedback-correct {
  background: #dcfce7;
  color: #166534;
}
.feedback-incorrect {
  background: #fee2e2;
  color: #991b1b;
}
#quiz-feedback .quiz-description-answer {
  background: var(--bg-content);
  border: 1px solid var(--border-color);
  padding: 1rem;
  margin-top: 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-normal);
}
#quiz-feedback .quiz-description-answer strong {
  color: var(--text-dark);
  display: block;
  margin-bottom: 0.5rem;
}
#quiz-final-score {
  font-size: 1.25rem;
  font-weight: 600;
}

/* --- Progress Bar Styles --- */
.progress-bar-container {
    height: 10px;
    background-color: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%;
    background-color: #10b981; /* Tailwind green-500 for progress */
    transition: width 0.5s ease-in-out;
}
#quiz-progress-card {
    background: var(--bg-content);
    border: 1px solid #10b981; /* Use green border for success vibe */
    padding: 1.25rem; 
}
#progress-text {
    font-weight: 600;
    color: var(--text-normal);
    margin-bottom: 0.5rem;
}


/* --- Materials Page Styles (ACCORDION/INTERACTIVE) --- */
.filters-bar {
  background: var(--bg-content);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border: none;
  box-shadow: none;
}
.filter-group { flex-grow: 1; }
.filter-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.filter-group input[type="text"],
.filter-group select {
  width: 100%;
  margin-bottom: 0;
}
@media (min-width: 768px) {
  .filter-group:first-child { flex-basis: 60%; }
  .filter-group:last-child { flex-basis: 35%; }
}

.material-subject-card h2 {
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

/* --- FORUM TAG STYLING (FIXED TO BLUE) --- */
.post-tag {
  /* Default blue color scheme for all tags */
  background-color: #e0e7ff; /* Light blue background */
  color: var(--primary-dark) !important; /* Dark blue text */
  cursor: pointer;
  transition: background-color 0.2s;
}

.post-tag:hover {
  background-color: #c7d2fe; /* Slightly darker blue on hover */
}

/* Highlight for the currently active filter tag */
.post-tag.active-filter-tag {
    background-color: var(--primary-color); /* Primary color background */
    color: #fff !important; /* White text for active filter */
    border: 1px solid var(--primary-dark);
}

/* --- FORUM POST & REPLY SIZING ADJUSTMENTS (OPTIMIZED) --- */
.post-card {
  /* Post card (question) should be as compact as possible */
  padding: 0.5rem 1rem !important; /* Tighter padding */
  background-color: var(--bg-content); 
}

.reply-card {
  /* Reply card should be slightly smaller/more compact than the main post */
  padding: 0.4rem 0.75rem !important; /* Tighter padding */
  background-color: var(--bg-card); 
}

.post-content-row {
    /* Ensures question text and like button are horizontally aligned */
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    gap: 1rem; 
    margin-bottom: 0; 
    padding-top: 0.1rem; 
}
.post-content {
    /* Ensures content takes up available space and text wraps */
    flex-grow: 1; 
    margin: 0 !important; /* CRUCIAL: Remove default paragraph margin */
    min-width: 0; 
    line-height: 1.4; 
    /* The P tag will naturally wrap and stretch its container height 
       because its margin is set to 0. */
}

.reply-content-row {
    /* Ensures reply text and like button are horizontally aligned */
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    gap: 1rem; 
}
.reply-content-row .post-content {
    margin: 0 !important; /* CRUCIAL: Remove default paragraph margin */
}

.post-actions {
    margin-top: 0.4rem; /* Reduced space above action buttons */
    padding-bottom: 0.2rem; /* Reduced space below post actions */
}

.post-meta {
    margin-top: 0.2rem; /* Reduced vertical spacing for meta info */
}
/* --- END FORUM STYLES --- */

/* --- PAGINATION STYLES (ADDED HIGHLIGHT FOR ACTIVE PAGE) --- */
#pagination-container {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  align-items: center; /* Align buttons and 'show all' button vertically */
}
.pagination-btn {
  background-color: var(--bg-card);
  color: var(--text-normal);
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-color);
}
.pagination-btn.active {
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 600;
  border-color: var(--primary-dark);
}
.pagination-btn:not(.active):hover {
  background-color: #cbd5e1;
}

/* --- ACCORDION STYLES --- */
.material-accordion-container {
    display: grid;
    grid-template-columns: 1fr; /* Full width sections */
    gap: 0.75rem; /* Vertical spacing between buttons/sections */
}
.accordion-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    background: var(--primary-color);
    color: #fff;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
}
.accordion-toggle h3 {
    color: #fff; /* Override h3 default color for button text */
    margin: 0;
    font-size: 1.15rem;
}
.accordion-toggle:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}
.toggle-icon {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: bold;
    transition: transform 0.2s;
}

.accordion-content {
    /* Base styles for the content pane */
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
    background: var(--bg-content);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 0 1.5rem; /* Padding needed when expanded, set to 0 initially */
    margin-bottom: 1rem;
}
.accordion-content.expanded {
    max-height: 10000px; /* Large value to allow height transition for all content */
    padding: 1.5rem;
    border-color: var(--primary-color); /* Highlight border when active */
}

/* --- RESOURCE LISTS (Study Materials & Written Notes) --- */
/* This forces the content list into a 3-column grid of equal-height links */
.accordion-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
  /* UPDATED: Use CSS Grid for 3-column horizontal layout on large screens */
  display: grid;
  grid-template-columns: repeat(3, 1fr); 
  gap: 1rem; /* Gap between list items */
  align-items: stretch; /* Added for consistency */
}

/* NEW: Apply Flexbox to LI for equal height in Study Materials/Notes */
.accordion-content li {
  margin-bottom: 0; 
  display: flex; /* Makes li a flex container */
}
.accordion-content li a {
  /* Make the anchor tag fill the entire height of the grid cell */
  height: 100%; 
  flex-grow: 1;
  /* Ensure the links themselves are styled like cards/boxes */
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem; /* Slightly more padding for the link box itself */
  color: var(--text-normal); /* Enforce dark font color */
}


/* --- NESTED VIDEO TOPIC GRID (Inside Video Resources Accordion) --- */
/* This creates the grid for sub-sections (Diffusion, Calculus, etc.) */
.material-topic-grid {
    /* Make the grid items stretch to the same height */
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 1rem;
    align-items: stretch; /* Crucial for equal height across all sub-sections */
}

/* --- Vertical Layout for Nested Video Links & Equal Height for Sub-Sections (FIXED) --- */
.material-sub-section {
    display: flex;
    flex-direction: column;
    height: 100%; /* Fill the height of the grid cell */
    padding: 0.75rem;
    background: var(--bg-card); 
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease-in-out;
}
.material-sub-section:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}
.material-sub-section h4 {
    font-size: 1rem;
    color: var(--primary-dark);
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Force the UL inside the sub-section (the list of videos) to be vertical */
.material-sub-section ul {
    /* Overrides the global .accordion-content ul grid setting */
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; /* Allow the list area to stretch within the card for equal height */
    padding: 0; 
    grid-template-columns: none; 
    gap: 0; 
    justify-content: flex-end; /* Pushes the list items to the bottom if needed */
}

/* Ensure the links inside the vertical list stack correctly and have consistent size */
.material-sub-section li {
    display: flex; 
    margin-bottom: 0.5rem; 
    flex-direction: row; 
    flex-grow: 1; 
}
.material-sub-section li:last-child {
    margin-bottom: 0;
}
/* Revert link styling for nested links inside video sub-sections */
.material-sub-section li a {
    /* Ensure links fill the width and revert height/flex properties */
    width: 100%; 
    height: auto; 
    flex-grow: 1; 
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-content); /* Slightly lighter background */
    border: 1px solid var(--border-color); /* Added border for definition */
    color: var(--text-normal); /* Enforce dark font color */
}
.material-sub-section li a:hover {
    background-color: #eef2ff;
}

/* No content found message padding correction */
.no-results-content {
    padding: 1rem 0;
    font-style: italic;
    color: var(--text-light);
}

/* Styling for individual link elements inside lists/sub-sections */
.accordion-content li a:hover {
  background-color: var(--bg-content);
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.01);
  box-shadow: var(--shadow-sm);
}

/* --- Footer --- */
footer {
  /* Dark footer style - now using primary dark blue */
  background-color: var(--footer-bg); 
  color: var(--footer-text); /* Light gray for main text */
  padding-top: 3rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.footer-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 2rem;
  
  /* Create a 3-column grid, but stack on mobile */
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* On tablets and desktops, use 3 columns */
@media (min-width: 768px) {
  .footer-container {
    grid-template-columns: 2fr 1fr 1fr; /* Brand column is twice as wide */
  }
}

.footer-brand h2 {
  color: var(--footer-heading); /* White */
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.footer-brand p {
  /* Inherits var(--footer-text) for consistency */
  line-height: 1.7;
  max-width: 35ch; /* Limit line length for readability */
}

.footer-links h4,
.footer-social h4 {
  color: var(--footer-heading); /* White */
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

/* NEW: Social Media Icon Styling */
.footer-social .social-links {
    display: flex; /* Arrange icons horizontally */
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-social .social-links li {
    margin-bottom: 0; /* Override default list item margin */
}
.footer-social .social-links li a {
    color: var(--footer-text); /* Icon color */
    font-size: 1.5rem; /* Icon size */
    transition: color 0.2s ease;
}
.footer-social .social-links li a:hover {
    color: var(--primary-color, #2563eb); /* Keep primary blue hover */
    padding-left: 0; /* Remove padding shift from general links */
}

/* Standard Footer Link Styling */
.footer-links a,
.footer-social a {
  color: var(--footer-text); /* Use light gray */
  text-decoration: none;
  transition: all 0.2s ease;
}

.footer-links a:hover {
  color: var(--primary-color, #2563eb); /* Keep primary blue hover */
  padding-left: 4px;
}

.footer-bottom-bar {
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 2rem;
  font-size: 0.875rem;
  background-color: var(--footer-bottom-bg); /* Very dark gray */
  color: var(--footer-text);
}

/* --- Responsive Media Query --- */
@media (max-width: 900px) {
  #quiz-list,
  #blog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* On medium screens (900px down to 768px), switch lists/topics to 2 columns */
  .material-topic-grid,
  .accordion-content ul {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 120px; /* More space for wrapped header */
  }
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    height: auto; /* Let header wrap */
  }
  nav {
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
  }
  nav a {
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-bottom: none;
  }
  
  main {
    margin: 1rem;
    padding: 1.5rem;
    width: auto;
    box-shadow: var(--shadow-sm);
  }
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }

  #quiz-list,
  .dashboard-grid,
  #blog-grid,
  #event-grid,
  #three-column-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  /* On small screens, force all grids and lists to stack in a single column */
  .material-topic-grid,
  .accordion-content ul {
    grid-template-columns: 1fr; 
  }
}
