/* CSS Variables for consistent colors and values */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #4CAF50;
    --secondary-dark: #43A047;
    --light-bg: #f8f9fa;
    --lighter-bg: #e9ecef;
    --timeline-bg: #d0d0d0;
    --border-radius: 4px;
    --transition-speed: 0.2s;
    --transcript-tab-bg: #e8e8e8;
}

/* Base container and components */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #0d8b8e 0%, #0f585e 100%);
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    margin: 0;
}

.main-wrapper {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 1200px;
    width: 100%;
    margin: 20px auto;
}

.container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

.video-container {
    width: 100%;
    padding: 0;
    margin: 0 auto;
    box-sizing: border-box;
}

.video-controls, .marker-item { 
    background: var(--light-bg); 
    border-radius: var(--border-radius); 
    padding: 10px; 
    margin: 10px 0; 
    width: 100%;
}

/* Video styling */
.video-wrapper { 
    position: relative; 
    margin-bottom: 15px; 
    width: 100%;
}

#my_video {
    width: 100%;
    background: #000;
    border-radius: var(--border-radius);
    display: block;
}

/* Subtitle display styling */
.subtitle-display {
    position: absolute;
    bottom: 70px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    text-shadow: 0px 0px 0px #000;
    font-size: 18px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10;
    max-width: 90%;
    margin: 0 auto;
    border-radius: 4px;
}

/* Main Timeline elements */
.main-timeline-container {
    position: relative;
    margin: 10px 0;
    height: 55px;
    width: 100%;
    background: var(--timeline-bg);
    border-radius: var(--border-radius);
    cursor: pointer;
    user-select: none;
}

.main-timeline-track {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--timeline-bg);
    border-radius: var(--border-radius);
}

.main-timeline-selection {
    position: absolute;
    top: 20px;
    height: 20px;
    background: rgba(33, 150, 243, 0.3);
    border-radius: var(--border-radius);
    pointer-events: none;
}

.main-timeline-playhead {
    position: absolute;
    top: 15px;
    width: 3px;
    height: 30px;
    background: var(--primary-color);
    transform: translateX(-50%);
    cursor: ew-resize;
    z-index: 3;
    pointer-events: none;
    border-radius: 2px;
}

.main-timeline-playhead::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; 
    height: 0; 
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--primary-color);
}

.main-timeline-playhead::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; 
    height: 0; 
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--primary-color);
}

/* Time info displays */
.time-info {
    display: flex;
    gap: 15px;
    font-family: monospace;
    font-size: 14px;
    margin: 5px 0;
    flex-wrap: wrap;
}

/* Drop zone styling */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    transition: border var(--transition-speed) ease-in-out;
    margin-bottom: 20px;
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(33, 150, 243, 0.1);
}

.drop-zone p {
    margin: 0;
    color: #666;
}

/* Button styling */
.btn {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
}

.btn-group .btn {
    flex: 1 1 auto;
    min-width: fit-content;
}

.frame-step {
    padding: 4px 6px;
    font-size: 12px;
    min-width: 40px;
}

/* Repeat button styling */
#repeat-play.active {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Transcript styling */
.subtitle-list {
    height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    resize: vertical;
    border-radius: 4px;
    background-color: #f9f9f9;
    width: 100%;
}

.subtitle-item {
    padding: 5px;
    cursor: pointer;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    width: 100%;
}

.subtitle-item:hover {
    background-color: #f0f0f0;
}

.subtitle-item.active, .transcript-segment.active {
    background-color: #e0f0ff;
    border-radius: 4px;
}

.time-stamp {
    color: #666;
    font-size: 12px;
    margin-right: 10px;
    display: inline-block;
}

.transcript-segment {
    margin-bottom: 8px;
    padding: 5px;
    border-bottom: 1px solid #eee;
    width: 100%;
}

.transcript-word {
    cursor: pointer;
    padding: 2px 0;
    margin: 0 1px;
    display: inline-block;
}

.transcript-word:hover {
    background-color: #f0f0f0;
    border-radius: 3px;
}

