/* * 06_modals.css 
 * Contains: All styles for Modals (Show Details, Confirm, Info)
 */

/* ---------------------------------- */
/* 13. Modals                       */
/* ---------------------------------- */

/* This rule is VITAL for collapsing seasons */
.hidden {
    display: none !important;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
	right: 0;  
    bottom: 0;
    width: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
    animation: fadeIn 0.3s;
}

/* This positions the modal at the top instead of centering */
.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;      
}

/* Main Modal Content Box */
.modal-content {
    background-color: var(--surface-color);
    margin: 0 auto; /* Keeps it centered horizontally */
    border: 1px solid var(--border-color);
    width: 85%;
    max-width: 900px; /* Largest desktop size */
    border-radius: 8px;
    position: relative;
    overflow: hidden; /* We will scroll the body, not the content box */
    
    /* Flex rules to fix scrolling */
    display: flex;
    flex-direction: column;
}

/* This is the main content area (header + nav + tabs) */
#showModal .modal-body {
    padding: 0; 
    flex: 1 1 auto; /* Allows body to grow and shrink */
    overflow-y: hidden; /* The wrapper child will scroll */
    display: flex;
    flex-direction: column;
}

.modal-close-btn {
    color: var(--text-color-secondary);
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1010; /* Ensure it's above poster */
}

.modal-close-btn:hover,
.modal-close-btn:focus {
    color: var(--text-color);
}

/* Confirmation Modal (for deleting) */
#confirmModalContent {
    max-width: 400px;
    padding: 30px;
    text-align: center;
}
.confirm-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}
.confirm-modal-buttons button {
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    border: none;
}
#confirmModalYes {
    background-color: var(--danger-color);
    color: white;
}
#confirmModalNo {
    background-color: var(--border-color);
    color: var(--text-color);
}

/* Info Modal (for general messages) */
#infoModalContent {
    max-width: 450px;
    padding: 30px;
    text-align: center;
    font-size: 1.1rem; 
    line-height: 1.6;
}
.info-modal-buttons {
    display: flex;
    justify-content: center;
    margin-top: 25px;
}
.info-modal-buttons button {
    padding: 10px 30px; 
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    border: none;
}
#infoModalOkBtn {
    background-color: var(--primary-color);
    color: white;
    transition: background-color 0.2s ease;
}
#infoModalOkBtn:hover {
    background-color: #3593d6; 
}


/* --- Add to Tracker button (in Modal) --- */
.modal-add-button-container {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    border-radius: 0 0 8px 8px; /* Match modal corners */
    flex-shrink: 0; /* Prevents this from scrolling */
}

