:root {
    --primary-color: #007bff;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --border-color: #e0e0e0;
    --active-subtitle-bg: #e6f2ff;
}

#primary,
#main,
.site-main,
.site-content,
.ast-container,
#content {
    margin: 0 !important;
    padding: 0 !important;
}

body {
    margin: 0 !important;
    padding: 5px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.shadowing-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 6px;
}

@media (max-width: 768px) {
    .shadowing-container {
        grid-template-columns: 1fr;
    }
    .shadowing-container > p,
    .shadowing-container > br {
        display: none !important;
    }
    /* Let video-section remain sticky on mobile */
}

.video-section {
    position: sticky;
    top: 0; /* Sticks to the very top */
    align-self: start;
    z-index: 10;
}

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

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

.video-interaction-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5; /* Di atas iframe */
    cursor: pointer;
}

.custom-video-banner {
    position: absolute;
    bottom: 12px;
    left: 30px;
    right: 30px;
    height: 48px;
    background-color: black;
    border-radius: 48px;
    z-index: 10; /* Di atas interaction layer */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.banner-text {
    color: #65799c;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
}

.custom-video-banner.show {
    opacity: 1;
}

.video-initial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #65799c;
    z-index: 15; /* Di atas video, di bawah interaction layer jika perlu, atau setara interaction layer */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Let clicks pass through to play button */
    transition: opacity 0.3s ease;
}

.initial-topic-label {
    color: white;
    font-size: 14px;
    font-weight: normal;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.initial-topic-title {
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    padding: 0 20px;
    line-height: 1.3;
}

.video-end-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.overlay-content {
    text-align: center;
}

.overlay-title {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.overlay-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.overlay-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.video-tools {
    margin-top: 0;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: visible; /* <-- Changed from hidden so dropdown can overflow upwards */
    background: white;
}

.video-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}

.tool-settings {
    display: flex;
    gap: 8px;
    padding-left: 12px;
}

.custom-select-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    padding: 3px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-width: 40px;
}

.select-label {
    font-size: 7px;
    color: #888;
    text-transform: uppercase;
}

.select-value {
    font-size: 9px;
    font-weight: bold;
    color: #333;
    margin-top: 1px;
}

.custom-dropdown-menu {
    display: none;
    position: absolute;
    bottom: 100%; /* Drop upwards */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    list-style: none !important;
    padding: 0 !important;
    margin: 0 0 2px 0 !important;
    min-width: 60px;
    z-index: 20;
    max-height: 200px;
    overflow-y: auto;
}

.custom-dropdown-menu.show {
    display: block;
}

.custom-dropdown-menu li {
    padding: 1px 0px !important;
    margin: 0 !important;
    font-size: 8px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.custom-dropdown-menu li:last-child {
    border-bottom: none;
}

.custom-dropdown-menu li:hover {
    background: #f0f0f0;
}

.video-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    background: #fafafa;
    border-radius: 0 0 8px 8px; /* <-- Keeps the bottom corners rounded */
}

.custom-progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0 4px;
}

.progress-time {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    min-width: 35px;
    text-align: center;
}

.custom-progress-bar-wrapper {
    flex-grow: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}

.custom-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.1s linear;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 16px;
    background: #0056b3; /* Darker blue for visibility */
    border-radius: 2px;
    pointer-events: none; /* Wrapper handles drag */
    transition: left 0.1s linear;
    z-index: 10;
}

.progress-tooltip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.progress-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
}

.custom-progress-bar-wrapper.show-tooltip .progress-tooltip {
    opacity: 1;
}

@media (hover: hover) {
    .custom-progress-bar-wrapper:hover .progress-tooltip {
        opacity: 1;
    }
}

.settings-dropup-container {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-settings-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    color: #666;
    transition: transform 0.2s;
}

.btn-settings-icon:hover {
    transform: rotate(45deg);
}

.settings-dropup-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    padding: 10px;
    min-width: 150px;
    z-index: 30;
    flex-direction: column;
    gap: 10px;
}

.settings-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: #333;
    font-weight: 600;
}

.settings-item input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.settings-item select {
    width: 100%;
    padding: 4px;
    font-size: 11px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.btn-fullscreen {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
    color: #333;
    transition: background 0.2s;
}

.btn-fullscreen:hover {
    background: #e0e0e0;
}

.control-buttons-wrapper {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.control-btn {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    background-color: white !important;
    color: #333 !important; /* Force text color even on hover */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: background 0.2s;
    flex: 1;
    font-weight: 600;
}

.control-btn:hover {
    background-color: #e0e0e0 !important;
    color: #333 !important;
}

/* Subtitles Section */
.subtitles-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    /* Removed max-height and overflow so it scrolls globally with the page */
}

@media (min-width: 769px) {
    .subtitles-section {
        overflow-y: auto;
    }
}

.mode-tabs-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.record-toggle-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: #007bff;
    color: white;
    font-size: 9px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.record-toggle-btn.active {
    background: rgb(145, 189, 53);
}

.mode-tabs {
    display: flex;
}

.mode-tab {
    padding: 6px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 9px;
    font-weight: bold;
    color: #666;
    transition: all 0.2s;
    border-left: 1px solid var(--border-color);
}

.mode-tab:hover {
    background: #e9e9e9;
}

.mode-tab.active {
    background: white;
    color: var(--primary-color);
    box-shadow: inset 0 -2px 0 var(--primary-color);
}

/* Record Controls */
.record-controls {
    display: none;
    gap: 8px;
    padding: 12px;
    background: #f0f0f0;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
}

.after-video-voice-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
    margin-right: 4px;
}

