* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Poppins', sans-serif;
  background: #111;
  color: #f1f1f1;
  text-align: center;
}
header {
  background: linear-gradient(to bottom, rgba(34, 34, 34, 0.95), rgba(17, 17, 17, 0.8));
  backdrop-filter: blur(10px); /* Glass effect */
  padding: 15px 20px;
  z-index: 500;
  position: sticky; /* Keep it at the top while scrolling */
  top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(45deg, #ff4757, #ff6b81);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; /* Gradient text for the logo */
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* ──────────────── Header and Search ──────────────── */
.header-tools {
    padding: 5px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    /*flex-wrap: wrap;*/
    position: relative;
}

input[type="text"] {
  flex: 1; /* Makes search bar take available space */
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  transition: all 0.3s ease;
  outline: none;
}

input[type="text"]:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ff4757;
  box-shadow: 0 0 15px rgba(255, 71, 87, 0.2);
}

button {
  padding: 12px 20px;
  background: #ff4757;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-weight: bold;
  transition: 0.5s;
}
button:hover { background: #e84118; }

/* ──────────────── Proportional Search Button ──────────────── */
#searchBtn {
  padding: 14px 28px; /* Increased padding to match the input's height */
  font-size: 1rem;
  border-radius: 12px;
  height: 100%; /* Ensures it fills the same vertical space */
  display: flex;
  align-items: center;
}

/* ──────────────── Theme Toggle Button ──────────────── */
.theme-button {
  position: absolute;
  right: -300px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-button:hover {
  background: rgba(255, 255, 255, 0.2); /* Lightens the button */
  transform: scale(1.1);               /* Makes it pop slightly */
  border-color: #ff4757;               /* Adds a thin red ring */
}

/* Increase the Sun/Moon Icon Size */
#themeIcon {
  font-size: 24px; /* Scaled up from standard size */
  line-height: 1;
}

/* ──────────────── NEW: Layout for Sidebar and Main Content ──────────────── */
#mainContentWrapper {
  display: flex;
  max-width: 1400px;
  margin: 20px auto; 
  gap: 20px;
  padding: 0 20px;
  text-align: left;
}

#sidebar {
  flex: 0 0 220px; /* Fixed width for the sidebar */
  background: #222; 
  padding: 20px;
  border-radius: 12px;
  height: fit-content;
  position: sticky;
  top: 20px;
  z-index: 50;
}

/* ──────────────── NEW: Filter Styling ──────────────── */
#sidebar h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

/* FIX: Completely hide the default input so it doesn't overlap. 
   We use the #sidebar ID here to override the previous styles. */
#sidebar input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    cursor: pointer;
}

/* FIX: Reset the label layout. 
   We remove 'display: flex' so your custom .checkbox block style works. */
#sidebar label {
    display: block;
    position: relative;
    cursor: pointer;
    margin-bottom: 10px;
    border-radius: 6px;
    user-select: none;
}

/* Keep the hover effect for the row */
#sidebar label:hover {
  background: rgba(255, 255, 255, 0.05);
}

#movieContent {
  flex: 1; /* Takes up the remaining space */
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h3 {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #bbb;
}

.checkbox{
  position: relative;
  font-size: 1.1 em;
  line-height: 30px;
  color: ghostwhite;
  display: block;
  padding-left: 40px;
  margin-bottom: 10px;
  cursor: pointer;
  z-index: 20;
  user-select: none;
}

.checkbox input{
  position: absolute;
  height: 0;
  width: 0;
  cursor: pointer;
}

.check{
  position: absolute;
  height: 30px;
  width: 30px;
  border: 2px solid #e7e7e7;
  border-radius: 50%;
  top:0;
  left:0;
  transition: .2s ease-in-out;
}

.checkbox:hover input ~ .check{
  border-color: transparent;
  background-color: #ff4757;
}

.checkbox input:checked ~ .check{
  background-color: #ff4757;
  border-color: transparent;
}

/*Initial State*/
.check::after{
  content: "";
  position: absolute;
  width: 5px;
  height: 12px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  left: 9px;
  top: 4px;
  transform: rotate(45deg) scale(0); /* Hidden */
  transition: transform 0.2s ease-in-out;
}

/*Checked State*/
.checkbox input:checked ~ .check::after {
  transform: rotate(45deg) scale(1); /* Reveal (scale up to 1) */
}

