/* ========================================= */
/* GRIDS & POSTER CARDS                      */
/* ========================================= */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 25px; }
.movies-grid, .shows-grid, .latest-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(var(--poster-size, 180px), 1fr)); 
    gap: 20px; align-items: start; 
}

.m-card { text-decoration: none; color: inherit; transition: opacity 0.4s, transform 0.4s; }
.m-poster { 
    position: relative; 
    background: #1a1a1a; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden; 
    border-radius: 15px; 
    border: 1px solid var(--glass-border); 
    aspect-ratio: 2 / 3; /* Forces every poster to be exactly the same size */
}
.m-poster img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1); }
.m-card:hover .m-poster img { transform: scale(1.08) !important; }

/* --- Hover Overlays --- */
.hover-overlay { 
    position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; 
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.1) 100%); 
    backdrop-filter: blur(4px); opacity: 0; display: flex; flex-direction: column; justify-content: flex-end; 
    padding: 20px; transition: opacity 0.4s ease; box-sizing: border-box; pointer-events: none; 
}
.m-card:hover .hover-overlay { opacity: 1; }
.hover-content { transform: translateY(20px); transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); }
.m-card:hover .hover-content { transform: translateY(0); }
.hover-meta { font-size: 0.75rem; color: var(--primary); font-weight: 800; margin-right: 12px; text-shadow: 0 2px 4px rgba(0,0,0,0.8); letter-spacing: 0.5px; }
.hover-synopsis { font-size: 0.8rem; color: #eee; margin: 10px 0 15px 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }

/* --- Refined Hover Overlay Elements --- */
.hover-content h4 {
    font-size: 0.85rem !important; /* Shrinks the title slightly */
    margin-bottom: 6px !important;
    line-height: 1.2 !important;
}

.hover-content .hover-meta {
    font-size: 0.65rem !important; /* Shrinks the episode/duration pill */
    padding: 3px 8px !important;
}

.hover-play-btn { 
    background: var(--primary); 
    color: #000; 
    text-align: center; 
    padding: 6px 12px !important; /* Tighter padding */
    border-radius: 6px !important; 
    font-weight: 800; 
    font-size: 0.65rem !important; /* Smaller button text */
    text-transform: uppercase; 
    letter-spacing: 0.5px !important; 
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3); 
    width: auto !important; /* Overrides the ugly 100% stretch */
    display: inline-block !important; /* Keeps the button neatly wrapped around the text */
    margin: 5px auto 0 auto !important;
}

/* --- Badges --- */
/* --- Badges --- */
.upcoming-badge { 
    position: absolute; 
    top: 8px; 
    left: 8px; 
    background: rgba(0, 210, 255, 0.9); 
    color: #000; 
    font-size: 0.55rem; 
    padding: 3px 6px; 
    border-radius: 6px; 
    font-weight: 900; 
    text-transform: uppercase; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.6); 
    z-index: 10; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    backdrop-filter: blur(5px); 
    transition: opacity 0.4s ease-in; 
    max-width: 48%; /* Prevents it from crossing the middle */
    white-space: nowrap;
}

.status-badge {
    position: absolute; 
    top: 8px; 
    right: 8px; 
    background: rgba(10, 14, 20, 0.95); 
    border: 1px solid; /* Color is set dynamically by PHP */
    font-size: 0.55rem; 
    font-family: 'Inter', sans-serif; 
    padding: 3px 6px; 
    border-radius: 6px; 
    font-weight: 800; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.8); 
    z-index: 10; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    backdrop-filter: blur(5px); 
    letter-spacing: 0.5px;
    max-width: 48%; /* Prevents it from crossing the middle */
    white-space: nowrap;
}

