/* Custom Styles */

/* Ensure main layout doesn't overflow and sidebars stay fixed */
.flex.h-screen {
    overflow: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
}

/* Left sidebar - fixed width, scrollable */
.w-80.bg-gray-800 {
    flex-shrink: 0 !important;
    overflow-y: auto !important;
    max-height: 100vh !important;
}

/* Right sidebar - fixed width, scrollable */
.w-96.bg-gray-800 {
    flex-shrink: 0 !important;
    overflow-y: auto !important;
    max-height: 100vh !important;
}

/* Middle section containing canvas and timeline - constrain to screen height and calculate width */
.flex-1.flex.flex-col.overflow-hidden.bg-gray-900 {
    max-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    width: calc(100vw - 16rem) !important; /* Full width minus left panel (w-80 = 16rem) */
    max-width: calc(100vw - 16rem) !important;
}

/* Canvas area - takes remaining space, constrains canvas container */
.flex-1.flex.items-center.justify-center {
    overflow: hidden !important; /* Hide overflow, let canvasContainer handle scrolling */
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 1 0 !important;
    display: flex !important;
    align-items: stretch !important; /* Stretch to fill */
    justify-content: stretch !important; /* Stretch to fill */
}

/* Canvas container - scrollable with constrained size, always center content */
#canvasContainer {
    position: relative;
    padding: 100px !important; /* Padding for overflow area */
    background: rgba(30, 41, 59, 0.7); /* Dark background for overflow area */
    overflow: auto !important; /* Scrollable when content exceeds container */
    flex-shrink: 0 !important; /* Don't shrink */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* Constrain size so it doesn't push timeline down */
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
}
.text-xs { font-size: 10px !important; }  /* Was 12px */
.text-sm { font-size: 12px !important; }  /* Was 14px */
.text-base { font-size: 14px !important; } /* Was 16px */
.text-lg { font-size: 16px !important; }  /* Was 18px */
.text-xl { font-size: 18px !important; }  /* Was 20px */
.text-2xl { font-size: 22px !important; } /* Was 24px */
.text-3xl { font-size: 28px !important; } /* Was 30px */

/* Apply base font size reduction to all elements */
body, html {
    font-size: 14px !important; /* Base reduced from 16px to 14px */
}

/* Form elements */
input, select, button, textarea, label {
    font-size: 12px !important; /* Reduced from 14px to 12px */
}

/* Adjust base spacing and sizing to be more compact */
.p-1 { padding: 0.2rem !important; }
.p-2 { padding: 0.4rem !important; }
.p-3 { padding: 0.6rem !important; }
.p-4 { padding: 0.8rem !important; }
.p-6 { padding: 1.2rem !important; }
.p-8 { padding: 1.6rem !important; }

.px-1 { padding-left: 0.2rem !important; padding-right: 0.2rem !important; }
.px-2 { padding-left: 0.4rem !important; padding-right: 0.4rem !important; }
.px-3 { padding-left: 0.6rem !important; padding-right: 0.6rem !important; }
.px-4 { padding-left: 0.8rem !important; padding-right: 0.8rem !important; }

.py-1 { padding-top: 0.2rem !important; padding-bottom: 0.2rem !important; }
.py-2 { padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
.py-3 { padding-top: 0.6rem !important; padding-bottom: 0.6rem !important; }
.py-4 { padding-top: 0.8rem !important; padding-bottom: 0.8rem !important; }

.m-1 { margin: 0.2rem !important; }
.m-2 { margin: 0.4rem !important; }
.m-3 { margin: 0.6rem !important; }
.m-4 { margin: 0.8rem !important; }

.mb-1 { margin-bottom: 0.2rem !important; }
.mb-2 { margin-bottom: 0.4rem !important; }
.mb-3 { margin-bottom: 0.6rem !important; }
.mb-4 { margin-bottom: 0.8rem !important; }
.mb-6 { margin-bottom: 1.2rem !important; }

.mt-1 { margin-top: 0.2rem !important; }
.mt-2 { margin-top: 0.4rem !important; }
.mt-3 { margin-top: 0.6rem !important; }
.mt-4 { margin-top: 0.8rem !important; }

.gap-1 { gap: 0.2rem !important; }
.gap-2 { gap: 0.4rem !important; }
.gap-3 { gap: 0.6rem !important; }
.gap-4 { gap: 0.8rem !important; }

.space-x-1 > * + * { margin-left: 0.2rem !important; }
.space-x-2 > * + * { margin-left: 0.4rem !important; }
.space-x-3 > * + * { margin-left: 0.6rem !important; }
.space-x-4 > * + * { margin-left: 0.8rem !important; }

.w-80 { width: 16rem !important; }
.w-full { width: 100% !important; }

/* Hide scrollbar but keep scrollable in left sidebar */
.overflow-y-auto::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

.overflow-y-auto {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Timeline tracks - Y scroll only, no scrollbar chrome */
.timeline-tracks-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
}
.timeline-tracks-scroll::-webkit-scrollbar {
    display: none;               /* Chrome/Safari/Opera */
}

/* Hide all scrollbars inside the timeline container */
#timelineContainer,
#timelineContainer * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#timelineContainer::-webkit-scrollbar,
#timelineContainer *::-webkit-scrollbar {
    display: none;
}

