:root {
    --primary-color: #e50914;
    --background-color: #141414;
    --card-background: #222;
    --text-color: #fff;
    --text-muted: #8c8c8c;
    --font-family: 'Roboto', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-family);
}

header {
    padding: 1rem 5%;
    background-color: rgba(20, 20, 20, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#logout-button {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

#logout-button:hover {
    background-color: #f61a26;
}

main {
    padding: 1.5rem 5%;
}

/* Login View */
#login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-container {
    background-color: var(--card-background);
    padding: 2.5rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.login-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 0.8rem;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 5px;
    color: var(--text-color);
    font-size: 1rem;
    font-family: var(--font-family);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.login-button {
    width: 100%;
    padding: 0.8rem;
    background-color: var(--primary-color);
    border: none;
    border-radius: 5px;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-button:hover {
    background-color: #f61a26;
}

.error-message {
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}

#course-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

#course-list-view h2 {
    font-size: 1.5rem;
    margin: 0;
}

.add-course-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.add-course-btn:hover {
    background-color: #f61a26;
}

#course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.course-card {
    background-color: var(--card-background);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.course-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}

.course-card img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.course-card-content {
    padding: 1rem;
}

.course-card-content h3 {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#course-detail-view {
    padding-bottom: 2rem;
}

#back-button {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: background-color 0.2s;
}

#back-button:hover {
    background-color: var(--card-background);
}

#video-player-container {
    position: sticky;
    top: 70px; /* Adjust based on header height */
    z-index: 5;
    background-color: var(--background-color);
    padding: 1rem 0;
    margin-bottom: 1rem;
}

#video-title {
    font-size: 1.5rem;
    font-weight: 500;
    margin-top: 1rem;
}

#video-description {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.5;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background-color: #000;
    border-radius: 8px;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#video-back-button {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: background-color 0.2s;
}

#video-back-button:hover {
    background-color: var(--card-background);
}

.course-banner {
    width: 100%;
    height: 30vh;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.course-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(20, 20, 20, 0.8), transparent);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
}

.banner-overlay h2 {
    font-size: 2rem;
    font-weight: 700;
}

.course-description {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 70ch;
}

.course-actions-container {
    margin: -1rem 0 2rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid #333;
}

.add-module-btn {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.add-module-btn:hover {
    background-color: var(--primary-color);
    color: var(--text-color);
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.module-header h3 {
    font-size: 1.4rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
    margin-bottom: 0;
}

.add-lesson-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.5rem;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-lesson-btn:hover {
    background-color: #f61a26;
}

.modules-container h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
}

.lesson-list {
    list-style: none;
    margin-top: 1.5rem;
}

.lesson-item {
    background-color: var(--card-background);
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent;
    transition: border-left-color 0.2s, background-color 0.2s;
}

.lesson-item-main {
    flex-grow: 1;
    cursor: pointer;
}

.lesson-item.active, .lesson-item.active:hover {
    background-color: #333;
    border-left-color: var(--primary-color);
}

.lesson-item:hover {
    background-color: #333;
    border-left-color: var(--primary-color);
}

.lesson-title {
    font-weight: 500;
}

.lesson-duration {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.lesson-actions {
    padding-left: 1rem;
}

.delete-lesson-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.delete-lesson-btn:hover {
    color: var(--primary-color);
}

.add-form-container {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #444;
}

.add-form-container h4 {
    margin-bottom: 1rem;
}

.add-lesson-form-container {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    margin-bottom: 2rem;
    border: 1px solid #444;
}

.add-lesson-form-container h4 {
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

.form-actions button {
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.form-actions .save-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
}

.form-actions .cancel-btn {
    background-color: #555;
    color: var(--text-color);
}

.hidden {
    display: none;
}