/* NEW: Style to hide an input */
.hidden-input {
    display: none !important; /* Use important to ensure it overrides other styles */
}

body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: #f5f6fa;
    color: #2c3e50;
}

header {
    background: white;
    padding: 20px 30px;
    border-bottom: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 2em;
    font-weight: bold;
    color: #e62117; /* YouTube red */
}

#channel-summary {
    font-size: 1em;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 10px;
}

#channel-summary span {
    margin-left: 15px;
}

main {
    padding: 30px;
    display: flex;
    flex-direction: column; /* Stack sections vertically */
    gap: 30px;
    max-width: 1200px; /* Limit width for readability */
    margin: 0 auto; /* Center the main content */
}

section {
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

section:hover {
    transform: translateY(-2px);
}

h2 {
    color: #2c3e50;
    margin-top: 0;
}

button {
    padding: 12px 20px;
    background-color: #cc0000;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s;
    vertical-align: top; /* Align buttons nicely if next to inputs */
}

button:hover {
    background-color: #b20000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Add a specific style for the reset button */
button.reset-button {
    background-color: #e74c3c; /* Reddish color */
    margin-left: 10px; /* Add some space */
}

button.reset-button:hover {
    background-color: #c0392b; /* Darker red on hover */
}

/* Style for the delete button */
button.delete-video-btn {
    background-color: #dc3545; /* Bootstrap-like danger red */
    padding: 5px 10px;
    font-size: 0.8em;
    margin-left: 5px; /* Space from other buttons */
}

button.delete-video-btn:hover {
    background-color: #c82333;
}

#videos-container {
    list-style: none;
    padding: 0;
}

#videos-container li {
    padding: 15px;
    margin-bottom: 15px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow content to wrap on smaller screens */
    cursor: pointer; /* NEW: Indicate clickable for video detail */
    transition: all 0.2s;
}

#videos-container li:hover {
    background-color: #f8f9fa;
    transform: translateX(3px);
    border-color: #d1d9dd;
}

#videos-container li > div {
    flex-grow: 1; /* Allow the video info div to take available space */
    margin-right: 10px; /* Space between info and buttons */
}

.video-stats {
    font-size: 0.95em;
    color: #666;
    margin-top: 8px;
}

/* Style for the 'Add to Playlist' button added to videos */
.add-to-playlist-btn {
    padding: 5px 10px; /* Smaller padding */
    font-size: 0.8em; /* Smaller font size */
    background-color: #007bff; /* Blue color */
}

.add-to-playlist-btn:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

/* Playlists Section Styles */
#playlists-container {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}

#playlists-container li {
    padding: 15px;
    margin-bottom: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
    cursor: pointer; /* Indicate clickable */
    transition: all 0.2s;
    display: flex;
    flex-direction: column; /* Stack name and stats vertically */
    gap: 5px;
}

#playlists-container li:hover {
    background: #f8f9fa;
    transform: translateX(3px);
}

.playlist-stats {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.playlist-view-count {
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    color: #1976d2;
}

.playlist-total-views {
    font-size: 0.8em;
    color: #666;
    font-weight: normal;
}

.playlist-video-count {
    background: #e1e8ed;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    margin-left: 10px;
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto; /* 15% from the top and centered */
    padding: 30px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 650px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    font-size: 1.5em;
    color: #2c3e50;
    margin-bottom: 20px;
    margin-top: 0;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.modal-content input[type="text"],
.modal-content select,
.modal-content textarea {
    display: block;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    transition: border-color 0.2s;
    width: calc(100% - 22px); /* Adjust for padding and border */
    margin-bottom: 15px;
    resize: vertical; /* Allow vertical resizing for textarea */
}

.modal-content input[type="text"]:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    border-color: #3498db;
    outline: none;
}

/* NEW: Style for the max views input group */
.max-views-input-group {
    display: flex; /* Arrange input and select horizontally */
    gap: 10px; /* Space between the elements */
    margin-bottom: 15px;
    align-items: center; /* Vertically align items */
}

.max-views-input-group input[type="number"] {
    flex-grow: 1; /* Allow input to take up most space */
    width: auto; /* Override display: block; width */
    margin-bottom: 0; /* Remove default bottom margin */
}

.max-views-input-group select {
    width: auto; /* Adjust width based on content */
    margin-bottom: 0; /* Remove default bottom margin */
}

/* NEW: Style for the max comments input group - similar to views */
.max-comments-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.max-comments-input-group input[type="number"] {
    flex-grow: 1;
    width: auto;
    margin-bottom: 0;
}

.max-comments-input-group select {
    width: auto;
    margin-bottom: 0;
}

/* NEW: Style for the skyrocket select input */
.modal-content select#skyrocket-option,
.modal-content select#playlist-skyrocket-option {
     width: calc(100% - 22px); /* Match other block inputs */
     margin-bottom: 15px;
}

/* Style for radio buttons */
.modal-content input[type="radio"] {
    display: inline-block; /* Make radio buttons and labels inline */
    width: auto; /* Auto width */
    margin-right: 5px; /* Space between radio and label */
}

.modal-content label[for^="type-"],
.modal-content label[for^="playlist-type-"] {
     display: inline-block; /* Make these labels inline */
     font-weight: normal; /* Less bold for the radio labels */
     margin-right: 15px; /* Space between radio groups */
}

.modal-content > div { /* Style for containers holding radios/selects */
    margin-bottom: 15px;
}

