/* Graph Box Layout */
.graph-box {
    border: 2px solid #333;
    background: #000;
    height: 330px;
    padding: 0;
    margin-bottom: 10px;
    border-radius: 4px;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Timeline Container */
.timeline-container {
    height: 30px;
    background: #252525;
    border-bottom: 1px solid #333;
    position: relative;
    display: flex;
    align-items: center;
    padding-left: 40px; /* Account for Y-axis width - align with x-axis */
    padding-right: 5px; /* Add right padding to match x-axis */
}

.timeline-track {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    margin: 0 10px 0 0; /* Remove left margin since container now has padding */
    position: relative;
}

.timeline-cursors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.timeline-cursor {
    position: absolute;
    top: 2px;
    left: 0%; /* Default to 0 seconds (start position) */
    width: 2px;
    height: 26px;
    background: #ff0;
    cursor: grab;
    pointer-events: all;
    z-index: 5; /* Lower than control voltage strip (z-index: 10) */
    border-radius: 1px;
}

.timeline-cursor::after {
    content: attr(data-time);
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 0, 0.9);
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 5; /* Lower than control voltage strip (z-index: 10) */
    border: 1px solid #666;
}

.timeline-cursor:active {
    cursor: grabbing;
}

.render-start-cursor, .render-end-cursor {
    position: absolute;
    top: 2px;
    width: 2px;
    height: 26px;
    background: #0f0;
    cursor: grab;
    pointer-events: all;
    z-index: 5; /* Lower than control voltage strip (z-index: 10) */
    border-radius: 1px;
}

.render-start-cursor::after, .render-end-cursor::after {
    content: attr(data-time);
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 255, 0, 0.9);
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 5; /* Lower than control voltage strip (z-index: 10) */
    border: 1px solid #666;
}

.render-start-cursor {
    left: 20%;
}

.render-end-cursor {
    left: 80%;
}

.timeline-markers {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    height: 10px;
    display: flex;
    justify-content: space-between;
    padding: 0 10px 0 0; /* Adjust padding to match track */
    font-size: 8px;
    color: #666;
}

.timeline-marker {
    font-size: 8px;
    color: #666;
    white-space: nowrap;
}

/* Graph Container */
.graph-container {
    flex: 1;
    display: flex;
    position: relative;
    }

/* Y-Axis (Voltage) */
.y-axis {
    width: 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 5px;
    background: #111;
    border-right: 1px solid #333;
    position: relative;
}

.y-axis-label {
    position: absolute;
    top: 50%;
    left: 30%;
    transform: translate(-50%, -50%) rotate(-90deg);
    font-size: 12px;
    color: #03bfe0;
    font-weight: bold;
}

.y-tick {
    font-size: 10px;
    color: #03bfe0;
    text-align: right;
    line-height: 1;
    position: relative;
}

.y-tick::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    width: 4px;
    height: 1px;
    background: #555;
    transform: translateY(-50%);
}

/* Graph Area */
.graph-area {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;    
}

#graph-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

#grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.graph-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* CV Curves */
.cv-curve {
    stroke: #0f0;
    }

.cv-curve.selected {
    stroke: #ff0;
    stroke-width: 3;
}

.cv-curve.trig {
    stroke: #f0f;
    stroke-width: 1; /* Hairline thickness */
}

.cv-curve.gate {
    stroke: #0ff;
}

.cv-curve.curv {
    stroke: #ff8800;
}

.cv-curve.log {
    stroke: #8800ff;
}

.cv-curve.exp {
    stroke: #ff0080;
}

.cv-curve.ran {
    stroke: #80ff00;
}

/* X-Axis (Time) */
.x-axis {
    height: 30px;
    background: #000;
    border-top: 1px solid #292929;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-left: 40px; /* Account for Y-axis width */
    padding-right: 5px; /* Add right padding */
}

.x-axis-label {
    position: absolute;
    bottom: 2px;
    right: 10px;
    font-size: 10px;
    color: #0f0;
    font-weight: bold;
}

.x-ticks {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.x-tick {
    position: absolute;
    font-size: 10px;
    color: #33ec0e;
    transform: translateX(-50%);
    white-space: nowrap;
}

.x-tick::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -4px;
    width: 1px;
    height: 4px;
    background: #555;
    transform: translateX(-50%);
}

.x-tick.major::before {
    height: 6px;
    background: #777;
}



/* Control Points */
.cv-point {
    fill: #fff;
    stroke: #000;
    stroke-width: 4;
    cursor: pointer;
    r: 6; /* 2x bigger than original (was 3) */
    pointer-events: all;
}

.cv-point:hover {
    r: 8; /* 2x bigger than original (was 4) */
    fill: #ff0;
}

.cv-point.selected {
    fill: #ff0;
    r: 8; /* 2x bigger than original (was 4) */
}

/* Zoom and Pan States */
.graph-area.panning {
    cursor: grabbing;
}

.graph-area.zooming {
    cursor: crosshair;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .y-axis {
        width: 35px;
    }
    
    .timeline-container {
        padding-left: 35px;
        padding-right: 5px;
    }
    
    .x-axis {
        padding-left: 35px;
        padding-right: 5px;
    }
    
    .y-tick {
        font-size: 9px;
    }
    
    .x-tick {
        font-size: 7px;
    }
}

/* Animation for smooth transitions */
.timeline-cursor, .render-start-cursor, .render-end-cursor {
    transition: left 0.1s ease-out;
}

/* Disable transition during animation */
.timeline-cursor.animating {
    transition: none;
    background: #f0f; /* Change color to magenta when animating */
    box-shadow: 0 0 8px #f0f; /* Add glow effect */
}

/* Enhanced cursor styling for overlap prevention */
.render-start-cursor,
.timeline-cursor, 
.render-end-cursor {
    position: absolute;
    top: 2px;
    width: 2px;
    height: 26px;
    z-index: 10;
    cursor: col-resize;
    transition: all 0.2s ease;
}

.render-start-cursor {
    background-color: #00ff00;
    border-left: 2px solid #00ff00;
}

.timeline-cursor {
    background-color: #00ff00;
    border-left: 2px solid #00ff00;
}

.render-end-cursor {
    background-color: #00ff00;
    border-left: 2px solid #00ff00;
}

/* Adjusted cursor styling */
.cursor-adjusted {
    opacity: 0.8;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    border-left-style: dashed !important;
}

.cursor-dragging {
    z-index: 15;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.cv-curve {
    transition: stroke-width 0.2s ease, opacity 0.2s ease;
}

/* Canvas smooth rendering */
#graph-canvas, #grid-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    image-rendering: crisp-edges;
}

/* Smooth canvas transitions */
.graph-area {
    transition: transform 0.1s ease-out;
}

/* Selection highlighting */
.graph-area.selecting {
    cursor: crosshair;
}

.selection-box {
    position: absolute;
    border: 1px dashed #ff0;
    background: rgba(255, 255, 0, 0.1);
    pointer-events: none;
    z-index: 4;
}
