/* ============================
   GLOBAL & LAYOUT STYLES
   ============================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    height: 100vh;
    background-color: #1a1a1a; /* Dark background - consistent across app */
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #e0e0e0; /* Light text - consistent across app */
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}

/* --------------------------------------
   Sidebar (New consistent design)
-------------------------------------- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100px;
    height: 100vh;
    background-color: #1C1C1C;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    z-index: 100; /* Ensure sidebar is always on top */
}

/* Add spacing ONLY to the first item */
.sidebar .item:first-child {
    margin-top: 10px;
}

.sidebar p,
.sidebar a {
    color: white;
    text-decoration: none;
    font-size: 0.8em; /* Smaller text for sidebar items */
}

.item {
    margin: 5px;
    padding: 10px;
    border-radius: 15px; /* smooth edges for all */
    transition: background 0.25s ease;
}

/* Shared active & hover background */
.item:hover,
.item.active,
.item-bottom:hover,
.item-bottom.active {
    background-color: #2A2A2A;
    border-radius: 15px;
    cursor: pointer;
}

/* Keep bottom item at the bottom */
.item-bottom {
    margin-top: auto;      /* THIS keeps it locked at bottom */
    padding: 10px;
    text-align: center;
}

.item img {
    width: 40px;
    height: 40px;
    display: block; /* Make image a block element */
    margin: 0 auto 5px auto; /* Center image with some margin below */
}

/* --------------------------------------
   Logo + Banner (if applicable)
-------------------------------------- */

/* The logo from moviepage.html was inline in the sidebar, let's add it to the sidebar styling */
.sidebar .logo {
    margin-bottom: 20px; /* Space below the logo */
    padding: 10px 0;
}
.sidebar .logo img {
    max-width: 80%; /* Fit within sidebar width */
    height: auto;
    display: block;
    margin: 0 auto; /* Center the logo image */
}


/* --------------------------------------
   Main Content Area (applies to index.html and moviepage.html)
-------------------------------------- */

.main {
    margin-left: 100px;        /* Push content to the right of the fixed 100px sidebar */
    min-height: 100vh;        /* full viewport height */
    padding: 24px;            /* inner spacing */
    background: linear-gradient(180deg, #0f0f0f 0%, #141414 100%);
    color: #fff;
    position: relative;       /* for any absolute children inside main */
    z-index: 10;
    overflow-x: hidden;       /* Prevent main content from causing horizontal scroll */
}

/* ============================
   CAROUSEL & SECTION STYLES (for index.html and moviepage.html's Watch More)
   ============================ */

/* Section layout */
.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.2px;
  color: #fff;
}

/* Carousel wrapper: hides overflow */
.carousel-wrapper {
  position: relative;
  overflow: hidden;
}

/* Carousel container */
.carousel {
  display: flex;
  gap: 15px;
  overflow-x: scroll;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* For smoother scrolling on iOS */
  padding: 10px 0;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  margin: 0 50px; /* Make space for side buttons */
}
/* Hide scrollbar for Webkit browsers (Chrome, Safari) */
.carousel::-webkit-scrollbar { display: none; }


/* ============================
   MOVIE CARDS (General for index.html, and base for account.html and moviepage.html carousel)
   ============================ */

.movie-card {
  flex: 0 0 auto; /* Ensure cards don't shrink in carousel */
  width: 180px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b0b0b, #121212);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
  position: relative;
  display: flex; /* Make it a flex container for card structure */
  flex-direction: column;
}

.movie-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 40px rgba(0,0,0,0.72);
  cursor: pointer;
}

.movie-card .poster {
  position: relative;
  width: 100%;
  height: 270px; /* Standard poster aspect ratio */
  background-size: cover;
  background-position: center;
  background-color: #555; /* Fallback background for poster area */
  flex-shrink: 0; /* Important for account.html where remove button is outside poster */
}

.movie-card .no-poster {
  background-image: none !important;
  background-color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eee;
  font-size: 1.2em;
  text-align: center;
  padding: 10px;
}

/* MEDIA BADGE (Adjusted to top-right for all cards) */
.media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(180deg, rgba(82,34,163,0.95), rgba(60,20,140,0.95));
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(65,25,140,0.35);
  text-transform: capitalize;
  z-index: 3; /* Ensure it's above other elements */
}

/* ============================
   WATCHLIST BUTTON STYLES
   ============================ */

/* 1. BUTTON INSIDE MOVIE CARDS (Home/Carousel) 
   We use .movie-card .watchlist-btn to make this specific enough 
   to override the generic .main rule below. */
.movie-card .watchlist-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
    background: rgba(128, 128, 128, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
    outline: none;
}