.layer-item {
    cursor: pointer;
    transition: all 0.2s;
}

.layer-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.layer-item.selected {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: rgb(59, 130, 246);
}

.layer-item.dragging {
    opacity: 0.5;
    cursor: move;
}

.layer-item.drag-over-top {
    border-top: 3px solid rgb(59, 130, 246);
}

.layer-item.drag-over-bottom {
    border-bottom: 3px solid rgb(59, 130, 246);
}

.canvas-element {
    position: absolute;
    cursor: move;
    border: none;
    z-index: 10; /* Ensure elements appear above the canvas overlay */
}

.canvas-element.selected {
    border: 2px solid rgb(59, 130, 246);
}

.canvas-element.text-element {
    border: none;
}

.canvas-element.text-element.selected {
    border: 2px dashed rgb(59, 130, 246);
}

.canvas-element.clickthrough-element {
    border: 2px dashed rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.canvas-element.clickthrough-element:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.8);
}

.layer-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgb(59, 130, 246);
    border: 1px solid white;
    border-radius: 50%;
    display: none;
}

.canvas-element.selected .resize-handle {
    display: block;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

#canvasWrapper {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    flex-shrink: 0 !important; /* Maintain banner size, don't shrink */
}

/* Canvas container with overflow visible to show elements outside */
/* Add semi-transparent overlay around canvas using box-shadow on wrapper */
#canvasWrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
    /* Create a frame effect with larger shadow spread */
    box-shadow: 
        0 0 0 2000px rgba(30, 41, 59, 0.5), /* Large semi-transparent overlay outside */
        inset 0 0 0 1px rgba(255, 255, 255, 0.1); /* Subtle inner border */
}

/* Canvas with visible overflow */
#canvas {
    background: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: white;
    position: relative;
    z-index: 1;
    overflow: visible !important; /* Allow elements to overflow */
}

.anim-item {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
}

.anim-item:hover {
    background: rgba(139, 92, 246, 0.2);
}

/* Timeline Styles */
.timeline-track {
    display: flex;
    border-bottom: 1px solid rgb(55, 65, 81);
    min-height: 38px;
    user-select: none; /* Disable text selection */
    cursor: move; /* Show move cursor on track */
}

.timeline-track.dragging {
    opacity: 0.5;
    background: rgba(59, 130, 246, 0.1);
}

.timeline-track.drag-over-top {
    border-top: 3px solid rgb(59, 130, 246);
}

.timeline-track.drag-over-bottom {
    border-bottom: 3px solid rgb(59, 130, 246);
}

.timeline-track-label {
    width: 200px;
    padding: 5px 8px;
    background: rgb(31, 41, 55);
    border-right: 1px solid rgb(55, 65, 81);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    user-select: none; /* Disable text selection */
    cursor: pointer;
    transition: background 0.2s;
}

.timeline-track-label:hover {
    background: rgba(59, 130, 246, 0.1);
}

.timeline-track.selected .timeline-track-label {
    background: rgba(59, 130, 246, 0.2);
    border-right-color: rgb(59, 130, 246);
}

.timeline-layer-btn {
    background: rgba(59, 130, 246, 0.2);
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    color: rgb(96, 165, 250);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.timeline-layer-btn:hover {
    background: rgba(59, 130, 246, 0.4);
    color: white;
}

.timeline-track-content {
    flex: 1;
    position: relative;
    background: rgb(17, 24, 39);
    user-select: none; /* Disable text selection */
    cursor: pointer; /* Show clickable cursor */
}

.timeline-block {
    position: absolute;
    height: 26px;
    top: 6px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.8), rgba(168, 85, 247, 0.8));
    border: 1px solid rgba(139, 92, 246, 1);
    border-radius: 4px;
    cursor: move;
    transition: all 0.2s;
    overflow: visible;
    display: flex;
    align-items: center;
    padding: 0 8px;
    user-select: none;
}