/* If the poster gets too small, cut off the text, but keep the icon visible */
.upcoming-badge span, .status-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
}.fr-badge { position: absolute; top: 10px; right: 10px; background: linear-gradient(135deg, #002395, #ed2939); color: #fff; font-size: 0.6rem; font-weight: 900; padding: 3px 6px; border-radius: 4px; z-index: 10; border: 1px solid rgba(255,255,255,0.5); box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.leaving-soon-badge { position: absolute; top: 10px; background: rgba(243, 156, 18, 0.95); color: #fff; height: 32px; width: auto; padding: 0 6px 0 14px; border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1rem; box-shadow: 0 4px 15px rgba(0,0,0,0.6); z-index: 20; border: 1px solid rgba(255,255,255,0.3); backdrop-filter: blur(4px); }
.days-left-sub { position: static; background: #e74c3c; color: #fff; font-size: 0.75rem; font-weight: 900; padding: 4px 8px; border-radius: 10px; line-height: 1; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.type-badge { position: absolute; top: 10px; right: 10px; background: var(--primary); color: #000; font-size: 0.6rem; padding: 2px 8px; border-radius: 4px; font-weight: 900; text-transform: uppercase; z-index: 5; }

/* ========================================= */
/* DETAILS PAGES: HERO SECTIONS & EPISODES   */
/* ========================================= */
.movie-hero-container, .series-hero-container { position: relative; border-radius: 30px; overflow: hidden; margin-top: 20px; background: #0b0e14; border: 1px solid var(--glass-border); padding: 40px; }
.hero-blur-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(60px) brightness(0.3); transform: scale(1.1); opacity: 0.6; z-index: 1; pointer-events: none; }
.movie-hero-content, .series-hero-content { position: relative; z-index: 2; display: flex; flex-direction: row !important; gap: 40px; width: 100%; align-items: flex-start !important; }
.hero-poster-wrapper { flex: 0 0 280px; }
.hero-poster { width: 100%; border-radius: 20px; border: 4px solid var(--glass-border); box-shadow: 0 20px 50px rgba(0,0,0,0.8); display: block; }
.hero-details { flex: 1 1 auto; display: block !important; width: 100%; min-width: 0; }
.hero-top-meta { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; gap: 10px; margin-bottom: 15px; align-items: center; width: 100%; }
.hero-badge { background: rgba(0, 210, 255, 0.1); backdrop-filter: blur(10px); padding: 6px 14px; border-radius: 30px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; border: 1px solid var(--primary); color: var(--primary); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.hero-title { font-size: 3.2rem; font-weight: 900; margin: 0 0 20px 0; letter-spacing: -1.5px; line-height: 1.1; color: #fff; word-break: break-word; display: block !important; }
.hero-actions { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; gap: 12px; margin-bottom: 25px; align-items: center; width: 100%; }
.hero-meta-grid { margin-bottom: 20px; display: block !important; width: 100%; }
.meta-item { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; margin-bottom: 8px; }
.meta-item label { color: var(--primary); font-weight: 900; text-transform: uppercase; font-size: 0.75rem; min-width: 80px; letter-spacing: 1px; }
.actor-link { color: #fff; text-decoration: none; transition: 0.3s; }
.actor-link:hover { color: var(--primary); text-shadow: 0 0 8px rgba(0, 210, 255, 0.4); }
.hero-synopsis { color: #ddd; line-height: 1.7; font-size: 1rem; max-width: 850px; margin: 0; text-shadow: 0 2px 4px rgba(0,0,0,0.8); display: block !important; }

/* Episode Rows */
.ep-row-modern { display: flex; justify-content: space-between; align-items: center; padding: 14px 25px; background: rgba(255,255,255,0.02); border-bottom: 1px solid rgba(255,255,255,0.05); transition: 0.3s; margin-bottom: 5px; border-radius: 12px; }
.ep-row-modern:hover { background: rgba(255,255,255,0.06); transform: translateX(5px); }
.ep-row-modern.is-watched { opacity: 0.4; filter: grayscale(50%); }
.ep-main-info { display: flex; align-items: center; gap: 20px; }
.ep-number { font-family: monospace; font-weight: 900; color: var(--text-dim); font-size: 1.1rem; width: 30px; text-align: center; }
.play-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); border: none; color: #000; cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; flex-shrink: 0;}
.play-btn:hover { transform: scale(1.15); box-shadow: 0 0 20px var(--primary); }
.ep-text { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ep-title { font-weight: 600; font-size: 1rem; color: #fff; }
.resume-badge { font-size: 0.65rem; background: var(--primary); color: #000; padding: 3px 8px; border-radius: 4px; font-weight: 800; text-transform: uppercase; }
.watched-check { background: none; border: 2px solid #555; color: transparent; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.watched-check.active { background: rgba(0,210,255,0.1); border-color: transparent; color: var(--primary); }
.watched-check:hover { border-color: var(--primary); color: var(--primary); }
.ep-actions { display: flex; align-items: center; gap: 20px; }
.ep-duration { font-size: 0.75rem; color: var(--text-dim); font-weight: 700; background: rgba(255,255,255,0.05); padding: 4px 10px; border-radius: 8px; border: 1px solid var(--glass-border);}
.ep-reset-icon { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.8rem; transition: 0.3s; padding: 0; }
.ep-reset-icon:hover { color: var(--primary); }

/* ========================================= */
/* CONTINUING WATCHING & STORY CIRCLES       */
/* ========================================= */
.cw-carousel, .scroll-shelf { padding-top: 15px !important; margin-top: -15px !important; display: flex; gap: 20px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--primary) var(--glass); }
@media (min-width: 768px) { .cw-carousel { display: flex !important; justify-content: center !important; } }
.cw-carousel::-webkit-scrollbar { height: 8px; }
.cw-carousel::-webkit-scrollbar-track { background: var(--glass); border-radius: 10px; }
.cw-carousel::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }
.cw-carousel::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.cw-card { flex: 0 0 280px; height: 160px; position: relative; border-radius: 16px; overflow: hidden; text-decoration: none; scroll-snap-align: start; border: 1px solid var(--glass-border); background: var(--glass); box-shadow: 0 10px 30px rgba(0,0,0,0.3); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s; }
.cw-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.cw-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0.4; transition: 0.4s; filter: blur(2px); }
.cw-card:hover .cw-bg { opacity: 0.6; filter: blur(0px); }
.cw-content { position: absolute; inset: 0; background: linear-gradient(to top, rgba(11,14,20,0.95) 0%, rgba(11,14,20,0.2) 100%); display: flex; flex-direction: column; justify-content: flex-end; padding: 15px; }
.cw-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 3rem; color: var(--primary); opacity: 0; transition: 0.3s; filter: drop-shadow(0 0 10px rgba(0,0,0,0.8)); }
.cw-card:hover .cw-play { opacity: 0.9; transform: translate(-50%, -50%) scale(1.1); }
.cw-info { display: flex; flex-direction: column; z-index: 2; }
.cw-series { color: #fff; font-size: 0.95rem; font-weight: 800; margin-bottom: 2px; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.cw-ep { color: var(--text-dim); font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-progress-bg { position: absolute; bottom: 0; left: 0; width: 100%; height: 4px; background: rgba(255,255,255,0.1); z-index: 3; }
.cw-progress-fill { height: 100%; background: var(--primary); box-shadow: 0 0 10px var(--primary); border-radius: 0 2px 2px 0; }

.story-explore-container { display: flex; justify-content: center; gap: 60px; margin-top: 30px; flex-wrap: wrap; }
.story-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; gap: 15px; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.story-item:hover { transform: translateY(-8px); }
.story-circle { width: 140px; height: 140px; border-radius: 50%; background-size: cover; background-position: center; border: 3px solid var(--glass-border); box-shadow: 0 10px 25px rgba(0,0,0,0.5); transition: all 0.3s ease; position: relative; overflow: hidden; }
.story-circle::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.4); transition: background 0.3s ease; }
.story-item:hover .story-circle { border-color: var(--primary); box-shadow: 0 0 25px rgba(0, 210, 255, 0.5); }
.story-item:hover .story-circle::after { background: rgba(0,0,0,0); }
.story-title { color: var(--text-dim); font-size: 1.1rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; transition: 0.3s; }
.story-item:hover .story-title { color: #fff; text-shadow: 0 0 10px rgba(0,210,255,0.6); }

/* Mobile Grid Overrides */
@media (max-width: 900px) {
    .movie-hero-container, .series-hero-container { padding: 25px 20px; }
    .movie-hero-content, .series-hero-content { flex-direction: column !important; align-items: center !important; text-align: center; gap: 25px; }
    .hero-poster-wrapper { flex: 0 0 auto; width: 220px; }
    .hero-details { align-items: center !important; width: 100%; }
    .hero-title { font-size: 2.2rem; }
    .hero-actions { justify-content: center !important; }
    .hero-top-meta { justify-content: center !important; }
    .ep-row-modern { flex-direction: column; align-items: flex-start; gap: 15px; }
    .ep-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 768px) {
    .movies-grid, .shows-grid, .latest-grid { grid-template-columns: repeat(var(--mobile-columns), 1fr) !important; gap: 12px !important; }
    .upcoming-badge { font-size: 0.55rem; padding: 3px 6px; top: 6px; left: 6px; }
    .cw-card { flex: 0 0 175px; height: 125px; } 
    .story-explore-container { gap: 25px; }
    .story-circle { width: 100px; height: 100px; border-width: 2px; }
    .story-title { font-size: 0.9rem; }
    /* Hide the status and upcoming date badges on mobile to keep posters clean */
    .status-badge, .upcoming-badge { 
        display: none !important; }
    /* Hide the quick-watch checkmark on mobile posters */
    .watched-toggle { display: none !important; }
    /* Hide the bulky hover overlay text on mobile to keep posters clean */
    .hover-overlay { display: none !important; }
}