.record-controls.show {
    display: flex;
}

.video-tools.recording-active .video-controls {
    border-radius: 0;
}

.btn-tele-rec {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: white;
    color: #333;
    transition: all 0.2s;
}

.btn-tele-rec:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-tele-rec:not(:disabled):hover {
    background: #e9e9e9 !important;
    color: #333 !important;
}

.btn-tele-rec.is-recording {
    background: #ff4d4d;
    color: white;
    border-color: #ff4d4d;
}

.subtitles-header {
    padding: 8px 12px;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
    display: flex;
    align-items: center;
}

.active-line-box {
    height: 3.3em;
    overflow-y: auto;
    background: #20263B;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 3px 4px;
    font-size: 1em;
    text-align: center;
    line-height: 1.5;
}

.active-line-box.initial-state {
    background: #65799c;
}

.active-line-box .sub-1-text {
    color: white;
}

.sub-1-text.sub-bold {
    font-weight: bold;
}

.active-line-box .sub-2-text {
    color: #FAF47F;
    font-size: 0.85em;
}

.active-line-box .sub-long {
    font-size: 0.75em; /* 0.75em relatif terhadap base (1em) */
}

.active-line-box .sub-2-text.sub-long {
    font-size: calc(0.75em * 0.85); /* Tetap 0.85x dari sub 1 meskipun sedang mode long */
}

.subtitles-list {
    flex: 1;
    padding: 0;
}

.subtitle-line {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 12px;
}

.subtitle-line:hover {
    background: #f9f9f9;
}

.subtitle-line.active {
    background: var(--active-subtitle-bg);
    border-left: 4px solid var(--primary-color);
}

.subtitle-time {
    color: #888;
    font-size: 0.85em;
    min-width: 40px;
    margin-top: 2px;
}

.subtitle-text {
    flex: 1;
    line-height: 1.4;
}

/* =========================================
   FULLSCREEN MODE OVERRIDES
   ========================================= */
.shadowing-container:fullscreen {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100% !important;
    background: black !important;
    padding: 0 !important;
    margin: 0 !important;
}

.shadowing-container:fullscreen .subtitles-section,
.shadowing-container:fullscreen .video-tools-header {
    display: none !important;
}

.shadowing-container:fullscreen .video-section {
    width: 100% !important;
    height: 100% !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    position: static !important;
}

.shadowing-container:fullscreen .video-wrapper {
    padding-bottom: 0 !important;
    flex-grow: 1 !important;
    border-radius: 0 !important;
}

.shadowing-container:fullscreen .video-controls {
    border-radius: 0 !important;
}

/* For older webkit browsers */
.shadowing-container:-webkit-full-screen {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100% !important;
    background: black !important;
    padding: 0 !important;
    margin: 0 !important;
}
.shadowing-container:-webkit-full-screen .subtitles-section,
.shadowing-container:-webkit-full-screen .video-tools-header {
    display: none !important;
}
.shadowing-container:-webkit-full-screen .video-section {
    width: 100% !important;
    height: 100% !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    position: static !important;
}
.shadowing-container:-webkit-full-screen .video-wrapper {
    padding-bottom: 0 !important;
    flex-grow: 1 !important;
    border-radius: 0 !important;
}
.shadowing-container:-webkit-full-screen .video-controls {
    border-radius: 0 !important;
}

/* Custom Video Modal */
.custom-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.custom-video-modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.custom-video-modal-content h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #333;
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.modal-form-row {
    display: flex;
    gap: 16px;
}

.modal-input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.modal-textarea {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    height: 120px;
    resize: vertical;
    box-sizing: border-box;
    font-family: monospace;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cancel-btn {
    background: #f0f0f0;
    color: #333;
}

.cancel-btn:hover {
    background: #e0e0e0;
}

.ok-btn {
    background: var(--primary-color);
    color: white;
}

.ok-btn:hover {
    background: #0056b3;
}


#btn-back-shadowing {
    position: absolute;
    top: 16px;
    left: 30px;
    width: 36px;
    height: 36px;
    border: 2px solid white;
    border-radius: 50%;
    background-color: #20263b;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}
#btn-back-shadowing.show {
    opacity: 1;
    pointer-events: auto;
}
#btn-back-shadowing:hover {
    background-color: #313a5b;
}


.video-watch-progress {
    position: absolute;
    top: 16px;
    right: 30px;
    min-width: 60px;
    height: 36px;
    padding: 2px 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    background-color: #20263b;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    box-sizing: border-box;
    text-align: center;
    line-height: 1.1;
}

.video-watch-progress .progress-val {
    font-size: 13px;
    font-weight: bold;
    color: #ffffff;
}

.video-watch-progress .progress-label {
    font-size: 10px;
    color: #94a3b8;
}

#btn-back-initial {
    position: absolute;
    top: 16px;
    left: 30px;
    width: 36px;
    height: 36px;
    border: 2px solid white;
    border-radius: 50%;
    background-color: #20263b;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 50;
    pointer-events: auto;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}
#btn-back-initial:hover {
    background-color: #313a5b;
}

@media (max-width: 390px) {
    #btn-back-shadowing {
        left: 16px;
    }
    #btn-back-initial {
        left: 16px;
    }
    .video-watch-progress {
        right: 16px;
    }
}