.checkbox input:focus ~ .check{
  box-shadow: 0 0 0 4px rgb(255 131 107 / .3);
}

#categoryFilters label, #starFilters label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 1.1em;
}

/* Style the new Apply Filters button */
#applyFiltersBtn {
    width: 100%;
    margin-top: 10px;
}


/* ──────────────── Movie Grid ──────────────── */
#movieContainer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  padding: 0; /* Remove padding here */
}

.year-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 71, 87, 0.95);
  color: white;
  font-size: 13px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 6px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.movie {
  position: relative;  
  background: #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.3s;
  cursor: pointer;
}

.movie:hover { transform: scale(1.05); }
.movie img {
  width: 100%;
  height: 270px;
  object-fit: cover;
}
.movie h3 { padding: 10px; font-size: 15px; }
.stars { color: #ffb347; font-size: 18px; padding-bottom: 10px; }


/* ──────────────── Pagination ──────────────── */
.pagination {
  margin: 40px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pagination button {
  background: #333;
  min-width: 44px;
  height: 44px;
}
.pagination button.active { background: #ff4757; }

/* ──────────────── Page Number Buttons ──────────────── */
#pageNumbersList {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  background: #333;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
}

.page-btn:hover {
  background: #555;
}

.page-btn.active {
  background: #ff4757;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.5);
}

.page-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
}

#prevBtn,
#nextBtn {
  background: #ff4757;         /* Always red! */
  color: white;
  min-width: 100px;            /* Make them wider and nicer */
  padding: 0 20px;
  font-weight: bold;
  border-radius: 8px;
  transition: all 0.3s ease;
}
#prevBtn:hover,
#nextBtn:hover {
  background: #e84118;         /* Darker red on hover */
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
}
#prevBtn:disabled,
#nextBtn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
/* Light mode */
body.light-mode .page-btn {
  background: #ddd;
  color: #222;
}

body.light-mode .page-btn:hover {
  background: #bbb;
}

body.light-mode .page-btn.active {
  background: #ff4757;
  color: white;
}

/* ──────────────── Modal ──────────────── */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.9);
  overflow-y: auto;
}
.modal-content {
  background: #1e1e1e;
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 700px;
  border-radius: 12px;
  text-align: left;
  position: relative;
  line-height: 1.6;
}
.modal-content h2 {
  margin: 20px 0 15px 0; /* Space above and below title */
  font-size: 1.8em;
}

.modal-content p {
  margin-bottom: 16px; /* Space between each info line */
  font-size: 1.05em;
}

.modal-content p strong {
  color: #ff4757; /* Make labels (Genre:, Director:) pop */
}

/* Special spacing for plot */
.modal-content p:nth-child(7) { /* This targets the Plot line */
  margin-top: 20px;
  margin-bottom: 20px;
  font-style: italic;
  color: #ddd;
}

/* Rating line */
.rating {
  font-size: 1.2em;
  margin: 25px 0;
  padding: 15px;
  background: rgba(255, 71, 87, 0.1);
  border-radius: 10px;
}

/* Trailer section */
.modal-content h3 {
  margin: 35px 0 15px 0; /* More space before Trailer */
  font-size: 1.6em;
  color: #ff4757;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
}

/* Make iframe responsive and spaced */
.modal-content iframe {
  width: 100%;
  height: 400px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  margin: 20px 0;
}
.close { 
  position: absolute; top: 10px; right: 20px; 
  font-size: 40px; cursor: pointer; color: #aaa;
}
.close:hover { color: white; }
.modal-content img { width: 100%; border-radius: 10px; margin-bottom: 15px; }

/* ──────────────── Modal Trailer Styles ──────────────── */
.modal-content h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  font-size: 1.2em;
  color: #f1f1f1; /* Light text for dark mode */
}

