/* ===== RESET & BASE STYLES ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ===== LAYOUT CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER STYLES ===== */
header {
    background-color: #881418;
    color: white;
    padding: 1rem;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 2rem;
}

/* ===== LOGIN FORM STYLES ===== */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

/* ===== BUTTON STYLES ===== */
.btn {
    padding: 12px;
    background-color: #881418;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #be1f24;
}

.btn-logout {
    background-color: #FF8C28;
    padding: 8px 15px;
    font-size: 14px;
}

.btn-logout:hover {
    background-color: #be1f24;
}

/* ===== MAIN CONTENT LAYOUT ===== */
.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* ===== COURSES SIDEBAR ===== */
.courses-sidebar {
    flex: 1;
    min-width: 250px;
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    max-height: 80vh;
}

.course-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.course-item {
    padding: 12px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.course-item:hover {
    background-color: #e8eaed;
}

.course-item.active {
    background-color: #881418;
    color: white;
}

/* ===== PLAYER CONTAINER ===== */
.player-container {
    flex: 3;
    min-width: 300px;
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ===== VIDEO CONTAINER ===== */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 20px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== MODULE INFO STYLES ===== */
.module-info {
    margin-bottom: 15px;
}

.module-title {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.course-title {
    color: #666;
    margin-bottom: 10px;
}

/* ===== NAVIGATION STYLES ===== */
.navigation {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

/* ===== MODULE LIST STYLES ===== */
.module-list {
    list-style: none;
    margin-top: 20px;
}

.module-item {
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.module-item:hover {
    background-color: #e8eaed;
}

.module-item.active {
    background-color: #881418;
    color: white;
}

/* ===== ERROR MESSAGE ===== */
.error-message {
    color: #EA4335;
    margin-top: 10px;
    text-align: center;
}

/* ===== USER INFO DISPLAY ===== */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== SEARCH CONTAINER ===== */
.search-container {
    margin-bottom: 15px;
}

#courseSearch {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* ===== IMAGE CONTAINER STYLES ===== */
#image-container {
    display: none;
    position: relative;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
    border: 1px solid #ddd;
}

.image-container-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* Same 16:9 ratio as YouTube */
    height: 0;
    overflow: auto;
}

.image-scroll-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1px;
    overflow: auto;
}

.image-scroll-area img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Gambar di-center dan scaled down */
.image-scroll-area img.fit-mode {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: auto;
    object-fit: contain;
}

/* Gambar natural size, posisi start dari kiri-atas */
.image-scroll-area img.full-mode {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    margin: 0 !important;
    align-self: flex-start !important;
    justify-self: flex-start !important;
}

.image-scroll-area.full-mode {
    justify-content: flex-start !important;
    align-items: flex-start !important;
}

.image-controls {
    padding: 10px;
    text-align: center;
    border-top: 1px solid #ddd;
    background: white;
}

.image-fullscreen-btn {
    margin: 0 5px;
    padding: 8px 15px;
    background: #4285F4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.image-fullscreen-btn:hover {
    background: #3367D6;
}

/* ===== IMAGE MODULE CONTROLS ===== */
#imageModuleControls {
    display: flex;
    gap: 10px;
}

#imageModuleControls .btn {
    background-color: #FF8C28;
    color: white;
}

#imageModuleControls .btn:hover {
    background-color: #FFFF00;
    color: black;
}

/* Adjust padding untuk image scroll area */
.image-scroll-area {
    padding: 1px;
}

/* Untuk styling tombol toggle yang aktif */
#toggleFitFullBtn.active {
    background-color: #28a745;
    border-color: #28a745;
}

/* ===== MODAL STYLES (UNTUK NOTES) ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
}

#notesTextarea {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== FLOATING NOTES BUTTON ===== */
#notesBtn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 15px 8px;
    font-size: 14px;
    background-color: #FF8C28;
    color: white;
    border: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: -2px 0 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

/* FALLBACK UNTUK BROWSER YANG TIDAK SUPPORT WRITING-MODE */
@supports not (writing-mode: vertical-rl) {
    #notesBtn {
        writing-mode: horizontal-tb; /* Reset ke horizontal */
        transform: translateY(-50%) rotate(270deg); /* ← PAKAI ROTATE HANYA JIKA TIDAK SUPPORT */
        white-space: nowrap;
    }
}

#notesBtn:hover {
    background-color: #FFFF00;
    color: black;
    right: 2px;
}

/* ===== TOGGLE BUTTON (MOBILE SIDEBAR) ===== */
.toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

/* ===== OVERLAY STYLES (UNTUK BLOKIR POPUP) ===== */
.overlay-box {
    position: absolute;
    top: 0;
    right: 0;
    width: 75px;
    height: 75px;
    background-color: transparent;
    cursor: not-allowed;
    z-index: 10;
}

.tooltip {
    display: none;
    position: absolute;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 11;
    right: 0;
    top: 80px;
    white-space: nowrap;
}

.has-overlay {
    position: relative;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Untuk perangkat mobile */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .courses-sidebar, .player-container {
        width: 100%;
    }
    
    header {
        flex-direction: column;
        gap: 10px;
    }
    
    #notesBtn {
        padding: 12px 6px;
        font-size: 12px;
    }
    
    .toggle-btn {
        display: inline;
    }
    
    .course-list-container {
        display: block;
    }
    
    .course-list-container.collapsed {
        display: none;
    }
}

/* Untuk layar sangat lebar */
@media (min-width: 1600px) {
    #notesBtn {
        right: calc((100% - 1200px) / 2 - 40px);
    }
}

/* ===== LOADING INDICATOR ANIMATION ===== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}