.video-subtitle-word {
    padding: 0 2px;
    border-radius: 3px;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.word-active {
    background-color: yellow;
    color: black;
    font-weight: bold;
    border-radius: 3px;
}

.search-match {
    background-color: #ffff99;
    border-radius: 3px;
}

.current-match {
    background-color: #ffa500 !important;
    font-weight: bold;
    border-radius: 3px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.search-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
}

/* Container for search padding checkbox */
.search-options {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 5px;
    background-color: #e0e0e0;
    border-radius: var(--border-radius);
    margin-top: -10px;
    margin-bottom: 10px;
}

.search-box {
    flex: 1 1 auto;
    min-width: 150px;
    width: 100%;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    padding: 2px;
    display: none;
    z-index: 10;
}

.search-clear-btn:hover {
    color: #333;
}

.search-navigation {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Marker styles */
.marker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color var(--transition-speed);
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
}

.marker-item.active {
    background: #e3f2fd;
    border-left: 3px solid var(--primary-color);
}

.marker-label { 
    cursor: pointer; 
    flex: 1;
    overflow-wrap: break-word;
    word-break: break-word;
}

.marker-actions { 
    display: flex; 
    gap: 5px; 
    flex-wrap: nowrap;
}

.marker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.marker-comment {
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-top: 5px;
    max-height: 60px;
    overflow-y: auto;
    font-size: 0.9rem;
    width: 100%;
    border-left: 3px solid #e9ecef;
}

.edit-marker {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

.edit-marker:hover {
    background-color: #138496;
    border-color: #117a8b;
}

.marker-edit-form {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-top: 5px;
    border-left: 3px solid var(--primary-color);
}

/* Form elements */
.form-control, .form-select {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #ddd;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(33, 150, 243, 0.25);
}

.input-group {
    width: 100%;
}

.input-group > .form-control,
.input-group > .btn {
    min-height: 38px;
}

/* Create marker from subtitle button */
.create-marker-from-subtitle {
    font-size: 14px;
    padding: 2px 6px;
    color: #fff;
    background-color: var(--secondary-color);
    border: none;
    border-radius: var(--border-radius);
    margin-left: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    min-width: 30px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.create-marker-from-subtitle:hover {
    background-color: var(--secondary-dark);
}

.info-text {
    color: #666;
    font-style: italic;
}

/* Tab styling */
.nav-tabs {
    width: 100%;
    margin-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.nav-tabs .nav-link {
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link.active {
    color: #495057;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
}

/* Transcript tab specific styling */
.nav-tabs .nav-link#transcript-tab {
    background-color: var(--transcript-tab-bg);
    color: #666;
}

.nav-tabs .nav-link#transcript-tab.active {
    background-color: #fff;
    color: #495057;
}

.nav-tabs .nav-link#transcript-tab:hover:not(.active) {
    background-color: #ddd;
}

.tab-content {
    width: 100%;
}

.tab-pane {
    width: 100%;
}

/* Header styling */
h2 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 600;
}

h5 {
    color: #555;
    font-weight: 500;
}

/* Waveform Styling */
#waveform-container {
    position: relative;
    width: 100%;
    height: 128px;
    background: #f5f5f5;
    border-radius: 5px;
}

#waveform-scroll-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    margin-top: 10px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--lighter-bg);
}

#waveform-scroll-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
    transform: translateY(-1px);
}

#waveform-scroll-container::before {
    content: "Click anywhere to seek";
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 11px;
    color: #666;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

#waveform-scroll-container:hover::before {
    opacity: 1;
}

#waveform-scroll-container::-webkit-scrollbar {
    height: 8px;
}

#waveform-scroll-container::-webkit-scrollbar-track {
    background: var(--lighter-bg);
    border-radius: 4px;
}

#waveform-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
}

#waveform {
    width: 100%;
    min-height: 128px;
    position: relative;
}

/* Enhanced waveform interaction styling */
#waveform canvas {
    cursor: pointer !important;
    transition: opacity 0.1s ease;
}

#waveform canvas:hover {
    opacity: 0.9;
}

#waveform canvas:active {
    opacity: 0.8;
}

/* Loading and message styling */
#waveform-message {
    display: none;
    margin: 10px 0;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    border-left: 4px solid #28a745;
}