.modal-content iframe {
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Light Mode Adjustments */
body.light-mode .modal-content h3 {
  color: #222; /* Dark text for light mode */
}

body.light-mode .modal-content iframe {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ──────────────── Light Mode Styles ──────────────── */
body.light-mode {
  background: #f8f9fa;
  color: #222;
}

body.light-mode header { 
  /* We use a slightly darker, semi-transparent white/gray for the glass base */
  background: rgba(224, 224, 224, 0.75); 
  
  /* Adding a subtle shadow helps define the 'floating' glass layer */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  
  /* Ensures the border is visible but soft */
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  
  /* Re-stating the blur for clarity, though it carries over from the main header rule */
  backdrop-filter: blur(12px); 
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

body.light-mode .movie { background: white; color: #222; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
body.light-mode .modal-content { background: white; color: #222; }
body.light-mode input { background: #f1f1f1; color: #222; }
body.light-mode button { background: #ff4757; }

body.light-mode .theme-button { background: #f1c40f; color: #111; }

body.light-mode #sidebar {
    background: #e0e0e0;
    color: #222;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

/* Fix for the "Filters" heading */
body.light-mode #sidebar h2 {
    color: #111;
    border-bottom-color: #ccc;
}

/* Fix for "Categories" and "Min. Rating" subheaders */
body.light-mode .filter-group h3 {
    color: #444; /* Darker gray for sub-titles */
    border-bottom: 1px solid #bbb;
}

/* ──────────────── Light Mode Checkbox Fix ──────────────── */

/* 1. Make the circle border dark so it's visible */
body.light-mode .check {
    border: 2px solid #999; /* Dark gray border */
    background-color: #fff;  /* White inside */
}

/* 2. Update the genre/category text color for better contrast */
body.light-mode .checkbox {
    color: #333; /* Deep gray text */
}

/* 3. Keep the red background when checked, but ensure it looks sharp */
body.light-mode .checkbox input:checked ~ .check {
    background-color: #ff4757;
    border-color: #ff4757;
}

/* 4. Ensure the hover effect remains subtle but visible */
body.light-mode #sidebar label:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.light-mode .pagination button { background: #ddd; color: #222; }
body.light-mode .pagination button.active { background: #ff4757; color: white; }
body.light-mode .year-badge { background: rgba(255, 71, 87, 0.9); }

/* ──────────────── Light Mode Rating Fix ──────────────── */

/* 1. Give the rating badge a dark background so stars pop */
body.light-mode .rating {
    background: #222;       /* Dark background */
    color: #fffa65;         /* Bright yellow for the stars/text */
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;  /* Keeps it as a neat badge */
    margin-top: 10px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* 2. Ensure the "Rating:" label inside is still readable if needed */
body.light-mode .rating b {
    color: #fff;            /* White text for the word "Rating:" */
    margin-right: 5px;
}

/* ──────────────── Mobile Responsiveness ──────────────── */
@media (max-width: 800px) {
  /* --- 1. Header & Layout Cleanup --- */
  header {
    padding: 10px 15px;
    position: sticky;
    top: 0;
  }

  /* Stack items vertically */
  .header-tools {
    display: flex; 
    align-items: center;
    justify-content: space-between; 
    gap: 8px;
    width: 100%;
    padding: 0 5px;
    position: relative;
    right: auto;
  }

  /* Row 1: Logo & Theme Toggle */
  /* We assume the H1 (Logo) is outside .header-tools. 
     If it is inside, this flex-wrap handles it. 
     If H1 is above .header-tools in HTML, we adjust via general layout */
  
  /* Make search bar take full width of its own row */
  input[type="text"] {
    flex: 1;
    min-width: 0;     /* CRITICAL: Allows flex items to shrink below their content size */
    padding: 10px 12px;
    font-size: 0.9rem;
    height: 45px;
  }

  /* Search Button next to Input */
  #searchBtn {
    flex-shrink: 0; /* Prevents the button from being squished */
    padding: 0 15px; /* Narrower padding */
    height: 45px;
    font-size: 0.9rem;
    white-space: nowrap; /* Keeps the word "Search" on one line */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Theme Button - Positioned top right absolutely or via flex */
  .theme-button {
    position: static; /* Removes absolute positioning */
    flex-shrink: 0;  /* Prevents the circle from becoming an oval */
    width: 45px;     /* Match height of other elements */
    height: 45px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #themeIcon { font-size: 20px; }

  /* --- 2. Main Layout --- */
  #mainContentWrapper {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
  }

  /* --- 3. The Sidebar (Hidden by default on mobile) --- */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111; /* Dark background */
    z-index: 2000; /* On top of everything */
    padding: 20px;
    overflow-y: auto; /* Scrollable */
    
    /* Animation for sliding in */
    transform: translateY(100%); 
    transition: transform 0.3s ease-in-out;
    display: block; /* It exists, just hidden via transform */
  }

  /* Class to show the sidebar */
  #sidebar.active {
    transform: translateY(0); /* Slide up */
  }

  /* Light mode support for the sidebar popup */
  body.light-mode #sidebar {
    background: #f8f9fa;
  }

  /* Center the headings inside the popup */
  #sidebar h2 {
    margin-top: 40px; /* Space for close button */
    font-size: 2rem;
  }

  /* Adjust Filter Groups for vertical scrolling */
  #categoryFilters, #starFilters {
    display: block; /* Stack vertically in the popup */
    text-align: left;
    margin-bottom: 20px;
  }

  .checkbox {
    margin-bottom: 15px;
    padding-left: 45px; /* More space for finger tap */
  }

  /* ──────────────── Mobile Pagination Fix ──────────────── */

/* 1. Container Layout: Center and spacing */
.pagination {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: center;
  gap: 15px;       /* Space between buttons and the text */
  margin: 30px;
  height: 50px;
}

#pageNumbers > *{  /* Hide all numbers by default in the list*/
  display: none !important;
}

/* 2. ...EXCEPT the one with the 'active' class */
  #pageNumbers button.active {
    display: block !important;
    background: transparent !important;
    border: none !important;
    color: #ff4757 !important;
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none; /* Make it look like a label, not a button */
    padding: 0;
    width: auto;
    position: relative;
    top: 3px;
  }

  /* 4. Style Prev/Next buttons as circles */
  #prevBtn, #nextBtn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    padding: 0;
    font-size: 0 !important; /* Hide text "Previous" */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #222;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  }

/* Add Icons using FontAwesome pseudo-elements */
#prevBtn::after {
  content: '\f060'; /* FA Arrow Left Icon */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  position: relative;
  top: 1px;
}

#nextBtn::after {
  content: '\f061'; /* FA Arrow Right Icon */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  position: relative;
  top: 1px;
}

/* Hover effects for mobile buttons */
#prevBtn:active, #nextBtn:active {
  background-color: #ff4757;
  transform: scale(0.9); /* Click press effect */
}

  /* --- 4. The New "Filter" Button & Close Button --- */
  
  /* The button that opens the menu */
  #mobileFilterBtn {
    display: flex; /* Visible on mobile */
    align-items: center;
    justify-content: center;
    width: 100%;
    background: #ff4757;
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  }
  
  /* Icon inside the button */
  #mobileFilterBtn i {
    margin-right: 10px; 
  }

  /* Light mode style for the button */
  body.light-mode #mobileFilterBtn {
    background: #ff4757;
    color: #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  }

  /* The Close 'X' inside the sidebar */