.timeline-block:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 1), rgba(168, 85, 247, 1));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.timeline-block-resize-handle {
    position: absolute;
    width: 8px;
    height: 100%;
    top: 0;
    cursor: ew-resize;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.2s;
}

.timeline-block:hover .timeline-block-resize-handle {
    opacity: 1;
}

.timeline-block-resize-handle.left {
    left: 0;
    border-left: 2px solid rgba(255, 255, 255, 0.5);
}

.timeline-block-resize-handle.right {
    right: 0;
    border-right: 2px solid rgba(255, 255, 255, 0.5);
}

.timeline-block-label {
    font-size: 10px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-block .delete-anim {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(239, 68, 68, 0.9);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.timeline-block:hover .delete-anim {
    display: flex;
}

.timeline-time-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(156, 163, 175, 0.3);
    cursor: pointer;
}

.timeline-time-label {
    position: absolute;
    top: 2px;
    font-size: 10px;
    color: rgb(156, 163, 175);
    transform: translateX(-50%);
    user-select: none;
    cursor: pointer;
    transition: color 0.2s;
}

.timeline-time-label:hover {
    color: rgb(255, 255, 255);
}

#timelineRuler {
    user-select: none;
}

.text-align-btn.active {
    background-color: rgb(59, 130, 246);
}

#propBold.active, #propItalic.active, #propUnderline.active {
    background-color: rgb(59, 130, 246);
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid #444;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.color-swatch.selected {
    border-color: rgb(59, 130, 246) !important;
    border-width: 3px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.color-swatch-rainbow,
.color-swatch-rainbow-shape {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    background: linear-gradient(135deg, 
        #ff0000 0%, #ff7f00 17%, #ffff00 33%, 
        #00ff00 50%, #0000ff 67%, #4b0082 83%, #9400d3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.color-swatch-rainbow:hover,
.color-swatch-rainbow-shape:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}


/* Folder Timeline Styles */
.timeline-folder {
    margin: 0;
}

.timeline-folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #4a4a52;
    color: #fff;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    max-width: 300px; /* Limit width so it doesn't cover whole timeline */
    position: relative;
    z-index: 10;
}

.timeline-folder-header:hover {
    background: #5a5a62;
}

.timeline-folder-toggle {
    width: 18px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    opacity: 0.9;
    font-size: 14px;
}

.timeline-folder-children {
    margin-left: 18px;
    min-height: 40px;
    padding: 4px 0;
    border-radius: 8px;
}

.timeline-folder-children:empty {
    border: 1px dashed rgba(255, 255, 255, 0.18);
}

.timeline-folder.collapsed .timeline-folder-children {
    display: none;
}

.ui-sortable-placeholder {
    height: 36px;
    background: #555;
    border-radius: 8px;
    margin: 6px 0;
    visibility: visible !important;
}

.timeline-track.layer {
    list-style: none;
}

.timeline-folder-handle {
    width: 18px;
    text-align: center;
    opacity: 0.85;
    cursor: grab;
    user-select: none;
}

.timeline-folder-handle:active {
    cursor: grabbing;
}

/* Folder selection and animation styles */
.timeline-folder.selected {
    background-color: #5a5a62;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Folder animations should always be visible, even when folder is collapsed */
.timeline-folder.collapsed .folder-track-content {
    display: block; /* Changed from 'none' to 'block' to keep folder animations visible */
}

.timeline-folder {
    display: flex;
    flex-direction: column;
}

.timeline-folder-row {
    display: flex;
    align-items: stretch;
}

.folder-track-content {
    position: relative;
    height: 40px;
    flex: 1;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    margin-left: 8px;
}

.folder-anim-block {
    background-color: #fbbf24 !important;
}

/* Canvas folder wrapper */
.canvas-folder {
    position: absolute !important;
    pointer-events: none !important; /* Let clicks pass through to elements */
}

/* When selected, show visual feedback but still let clicks pass through */
.canvas-folder.selected {
    outline: 2px dashed rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.05);
    pointer-events: none !important; /* Let clicks pass through */
}

.canvas-folder > .canvas-element {
    pointer-events: auto; /* Child elements always clickable and take priority */
}

/* Inline rename input for timeline tracks */
.track-rename-input {
    flex: 1;
    min-width: 0;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #3b82f6;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 12px;
    outline: none;
}