.modal-add-btn {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.modal-add-btn:hover {
    background-color: #3593d6;
}

.modal-add-btn:disabled {
    background-color: var(--success-color);
    opacity: 0.8;
    cursor: not-allowed;
}

/* ================================================================= */
/* === 1. NEW MODAL LAYOUT STYLES === */
/* ================================================================= */

/* Style the new top header */
.modal-top-header {
    position: relative;
    width: 100%;
    max-height: 600px;
    overflow: hidden;
    flex-shrink: 0; /* Don't shrink the header */
}

.modal-top-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    /* Create a fade-out effect at the bottom */
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.modal-top-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2rem 1rem 1rem 1rem; /* Extra padding at top for gradient */
    box-sizing: border-box;
    /* Gradient from bottom to top, ensures text is readable */
    background: linear-gradient(180deg, rgba(30, 32, 37, 0.0) 0%, rgba(30, 32, 37, 0.8) 40%, #1E2025 100%);
}

.modal-top-info h2 .status-badge.ended {
    display: none;
}

/* Reposition platform logo */
.modal-top-info .show-platform-logo {
    position: absolute;
    top: -20px; 
    right: 1rem;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 4px;
    z-index: 10;
}
.modal-top-info .show-platform-logo img {
    height: 40px;
    width: auto;
}
.modal-top-info .show-platform-text {
    color: #ccc;
}


/* === 2. MODAL NAVIGATION BAR === */
.modal-nav-bar {
    display: grid; 
    grid-template-columns: 1fr 1fr; /* 2 equal-width columns */
    flex-wrap: nowrap; 
    width: 100%;
    background: var(--color-bg-dark); 
    border-bottom: 1px solid #444;
    flex-shrink: 0; /* Don't shrink the nav bar */
}

.modal-nav-link {
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #aaa;
    background: none;
    border: none;
    padding: 0.9rem 1.2rem;
    cursor: pointer;
    border-bottom: 3px solid transparent; 
    margin-bottom: -1px; 
    transition: color 0.2s ease, border-color 0.2s ease;
    text-align: center; 
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
}

.modal-nav-link:hover {
    color: #fff;
    background: #333;
}

.modal-nav-link.active {
    color: #fff;
    border-bottom-color: var(--accent-color);
}


/* === 3. MODAL TAB CONTENT === */

/* THIS IS THE NEW SCROLLING WRAPPER */
.modal-tabs-wrapper {
    flex: 1 1 auto; /* This makes it fill the remaining space */
    overflow-y: auto; /* This makes IT scroll, not the modal */
}

.modal-tab-content {
    display: none; /* Hide all tabs by default */
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.modal-tab-content.active {
    display: block; /* Show only the active tab */
}

.modal-tab-content .card-body-header {
    margin-top: 0;
}
.modal-tab-content .episode-list {
    max-height: 400px; /* Constrain episode list height */
}


/* === 4. CAST LIST STYLES === */
.cast-list-header {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #444;
    color: #fff;
    font-size: 1.25rem;
}

.cast-list {
    display: grid;
    /* Uses the smaller column size by default */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    /* No max-height or overflow, so it scrolls with the main tab */
}

.cast-member {
    background: var(--color-bg-light);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cast-photo {
    width: 100%;
    height: 180px; /* Shorter photos for smaller columns */
    object-fit: cover;
    object-position: top center;
    background: #111; /* Fallback */
}

.cast-photo-char {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-top: -30px; 
    margin-left: 10px;
    position: relative;
    z-index: 2;
}

.cast-info {
    padding: 0.8rem;
    flex-grow: 1;
}

.cast-actor-name {
    display: block;
    font-weight: 700;
    color: #fff;
    font-size: 0.95rem;
}

.cast-char-name {
    display: block;
    font-size: 0.85rem;
    color: #ccc;
}


/* === 5. WATCH STATUS IN HEADER === */
.next-episode-info-header {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #444; /* Adds a nice separator */
}

.next-episode-info-header h4 {
    margin: 0 0 4px 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa; /* Lighter color */
    font-weight: 700;
}

.next-episode-info-header p {
    margin: 0;
    font-size: 0.95rem;
    color: #fff; /* White text */
    font-weight: 400;
}

.next-episode-info-header .countdown.upcoming {
    color: var(--success-color);
}
.next-episode-info-header .countdown.past {
    color: var(--danger-color);
}
.next-episode-info-header .countdown.tba {
    color: #ccc;
}

/* Hide the old blue-bordered box, which is now obsolete */
.modal-tab-content .next-episode-info {
    display: none;
}

/* 1. Make watched episodes green and strikethrough */
.modal-content .episode-item.watched .episode-name {
    color: #66BB6A; /* A readable, light green */
    text-decoration: line-through;
}

/* 2. Add the green checkmark to the right of the name */
.modal-content .episode-item.watched .episode-name::after {
    content: '✔'; /* This is the checkmark character */
    font-weight: bold;
    margin-left: 8px; /* Adds space between the name and the check */
    
    /* This is crucial: it prevents the checkmark from being struck-through */
    text-decoration: none;
    display: inline-block;
}

/* 3. Make unwatched (and aired) episodes a readable red */
/* This targets items that are NOT .watched and NOT .future-episode */
.modal-content .episode-item:not(.watched):not(.future-episode) .episode-name {
    color: #E57373; /* A readable, light red */
}


/* Simple fade-in animation for tabs */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================================= */
/* === 6. NEW: Modal Season Tab UI === */
/* ================================================================= */

/* Hides the "All Episodes" H3 in the 'Seasons' tab */
.modal-tab-content[data-tab-id="seasons"] .card-body-header h3 {
    display: none;
}

/* This is the container for the "S01", "S02" boxes */
.season-tab-container {
    display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));    
	gap: 10px;    
	padding: 0 0 15px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

/* Style for each "S01" tab box */
.season-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
	justify-content: space-between;
}

/* The text part of the tab (e.g., "S01") */
.season-tab-label {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-color-secondary);
    transition: color 0.2s ease;
    pointer-events: none; /* Clicks should pass through to the parent tab */
}