/* Specific style for the div containing the channel name input and button */
#settings-modal .modal-content > div:first-of-type,
#settings-modal .modal-content > div:nth-of-type(2) { /* Apply to both name and description divs */
    display: flex;
    align-items: center;
    gap: 10px; /* Space between input and button */
    margin-bottom: 15px; /* Add margin below this flex container */
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#settings-modal .modal-content > div:first-of-type input[type="text"],
#settings-modal .modal-content > div:nth-of-type(2) textarea { /* Apply to both name and description inputs */
    display: inline-block; /* Make input inline within flex */
    width: auto; /* Auto width within flex */
    flex-grow: 1; /* Allow input to take up remaining space */
    margin-bottom: 0; /* Remove bottom margin */
}

#settings-modal .modal-content > div:first-of-type button,
#settings-modal .modal-content > div:nth-of-type(2) button { /* Apply to both save buttons */
    margin-bottom: 0; /* Remove bottom margin */
    margin-top: 0; /* Remove top margin */
}

.modal-content button {
    margin-top: 10px;
    margin-right: 10px; /* Space between modal buttons */
}

/* Style for the small button inside the modal header */
.modal-content button.small-modal-button {
    font-size: 0.9em;
    padding: 8px 12px;
    margin-bottom: 15px; /* Space below the button */
    display: block; /* Make it take full width or be block */
    width: auto; /* Auto width */
    margin-left: 0; /* Remove default margin-left */
    margin-right: auto; /* Center or align left */
}

.close-modal-btn {
    background-color: #ccc;
    color: #333;
}

.close-modal-btn:hover {
    background-color: #bbb;
}

/* Style for announcement display */
.announcement-display {
    padding: 15px 20px;
    border: none;
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    margin: 20px 0;
    font-style: italic;
    color: #555;
    display: none; /* Hide by default if no announcement */
}

.announcement-display strong {
    color: #cc0000;
    margin-right: 5px;
}

/* Style for Add to Playlist options list */
#add-to-playlist-options-container {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}

#add-to-playlist-options-container li {
    padding: 10px;
    border: 1px solid #eee;
    margin-bottom: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

#add-to-playlist-options-container li:hover {
    background-color: #f0f0f0;
}

/* --- Styles for the Playlist View Modal --- */
#playlist-view-modal .modal-content {
    max-width: 600px; /* Slightly wider for video list */
}

#playlist-view-videos-container {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}

#playlist-view-videos-container li {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px; /* Space between items */
}

#playlist-view-videos-container li > div:first-child {
    flex-grow: 1; /* Allow video title/stats to take space */
}

.playlist-view-video-actions button {
     padding: 4px 8px; /* Smaller buttons */
     font-size: 0.75em; /* Smaller font */
     margin: 0 2px; /* Tighten spacing */
     vertical-align: middle; /* Align buttons vertically */
}

.remove-from-playlist-btn {
    background-color: #dc3545; /* Red for removal */
}

.remove-from-playlist-btn:hover {
    background-color: #c82333;
}

/* Style for the Delete Video button in Playlist View (for playlist-only videos) */
.delete-playlist-only-video-btn {
    background-color: #c0392b; /* Slightly darker red for permanent delete */
}
.delete-playlist-only-video-btn:hover {
    background-color: #a93226;
}

.move-video-btn {
    background-color: #007bff; /* Blue for move */
}

.move-video-btn:hover {
    background-color: #0056b3;
}

.playlist-view-actions {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    gap: 10px; /* Space between action buttons */
}

#delete-playlist-btn {
    margin-right: auto; /* Push the delete button to the left */
}

/* --- Styles for the NEW Playlist Video Creation Modal --- */
#playlist-video-creation-modal .modal-content {
     max-width: 450px; /* Slightly smaller than main video modal */
}

/* NEW: Style for the max views input group in the playlist modal */
#playlist-video-creation-modal .max-views-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

#playlist-video-creation-modal .max-views-input-group input[type="number"] {
    flex-grow: 1;
    width: auto;
    margin-bottom: 0;
}

#playlist-video-creation-modal .max-views-input-group select {
    width: auto;
    margin-bottom: 0;
}

/* NEW: Style for the max comments input group in the playlist modal */
#playlist-video-creation-modal .max-comments-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

#playlist-video-creation-modal .max-comments-input-group input[type="number"] {
    flex-grow: 1;
    width: auto;
    margin-bottom: 0;
}

#playlist-video-creation-modal .max-comments-input-group select {
    width: auto;
    margin-bottom: 0;
}

/* NEW: Style for sorting options */
.sort-options {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sort-options label {
    font-weight: bold;
    margin-bottom: 0; /* Override default label margin */
}

.sort-options select {
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    width: auto; /* Allow select to size to content */
    display: inline-block; /* Make it inline with label */
    margin-bottom: 0; /* Remove default margin */
}

/* NEW: Video Detail Modal specific styles */
#video-detail-modal .modal-content {
    max-width: 600px;
}

#video-detail-modal p {
    margin-bottom: 8px;
    font-size: 0.95em;
}

#video-detail-modal p strong {
    color: #555;
    margin-right: 5px;
}

#detail-video-comments-list {
    list-style: none;
    padding: 0;
    max-height: 400px; /* Limit height for scrollable comments */
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 15px;
    background: #ffffff;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

#detail-video-comments-list li {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
    font-size: 0.9em;
    color: #444;
}

#detail-video-comments-list li:last-child {
    border-bottom: none;
}

footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #555;
    font-size: 0.8em;
    border-top: 1px solid #eee;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}