/* Hydra Video Editor - Main Stylesheet */

/* ==================== Global Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.modal-content {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #fff;
    font-size: 20px;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.6;
    color: #ccc;
    white-space: pre-line;
}

#restore-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

#restore-buttons button {
    padding: 12px 20px;
    font-size: 14px;
}

body {
    font-family: 'Monaco', 'Courier New', monospace;
    background: #0a0a0a;
    color: #f0f0f0;
    height: 100vh;
    overflow: hidden;
}

/* ==================== Main App Container (Grid Layout) ==================== */
#app-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    grid-template-rows: 1fr 280px;
    grid-template-areas:
        "left right"
        "bottom bottom";
    height: 100vh;
    gap: 2px;
    background: #333;
    position: relative;
}

/* Resize Handles */
.resize-handle-vertical {
    position: absolute;
    width: 5px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 100;
    top: 0;
}

.resize-handle-vertical:hover {
    background: rgba(255, 255, 255, 0.1);
}

.resize-handle-horizontal {
    position: absolute;
    height: 5px;
    width: 100%;
    cursor: ns-resize;
    background: transparent;
    z-index: 100;
    left: 0;
}

.resize-handle-horizontal:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==================== Left Panel (Accordion) ==================== */
#left-panel {
    grid-area: left;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 2px solid #333;
}

/* Accordion Items */
.accordion-item {
    border-bottom: 1px solid #333;
}

.accordion-header {
    width: 100%;
    background: #222;
    color: #ccc;
    border: none;
    padding: 10px 15px;
    margin: 0;
    cursor: pointer;
    font-size: 11px;
    text-align: left;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header:hover {
    background: #2a2a2a;
    color: #fff;
}

.accordion-item.active .accordion-header {
    background: #2a2a2a;
    color: #fff;
    font-weight: bold;
}

.accordion-icon {
    transition: transform 0.25s ease;
    font-size: 10px;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 0;
    background: #1a1a1a;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.accordion-item.active .accordion-content {
    display: block;
    padding: 15px;
    max-height: 2000px;
    overflow-y: auto;
}

/* Code Segments - Expand to fill available space */
.accordion-item:nth-child(2) {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.accordion-item:nth-child(2).active {
    flex: 1;
}

.accordion-item:nth-child(2) .accordion-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.accordion-item:nth-child(2) #segment-code {
    flex: 1;
    min-height: 400px;
    max-height: none;
}

/* ==================== Right Panel (Hydra Canvas) ==================== */
#right-panel {
    grid-area: right;
    position: relative;
    background: #000;
    overflow: hidden;
}

#hydra-container {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

#hydra-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==================== Bottom Panel (Timeline/Waveform) ==================== */
#bottom-panel {
    grid-area: bottom;
    background: #1a1a1a;
    border-top: 2px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #0a0a0a;
    border-bottom: 1px solid #333;
}

.panel-header h3 {
    color: #fff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* ==================== Buttons ==================== */
button {
    background: #555;
    color: #fff;
    border: 1px solid #777;
    padding: 6px 12px;
    margin: 3px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.2s ease;
}

button:hover {
    background: #666;
    border-color: #888;
}

button:disabled {
    background: #333;
    border-color: #444;
    cursor: not-allowed;
    opacity: 0.5;
}

button.primary {
    background: #666;
    border-color: #999;
}

button.primary:hover {
    background: #777;
}

button:active {
    transform: translateY(1px);
}

/* ==================== File Inputs ==================== */
input[type="file"] {
    display: none;
}

label.file-label {
    background: #444;
    color: #fff;
    padding: 6px 12px;
    margin: 3px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-block;
    font-size: 12px;
    border: 1px solid #666;
    transition: all 0.2s ease;
}

label.file-label:hover {
    background: #555;
    border-color: #777;
}

/* ==================== Waveform Display ==================== */
#waveform-container {
    position: relative;
    flex: 1;
    background: #0a0a0a;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    min-height: 150px;
}

#waveform {
    width: 100%;
    height: 100%;
}

#playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: #fff;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.waveform-controls {
    display: flex;
    gap: 10px;
    padding: 8px 15px;
    font-size: 12px;
    color: #888;
    align-items: center;
    background: #0a0a0a;
    border-top: 1px solid #333;
}

.waveform-controls button {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 8px;
}

/* Timeline Scrubber */
.timeline-scrubber {
    padding: 8px 15px;
    background: #0a0a0a;
    border-bottom: 1px solid #333;
}

#timeline-scroll {
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#timeline-scroll::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    cursor: pointer;
}

#timeline-scroll::-webkit-slider-thumb:hover {
    background: #888;
}

#timeline-scroll::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    cursor: pointer;
    border: none;
}

#timeline-scroll::-moz-range-thumb:hover {
    background: #888;
}

/* ==================== Timeline (Overlaid on Waveform) ==================== */
#timeline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.segment {
    position: absolute;
    background: rgba(100, 150, 255, 0.3);
    border: 2px solid rgba(100, 150, 255, 0.8);
    border-radius: 3px;
    height: 100%;
    pointer-events: all;
    cursor: pointer;
    overflow: visible;
}

.segment.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.segment.editing {
    background: rgba(200, 200, 200, 0.3);
    border-color: #aaa;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.segment.selected {
    outline: 3px solid #4a9eff;
    outline-offset: -3px;
    z-index: 10;
}

.segment:hover {
    background: rgba(120, 170, 255, 0.4);
    border-color: rgba(120, 170, 255, 1);
}

/* Segment resize handles */
.segment-edge {
    position: absolute;
    width: 8px;
    height: 100%;
    top: 0;
    cursor: ew-resize;
    z-index: 10;
}

.segment-edge.left {
    left: -4px;
}

.segment-edge.right {
    right: -4px;
}

.segment-edge:hover {
    background: rgba(255, 255, 255, 0.3);
}

.segment-delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 2px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.segment:hover .segment-delete-btn {
    opacity: 1;
}

.segment-label {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: auto;
    cursor: grab;
    padding: 2px 4px;
}

.segment-label:active {
    cursor: grabbing;
}

.segment-time {
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Segments list removed - now edited via timeline clicks */

/* ==================== Text Inputs ==================== */
textarea {
    width: 100%;
    min-height: 200px;
    flex: 1;
    background: #0a0a0a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 8px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    line-height: 1.4;
}

#segment-code {
    min-height: 500px;
    flex-grow: 1;
}

textarea:focus {
    outline: none;
    border-color: #888;
    box-shadow: 0 0 5px rgba(136, 136, 136, 0.3);
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
}

.input-group label {
    min-width: 80px;
    font-size: 13px;
}

.input-group input[type="number"],
.input-group input[type="text"] {
    flex: 1;
    background: #0a0a0a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 8px;
    font-family: inherit;
    font-size: 13px;
}

.input-group input:focus {
    outline: none;
    border-color: #888;
    box-shadow: 0 0 5px rgba(136, 136, 136, 0.3);
}

/* Time Inputs Row */
.time-inputs-row {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.time-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-input-group label {
    font-size: 12px;
    min-width: 40px;
}

.time-input-group input {
    width: 70px;
    background: #0a0a0a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 6px;
    font-family: inherit;
    font-size: 12px;
}

/* Canvas Size Presets */
.canvas-presets {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 10px 0;
}

.preset-btn {
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 12px;
    background: #333;
    border: 1px solid #555;
    border-radius: 8px;
}

.preset-btn:hover {
    background: #444;
}

.preset-btn.active {
    background: #555;
    border-color: #888;
    font-weight: bold;
}

/* ==================== Playback Controls ==================== */
#playback-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#time-display {
    font-size: 14px;
    color: #fff;
    font-weight: bold;
    min-width: 120px;
    font-family: monospace;
}

/* ==================== Info Text ==================== */
.info {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
    line-height: 1.4;
}

/* ==================== Media Sources ==================== */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.source-item {
    background: #0a0a0a;
    padding: 10px;
    border-radius: 3px;
    border: 1px solid #444;
    font-size: 12px;
    word-break: break-all;
    position: relative;
    transition: all 0.2s ease;
}