#loading-indicator {
    display: none;
    color: #4285f4;
    margin: 10px 0;
    text-align: center;
    font-weight: 500;
}

/* Animation for click feedback */
@keyframes clickPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

.waveform-click-indicator {
    animation: clickPulse 0.3s ease-out;
}

/* Timeline Scale Styling */
#timeline-scale {
    position: relative;
    width: 100%;
    height: 25px;
    margin-top: 5px;
    margin-bottom: 15px;
    overflow: hidden;
    background: linear-gradient(to bottom, transparent 0%, transparent 70%, #f0f0f0 70%, #f0f0f0 100%);
    border-radius: 0 0 4px 4px;
}

.tick {
    position: absolute;
    bottom: 15px;
    width: 1px;
    height: 8px;
    background-color: #666;
    z-index: 1;
}

.tick-label {
    position: absolute;
    bottom: 0px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    color: #333;
    font-weight: 500;
    transform: translateX(-50%);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.95);
    padding: 1px 3px;
    border-radius: 2px;
    border: 1px solid #ccc;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }
    
    .main-wrapper {
        padding: 20px;
        border-radius: 15px;
        max-height: none;
        min-height: 100vh;
    }
    
    .subtitle-display {
        font-size: 16px;
        padding: 8px;
        bottom: 60px;
    }
    
    .btn-group {
        justify-content: center;
    }
    
    .subtitle-list {
        height: 150px;
    }
    
    .main-timeline-container {
        height: 50px;
    }
    
    .main-timeline-track {
        top: 15px;
        height: 20px;
    }
    
    .main-timeline-selection {
        top: 15px;
    }
    
    .main-timeline-playhead {
        top: 10px;
        height: 30px;
    }
    
    .btn {
        padding-left: 8px;
        padding-right: 8px;
        font-size: 14px;
    }
    
    .d-flex {
        width: 100%;
    }
    
    .marker-actions {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .marker-actions .btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    #timeline-scale {
        height: 20px;
    }
    
    .tick {
        height: 6px;
        bottom: 12px;
    }
    
    .tick-label {
        font-size: 8px;
        padding: 0px 2px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .main-wrapper {
        padding: 15px;
        border-radius: 10px;
    }
    
    .subtitle-display {
        font-size: 14px;
        padding: 5px;
        bottom: 50px;
    }
    
    .d-flex {
        flex-direction: column;
    }
    
    .d-flex.flex-wrap {
        flex-direction: row;
    }
    
    .d-flex > * {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .search-navigation,
    .marker-actions,
    .time-info {
        flex-direction: row;
        width: 100%;
    }
    
    .btn, 
    .form-control {
        min-height: 44px;
    }
    
    .frame-step {
        width: auto;
        min-width: 36px;
    }

    .marker-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .marker-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .marker-actions {
        margin-top: 8px;
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-group {
        gap: 5px;
    }
    
    .btn-group .btn {
        flex: 1 1 calc(50% - 5px);
    }
    
    .marker-subtitle {
        font-size: 0.85rem;
        padding: 5px;
    }
    
    .marker-edit-form textarea {
        font-size: 0.85rem;
    }
    
    .tick-label {
        font-size: 7px;
        padding: 0px 1px;
    }
}

/* Custom Duration Input Styling */
/* Mobile-first stacked layout */
.custom-duration-group .duration-row {
  display: flex;
}
.custom-duration-group .duration-row input.form-control {
  flex-grow: 1;
  min-width: 50px; /* prevent input from getting too small */
}
.custom-duration-group .duration-separator {
  display: flex;
  justify-content: center;
}
.custom-duration-group > div {
    margin-bottom: 5px; /* Add space between stacked rows */
}

/* Desktop horizontal layout */
@media (min-width: 480px) {
  .custom-duration-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    width: 100%;
  }
  .custom-duration-group > div {
    margin-bottom: 0; /* Remove bottom margin for horizontal layout */
  }
  .custom-duration-group .duration-row {
    flex-grow: 1;
  }
  .custom-duration-group .duration-separator {
    flex-grow: 0;
  }
}