/* --- Tab States --- */

.season-tab:hover {
    border-color: var(--primary-color);
}

.season-tab:hover .season-tab-label {
    color: var(--primary-color);
}

/* The active/selected tab */
.season-tab.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.season-tab.active .season-tab-label {
    color: #fff;
}

/* --- Checkbox Inside Tab --- */
/* We just need to adjust margins, the core style is in 04_show_card.css */
.season-tab .season-checkbox-container {
    margin: 0;
    width: 20px; /* Make it a bit smaller */
    height: 20px;
}
.season-tab .season-checkbox-container .season-checkmark {
    width: 5px;
    height: 10px;
}

/* --- Episode List Container --- */

/* This wrapper holds all the episode lists */
.season-content-container {
    position: relative;
    max-height: 400px; /* Sets the scrollable height */
    overflow-y: auto;
}


/* Hide all episode lists by default */
.season-content-container .episode-list {
    display: none;
    max-height: none; /* Remove max-height from the list itself */
    overflow-y: visible; /* Let the container handle scrolling */
	
}
.season-tab-container .episode-list {
	display: none;
    max-height: none; /* Remove max-height from the list itself */
    overflow-y: visible; /* Let the container handle scrolling */
    grid-column: 1 / -1;
    margin-bottom: 10px; /* Add some space after the list */
}


/* Show only the active episode list */
.season-tab-container .episode-list.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Remove old collapsible list styles inside the modal */
.modal-content .episode-list li.season-separator {
    display: none;
}

/* ================================================================= */
/* === 7. NEW: Season Grouping Styles (Modal) === */
/* ================================================================= */

.modal-content .season-tab-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
	grid-column: 1 / -1;
}

.modal-content .season-tab-group .season-tab-label {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-color-secondary);
    transition: color 0.2s ease;
    pointer-events: none;
}

.modal-content .season-tab-group:hover {
    border-color: var(--primary-color);
}
.modal-content .season-tab-group:hover .season-tab-label {
    color: var(--primary-color);
}

.modal-content .season-tab-group.expanded {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.modal-content .season-tab-group.expanded .season-tab-label {
    color: #fff;
}

.modal-content .season-group-toggle-icon {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-color-secondary); /* Points down */
    transition: all 0.2s ease;
    pointer-events: none; /* Pass clicks to parent */
}

.modal-content .season-tab-group.expanded .season-group-toggle-icon {
    transform: rotate(180deg); /* Points up */
    border-top-color: #fff; /* White when expanded */
}
.modal-content .season-tab-group:hover .season-group-toggle-icon {
    border-top-color: var(--primary-color);
}
.modal-content .season-tab-group.expanded:hover .season-group-toggle-icon {
    border-top-color: #fff;
}

.modal-content .season-tabs-individual-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* This makes it take up the full width below the group tab */
    flex-basis: 100%; 
    padding: 10px 0 0 0;
	grid-column: 1 / -1;
	
}

.modal-content .season-tabs-individual-wrapper.hidden {
    display: none;
}

/* --- ADD THIS NEW BLOCK to css/06_modals.css --- */

/* These rules make the 'completed' checkbox appear green */
.modal-content .season-tab-group .season-group-icons,
.modal-content .season-tab .season-group-icons {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between checkmark and arrow */
    pointer-events: none; 
}

.modal-content .season-tab-group .season-checkbox-container {
    display: none; /* Hide the checkbox by default */
    width: 20px; 
    height: 20px;
    border: 2px solid var(--text-color-secondary);
    border-radius: 5px;
    margin: 0;
}

.modal-content .season-tab-group .season-checkbox-container .season-checkmark {
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg) translateY(-1px);
    opacity: 0;
}