.source-item:hover {
    border-color: #666;
    transform: translateY(-2px);
}

.source-item.video,
.source-item.image {
    border-color: #666;
}

.source-preview {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 3px;
    margin-bottom: 8px;
    background: #000;
    display: block;
}

.source-label {
    display: block;
    margin-top: 5px;
    color: #aaa;
    font-weight: bold;
}

.source-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(255, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.source-item:hover .source-delete-btn {
    opacity: 1;
}

.source-delete-btn:hover {
    background: rgba(255, 0, 0, 0.9);
}

.audio-delete-btn {
    width: 100%;
    padding: 8px;
    background: #c00;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.audio-delete-btn:hover {
    background: #f00;
}

/* ==================== Error Display ==================== */
#error-section {
    background: #4a0000;
    border: 2px solid #ff0000;
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 15px;
}

.error-banner {
    color: #ff4444;
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 8px;
}

#error-display {
    background: #1a0000;
    color: #ff6666;
    padding: 15px;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 10px 0;
    max-height: 150px;
    overflow-y: auto;
}

#clear-error {
    background: #666;
    margin: 5px 0;
}

#clear-error:hover {
    background: #888;
}

/* ==================== Edit Mode ==================== */
#edit-mode-indicator {
    color: #ccc;
    font-weight: bold;
    font-size: 12px;
    margin-left: 10px;
}

#cancel-edit {
    background: #444;
    border-color: #555;
}

#cancel-edit:hover {
    background: #555;
}

/* ==================== Project Buttons ==================== */
.project-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ==================== Scrollbar Styling ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==================== Additional Styles ==================== */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0;
}

.button-group button {
    flex: 1;
    min-width: 100px;
}

.info-box {
    background: #0a0a0a;
    padding: 10px;
    border-radius: 3px;
    border: 1px solid #333;
    margin: 10px 0;
    font-size: 12px;
    line-height: 1.6;
}

.info-box strong {
    color: #aaa;
}

#playback-controls button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    padding: 8px;
    margin: 0 8px;
    min-width: auto;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 1200px) {
    #app-container {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 900px) {
    #app-container {
        grid-template-columns: 250px 1fr;
        grid-template-rows: 1fr 250px;
    }
    
    #left-panel {
        font-size: 12px;
    }
    
    #tab-content {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    #app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr 300px;
        grid-template-areas:
            "left"
            "right"
            "bottom";
    }
    
    #left-panel {
        border-right: none;
        border-bottom: 2px solid #333;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    /* Make accordions more compact on mobile */
    .accordion-header {
        padding: 12px 15px;
        font-size: 12px;
    }
    
    .accordion-content {
        padding: 12px !important;
    }
    
    /* Ensure Code Segments section doesn't expand too much on mobile */
    .accordion-item:nth-child(2) #segment-code {
        min-height: 150px;
        max-height: 200px;
    }
    
    /* Make buttons more touch-friendly */
    button {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 40px;
    }
    
    label.file-label {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Sources grid - horizontal scroll on mobile */
    .sources-grid {
        display: flex;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 10px;
    }
    
    .source-item {
        flex-shrink: 0;
        width: 120px;
    }
    
    .source-item img,
    .source-item video {
        width: 120px;
        height: 120px;
    }
    
    /* Waveform controls - wrap on mobile */
    .waveform-controls {
        flex-wrap: wrap;
        gap: 5px;
        padding: 10px;
    }
    
    .waveform-controls button {
        flex: 1;
        min-width: 80px;
    }
    
    /* Timeline segments - make more touch-friendly */
    .segment-item {
        min-height: 50px;
        padding: 8px;
    }
    
    /* Playback controls - better spacing */
    #playback-controls {
        display: flex;
        gap: 8px;
        align-items: center;
    }
    
    #playback-controls button {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Time inputs - better mobile layout */
    .time-inputs-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .time-input-group {
        width: 100%;
    }
    
    .time-input-group input {
        width: 100%;
    }
    
    /* Canvas presets - stack vertically on mobile */
    .canvas-presets {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .preset-btn {
        width: 100%;
    }
}