.movie-card .watchlist-btn:hover {
    transform: scale(1.12);
    background: rgba(128, 128, 128, 0.9);
    cursor: pointer;
}

/* 2. BUTTON ON MOVIE PAGE (The big button) 
   This applies to buttons in .main that are NOT inside a movie card. */
.main .watchlist-btn:not(.movie-card .watchlist-btn) {
    position: relative;
    bottom: auto;
    right: auto;
    width: auto;
    height: auto;
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: none;
    background: rgba(128, 128, 128, 0.6); /* Ensure background exists */
}

/* State when the item IS watchlisted (Applies to both) */
.watchlist-btn.added {
    background: rgba(220, 53, 69, 0.85) !important; /* Red when added */
    color: white;
}

.watchlist-btn.added:hover {
    background: rgba(255, 0, 0, 1) !important;
}

/* Card Bottom (Title Overlay) */
.card-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
  z-index: 1; /* Ensure it's below the watchlist button and media badge */
}

.card-title {
  color: #fff;
  font-weight: bold;
  font-size: 1em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  margin: 0;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

/* Loading / empty placeholders */
.loading, .empty {
  color: #aaa;
  padding: 24px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* ============================
   CAROUSEL ARROWS (SIDE BUTTONS)
   ============================ */

/* These styles are applied directly to .carousel-btn elements for consistency */
/* The carousel-wrapper .carousel-btn styles at the top are for the arrows that overlay the carousel content */


/* Hide top-right header controls (optional) */
.section-header .controls { display: none; }

/* Slight fade at edges to indicate overflow */
.carousel-wrapper::before,
.carousel-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 3;
}
.carousel-wrapper::before {
  left: 0;
  background: linear-gradient(90deg, rgba(11,11,11,1), rgba(11,11,11,0));
}
.carousel-wrapper::after {
  right: 0;
  background: linear-gradient(-90deg, rgba(11,11,11,1), rgba(11,11,11,0));
}

/* ============================
   RESPONSIVE ADJUSTMENTS
   ============================ */
@media (max-width: 900px) {
  .movie-card { width: 160px; }
  .movie-card .poster { height: 240px; }
  /* .carousel-btn for side arrows */
  .carousel-wrapper .carousel-btn { width: 40px; height: 100px; font-size: 26px; }
}

@media (max-width: 600px) {
  .movie-card { width: 140px; }
  .movie-card .poster { height: 200px; }
  .section-header h2 { font-size: 16px; }
  /* .carousel-btn for side arrows */
  .carousel-wrapper .carousel-btn { width: 36px; height: 80px; font-size: 22px; }
}


/* ======================================================================
   ACCOUNT.HTML SPECIFIC STYLES (now using .main content area, no .account-content-wrapper)
   ====================================================================== */

/* Instead of .account-content-wrapper, these apply to elements inside .main for account.html */
/* The .main already has margin-left: 100px; and padding: 24px; */
.main h1 { /* General h1 in main content */
    color: #fff;
    margin-bottom: 20px;
}
.main h2 { /* General h2 in main content */
    margin-bottom: 10px;
    color: #ffffff;
}
.info-box, .stats-box {
    background: #282828;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    justify-items: start;
}
.stat-item {
    background: #1f1f1f;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}
.stat-item h3 {
    margin: 6px 0;
    font-size: 22px;
    color: #007bff;
}
/* Watchlist grid uses same .movie-card styles, but overrides if needed */
.watchlist-grid {
    display: flex; /* Use Flexbox */
    flex-wrap: wrap; /* Allow wrapping onto multiple lines */
    gap: 20px; /* Spacing between cards */
    padding: 10px 0;
    justify-content: flex-start; /* Align cards to the start (left) */
}
.watchlist-grid .movie-card {
    display: flex;
    flex-direction: column;
    width: 180px;
}
.watchlist-grid .movie-card .poster {
    flex-shrink: 0;
}

/* NEW REMOVE BUTTON STYLES (for account.html) */
.remove-btn {
    display: block;
    width: calc(100% - 20px);
    margin: 10px;
    padding: 8px 12px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    text-align: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}
.remove-btn:hover {
    background-color: #c82333;
}


/* ======================================================================
   CUSTOM CONFIRM DIALOG STYLES
   ====================================================================== */
.custom-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensure it's on top of everything */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-confirm-overlay.show {
    opacity: 1;
    visibility: visible;
}

.custom-confirm-dialog {
    background-color: #282828;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.custom-confirm-overlay.show .custom-confirm-dialog {
    transform: translateY(0);
}

.custom-confirm-dialog p {
    margin-bottom: 25px;
    font-size: 1.1em;
    color: #e0e0e0;
}

.custom-confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.custom-confirm-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.custom-confirm-buttons .confirm-yes {
    background-color: #dc3545; /* Red for Yes */
    color: white;
}

.custom-confirm-buttons .confirm-yes:hover {
    background-color: #c82333;
}

.custom-confirm-buttons .confirm-no {
    background-color: #6c757d; /* Gray for No */
    color: white;
}

.custom-confirm-buttons .confirm-no:hover {
    background-color: #5a6268;
}

/* --------------------------------------
   MOVIEPAGE.HTML SPECIFIC STYLING
-------------------------------------- */
.movie-details {
    margin-top: 20px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.movie-details h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
    color: #fff;
}

.movie-details .rating {
    font-size: 1.1em;
    color: #ffc107; /* Gold/Yellow for rating */
    margin-bottom: 15px;
}
.movie-details .rating svg {
    vertical-align: middle;
    margin-right: 5px;
    color: #ffc107;
}

.movie-details p {
    font-size: 1em;
    color: #ccc;
    max-width: 800px;
}


.movie-player-section {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.movie-player-section button {
    background-color: #333;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.movie-player-section button:hover {
    background-color: #555;
}

.movie-player-section button.server-active {
    background-color: #007bff; /* Highlight active server */
    font-weight: bold;
}

        .carousel-btn {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background-color: rgba(0, 0, 0, 0.7); /* Dark semi-transparent background */
            color: white;
            border: none;
            padding: 10px 15px;
            font-size: 2rem;
            cursor: pointer;
            z-index: 10; /* Ensure it sits on top of images */
            border-radius: 5px;
            user-select: none;
            transition: background-color 0.3s;
            height: auto;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .carousel-btn:hover {
            background-color: rgba(255, 255, 255, 0.2); /* Lighten on hover */
        }

        .carousel-btn.prev {
            left: 10px; /* Position left */
        }

        .carousel-btn.next {
            right: 10px; /* Position right */
        }

.sidebar p {
font-size: 15px;
font-weight: bold;
}

    .search-container { text-align: center; padding: 20px; }
    .search-container input {
      width: 60%; max-width: 500px; padding: 12px 15px;
      font-size: 1rem; border-radius: 8px; border: 1px solid #ccc;
      outline: none;
    }
    .search-container input:focus { border-color: #007bff; }

/* styles.css */

/* --- New Loading Spinner Styles --- */

/* General carousel styling */
.carousel {
  padding: 20px 0; /* Original padding */
  scroll-behavior: smooth;
  min-height: 250px; /* Ensure space for the spinner, adjust as needed */
  /* Other base carousel styles like display: flex, flex-wrap: nowrap, etc. 
     should ideally be here if not overwritten by the loaded/loading states below. */
}

/* Styles when the carousel is loading */
.carousel[data-loaded="false"] {
  display: flex; /* Use flexbox to center the spinner */
  align-items: center;
  justify-content: center;
  overflow-x: hidden; /* Hide horizontal scrollbar when loading */
  white-space: normal; /* Allow text within spinner to wrap */
}

/* Styles when the carousel is loaded with content */
.carousel[data-loaded="true"] {
  display: flex; /* Still flex for cards layout */
  flex-wrap: nowrap; /* Keep cards in a single row */
  overflow-x: auto; /* Allow horizontal scrolling */
  white-space: nowrap; /* Prevent cards from wrapping to next line */
  align-items: flex-start; /* Align cards to the start, not centered */
  justify-content: flex-start; /* Start cards from the left */
}

/* Loading spinner specific styling */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%; /* Take full width of the parent (carousel) */
  height: 100%; /* Take full height of the parent (carousel) */
  color: #ccc; /* Lighter text color */
  font-size: 1.2em;
  gap: 15px; /* Space between icon and text */
  text-align: center;
}

.loading-spinner .lucide-loader-circle {
  width: 60px; /* Larger icon size */
  height: 60px;
  color: #FFD700; /* A vibrant gold color for your spinner! */
  stroke-width: 1.5; /* Make the spinner lines a bit thicker for visibility */
}

/* Keyframe animation for a more dynamic spinning effect */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite; /* A bouncy, dynamic spin! */
}

/* Optional: styling for "No items found" / "Error" messages */
.carousel .empty {
    color: #aaa;
    font-size: 1.1em;
    text-align: center;
    width: 100%;
    padding: 20px;
}

/* Ensure movie cards still behave correctly in the loaded carousel */
.carousel[data-loaded="true"] .movie-card {
  /* Your existing movie-card styles that make them display side-by-side */
  flex: 0 0 auto; /* Prevent cards from growing/shrinking */
  width: 200px; /* Example card width, adjust to your design */
  margin-right: 15px; /* Space between cards */
  /* ... other movie-card styles ... */
}