.modal-content .season-tab.active .season-group-toggle-icon {
    transform: rotate(180deg); /* Points up */
    border-top-color: #fff; /* White when active */
}

/* Make the arrow stay white on hover when active */
.modal-content .season-tab.active:hover .season-group-toggle-icon {
    border-top-color: #fff;
}

/* This is the key: Show and style the checkmark when the group is .completed */
.modal-content .season-tab-group.completed .season-checkbox-container {
    display: flex; /* Show the box */
    align-items: center;
    justify-content: center;
    background-color: var(--success-color);
    border-color: var(--success-color);
}

/* Show the checkmark *glyph* */
.modal-content .season-tab-group.completed .season-checkbox-container .season-checkmark {
    opacity: 1;
}

/* Add this to css/06_modals.css or css/01_global.css */

/* Positions the "Next:" label above the timer */
.countdown-next-label {
    color: #4CAF50;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;

}

/* Styles the timer wrapper inside the modal */
.modal-countdown-container {
    width: 100%;
    /* Centers the label and timer block */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Increases the font size for the countdown *only* in the modal */
.modal-countdown-container .countdown-timer {
    font-size: 1.15rem; /* Increase base font size */
    max-width: 400px;
    width: 100%;
}

.modal-countdown-container .countdown-timer .countdown {
    font-size: 2.5rem; /* Increase number font size */
}

/* Makes the "Ended" button and "TBA" text bigger in the modal too */
.modal-countdown-container .countdown-timer .status-badge,
.modal-countdown-container .countdown-timer .countdown-tba-text {
    font-size: 1.2rem;
    padding: 10px 20px;
}

/* ============================ */
/* === ACTOR DETAIL STYLING === */
/* ============================ */

/* Make cast members look clickable */
.cast-list .cast-member {
    transition: background-color 0.2s;
    border-radius: 4px;
}
.cast-list .cast-member:hover {
    background-color: #2a2a2a;
    cursor: pointer;
}

/* Back button */
.cast-back-btn {
    display: inline-block;
    background: #333;
    color: #eee;
    border: 1px solid #555;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 20px;
    transition: background-color 0.2s;
}
.cast-back-btn:hover {
    background: #444;
}

/* Container for the actor detail view */
.actor-detail-view {
    padding: 10px;
}
.actor-detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
.actor-detail-img {
    width: 150px;
    height: 210px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}
.actor-detail-info h3 {
    font-size: 1.8rem;
    margin: 0;
    color: #fff;
}
.actor-detail-info p {
    font-size: 0.9rem;
    color: #ccc;
    margin: 5px 0;
}
.actor-detail-info p strong {
    color: #888;
}

/* Actor's biography */
.actor-detail-bio {
    line-height: 1.6;
    color: #ddd;
}
.actor-detail-bio p {
    margin-bottom: 15px;
}
/* Add this to the end of css/06_modals.css */

.actor-detail-info .actor-tvmaze-link {
    margin-top: 10px;
}

.actor-detail-info .actor-tvmaze-link a {
    color: #3fa9f5;
    text-decoration: none;
    font-weight: bold;
}
.actor-detail-info .actor-tvmaze-link a:hover {
    text-decoration: underline;
}



/* =============================== */
/* === EPISODE TOOLTIP STYLING === */
/* =============================== */

.episode-tooltip {
    position: fixed; /* Floats over everything */
    z-index: 1001; /* Must be higher than the modal (1000) */
    background-color: #1e1e1e;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    width: 380px; /* Set a fixed width */
    max-width: 90vw;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    
    /* Makes mouse events pass through it to the element below */
    pointer-events: none; 
    
    /* Fade in/out */
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    
    /* Will be positioned by JavaScript */
}

.episode-tooltip.active {
    opacity: 1;
}

.tooltip-header {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.tooltip-img {
    width: 120px;
    height: 68px; /* 16:9 aspect ratio */
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.tooltip-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: #3fa9f5;
}
.tooltip-info p {
    margin: 2px 0;
    font-size: 0.9rem;
    color: #ccc;
}

.tooltip-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #ddd;
    
    /* Add a scrollbar if summary is too long */
    max-height: 150px;
    overflow-y: auto;
}