#closeFilterBtn {
    /* Position it in the top-right corner of the sidebar */
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 3001; /* Ensure it sits on top of everything */

    /* Size & Shape */
    width: 45px;
    height: 45px;
    border-radius: 50%; /* Circle */

    /* Colors */
    background-color: rgba(20, 20, 20, 0.9); /* Dark background to block content behind it */
    border: 2px solid #ff4757; /* Red Border */
    color: #ff4757; /* The Red "X" */

    /* Centering the X */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Font styling for the X */
    font-size: 32px; 
    font-weight: 300;
    line-height: 1;
    
    cursor: pointer;
    transition: all 0.3s ease;
}

/* 2. Hover Effect */
#closeFilterBtn:hover, #closeFilterBtn:active {
    background-color: #ff4757; /* Red on hover */
    color: white;
    transform: rotate(90deg); /* Small spin animation */
}

/* 3. Light Mode Adjustments */
body.light-mode #closeFilterBtn {
    color: #333; /* Dark Icon */
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

  /* --- 5. Grid Adjustments --- */
  #movieContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* 2 columns like Flipkart/Apps */
    gap: 15px;
    padding: 10px;
  }
  
  .movie-card img {
    width: 100%;       /* Fill the card width */
    height: 240px;     /* Force a consistent height (adjust as needed) */
    object-fit: cover; /* CRITICAL: Crops the image so it doesn't distort/squash */
  }

  .movie h3 {
    font-size: 0.9rem; /* Smaller text */
    padding: 8px 5px;
  }
}

/* Hide the Mobile Filter/Close buttons on Desktop */
@media (min-width: 801px) {
  #mobileFilterBtn, #closeFilterBtn {
    display: none;
  }
}