/* --- CSS Variables --- */
:root {
    --primary: #b01616;
    --primary-hover: #961111;
    --primary-dark: #b01616;
    --bg-dark: #0a0a0a;
    --bg-sidebar: #1a1a1a;
    --bg-input: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #666666;
    --border-color: #2a2a2a;
    --sidebar-width: 320px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

/* =========================================================
   EMPTY STATE - Centered homepage message
   ========================================================= */
.empty-state {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.empty-state.visible {
    opacity: 1;
}

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    padding: 60px;
    max-width: 450px;
}

.empty-state-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 20px 60px rgba(204, 102, 102, 0.3),
        0 0 0 1px rgba(204, 102, 102, 0.1);
    animation: emptyIconFloat 4s ease-in-out infinite;
    position: relative;
}

.empty-state-icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 32px;
    border: 2px dashed rgba(204, 102, 102, 0.3);
    animation: emptyIconSpin 20s linear infinite;
}

.empty-state-icon svg {
    width: 50px;
    height: 50px;
    fill: #fff;
}

.empty-state-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
}

.empty-state-text {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.empty-state-text kbd {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 0 #2a2a2a;
}

.empty-state-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(204, 102, 102, 0.4);
}

.empty-state-btn-icon svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

@keyframes emptyIconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}

@keyframes emptyIconSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   SIDEBAR TRIGGER - Left Edge Tab (shows on hover)
   ========================================================= */
.sidebar-trigger {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 25px;
    height: 180px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.sidebar-toggle {
    width: 5px;
    height: 70px;
    border-radius: 0 4px 4px 0;
    border: none;
    background: linear-gradient(180deg, 
        rgba(176, 22, 22, 0.9) 0%, 
        var(--primary) 50%, 
        rgba(176, 22, 22, 0.9) 100%);
    cursor: pointer;
    display: block;
    box-shadow: 
        2px 0 15px rgba(176, 22, 22, 0.5),
        0 0 25px rgba(176, 22, 22, 0.2);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(-4px);
    position: relative;
}

/* Subtle glow effect */
.sidebar-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 3px;
    height: 30px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 0 2px 2px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show the menu button on hover (all screen sizes) */
.sidebar-trigger:hover .sidebar-toggle {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-trigger:hover .sidebar-toggle::before {
    opacity: 1;
}

.sidebar-toggle:hover {
    width: 8px;
    height: 90px;
    background: linear-gradient(180deg, 
        var(--primary) 0%, 
        #d42020 50%, 
        var(--primary) 100%);
    box-shadow: 
        4px 0 30px rgba(176, 22, 22, 0.7),
        0 0 50px rgba(176, 22, 22, 0.4);
}

.sidebar-toggle:active {
    width: 8px;
    height: 90px;
    transform: translateX(-1px);
    transition: all 0.1s ease;
}

/* Hide the SVG - we don't need it for the line tab */
.sidebar-toggle svg {
    display: none;
}

body.sidebar-open .sidebar-trigger {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3%) translateX(-3px);
    transition: all 0.3s ease;
}

/* =========================================================
   SIDEBAR PANEL
   ========================================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 10001;
    transform: translateX(-100%);
    transition: transform var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

body.sidebar-open .sidebar {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.sidebar-header h2 svg {
    width: 22px;
    height: 22px;
    fill: var(--primary);
}

.sidebar-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-close:hover {
    background: var(--primary);
    color: var(--text-primary);
}

.sidebar-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sidebar-content {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* =========================================================
   INPUT GROUP
   ========================================================= */
.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(204, 102, 102, 0.15);
}

#urlInput {
    flex: 1;
    padding: 14px 16px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

#urlInput::placeholder {
    color: var(--text-muted);
}

#addVideoBtn {
    padding: 14px 18px;
    background: var(--primary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

#addVideoBtn:hover {
    background: var(--primary-hover);
}

#addVideoBtn:active {
    background: var(--primary-dark);
}

#addVideoBtn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* =========================================================
   VIDEO COUNT
   ========================================================= */
.video-count {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.video-count span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

/* =========================================================
   SHORTCUTS SECTION
   ========================================================= */
.shortcuts h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.shortcut-item kbd {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--text-primary);
    min-width: 50px;
    text-align: center;
}

.tip-icon {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    flex-shrink: 0;
}

/* =========================================================
   SIDEBAR OVERLAY
   ========================================================= */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: all;
}

/* =========================================================
   TOAST MESSAGES
   ========================================================= */
.toast-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 500;
    z-index: 20000;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast-message svg {
    width: 18px;
    height: 18px;
}

.toast-message.success svg {
    fill: #b01616;
}

.toast-message.error svg {
    fill: var(--primary);
}

.toast-message.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* =========================================================
   VIDEO CONTAINER & CONTROLS
   ========================================================= */
.video-container {
    position: absolute;
    cursor: default;
    background: #0a0a0a;
    overflow: hidden;
    border-radius: 0px;
}

/* Red dashed outline around entire video frame ONLY while resizing */
.video-container::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 15;
}

.video-container.resizing::before {
    border-color: var(--primary);
}

.video-container.dragging { 
    cursor: move; 
}

.video-container.resizing,
.video-container.dragging {
    transition: none !important;
}

.player-wrapper {
    position: absolute;
    inset: 0;              /* top:0; right:0; bottom:0; left:0; */
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    border-radius: inherit; /* match container rounding */
}

/* YouTube player / iframe: fill container exactly */
.youtube-player,
.player-wrapper iframe {
    position: absolute;
    inset: 0;            /* top:0; right:0; bottom:0; left:0; */
    width: 100%;
    height: 100%;
    border: none;
    display: block;      /* avoids any inline gap behavior */
}

/* =========================================================
   HOVER OUTLINE
   ========================================================= */
.hover-outline { 
    position: absolute; 
    inset: 0; 
    pointer-events: none; 
    z-index: 10; 
}

.hover-outline-edge {
    position: absolute;
    pointer-events: auto;
    opacity: 0;
    background-color: transparent;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.hover-outline-top { 
    top: 0; 
    left: 0; 
    right: 0; 
    height: 50px; 
}

.hover-outline-left { 
    top: 50px; 
    bottom: 60px; 
    left: 0; 
    width: 20px; 
}

.hover-outline-right { 
    top: 50px; 
    bottom: 60px; 
    right: 0; 
    width: 20px; 
}

.hover-outline-bottom { 
    display: none; 
}

.video-container:hover .hover-outline-edge { 
    opacity: 1; 
}

.video-container.dragging .hover-outline-edge,
.video-container.resizing .hover-outline-edge {
    opacity: 0 !important;
    background-color: transparent !important;
}

/* =========================================================
   VIDEO CONTROLS
   ========================================================= */
.video-controls {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 20;
    pointer-events: none;
}

.video-container:hover .video-controls { 
    opacity: 1; 
    pointer-events: auto;
}

.video-container.resizing .video-controls {
    opacity: 0 !important;
    pointer-events: none !important;
}

.video-controls .copy-btn { 
    margin-left: auto;
}

.video-controls .delete-btn { 
    margin-left: 0;
}

.control-btn {
    width: 32px; 
    height: 32px;
    background: rgba(0,0,0,0.9);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    position: relative;
    flex-shrink: 0;
    pointer-events: auto;
}

.control-btn svg { 
    width: 14px; 
    height: 14px; 
    fill: #ccc; 
}

.control-btn:hover {
    background: rgba(0,0,0,0.95);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.move-btn:hover { 
    background: rgba(90,42,42,0.9); 
    border-color: rgba(204,102,102,0.6); 
}

.move-btn:hover svg { 
    fill: #cc6666; 
}

.delete-btn:hover { 
    background: rgba(90,42,42,0.9); 
    border-color: rgba(204,102,102,0.6); 
}

.delete-btn:hover svg { 
    fill: #cc6666; 
}

.lock-btn.locked { 
    background: rgba(90,42,42,0.95); 
    border-color: rgba(204,102,102,0.9); 
}

.lock-btn.locked svg { 
    fill: #cc6666; 
}

.copy-btn.copied { 
    outline: 2px solid  #b01616; 
}

.video-container.locked .move-btn { 
    opacity: 0.5; 
    cursor: not-allowed; 
}

.video-container.locked .resize-handle { 
    opacity: 0 !important; 
    pointer-events: none; 
}

/* =========================================================
   RESIZE HANDLES
   ========================================================= */
.resize-handle {
    position: absolute;
    background: #404040;   /* grey by default */
    opacity: 0;
    transition: all 0.15s ease;
    border-radius: 2px;
    z-index: 25;
}

/* Show grey handles on hover */
.video-container:hover .resize-handle {
    opacity: 0.8;
    background: #404040;
}

/* When actually resizing (JS adds .resizing), make all handles red */
.video-container.resizing .resize-handle {
    opacity: 1;
    background: var(--primary);
    box-shadow: 0 0 0 1px rgba(255, 120, 120, 0.7);
}

/* While mouse is physically down on the handle */
.resize-handle:active {
    background: var(--primary-hover);
}

.resize-se { 
    bottom: -6px; 
    right: -6px; 
    width: 18px; 
    height: 18px; 
    cursor: se-resize; 
}

.resize-sw { 
    bottom: -6px; 
    left: -6px; 
    width: 18px; 
    height: 18px; 
    cursor: sw-resize; 
}

.resize-ne { 
    top: -6px; 
    right: -6px; 
    width: 18px; 
    height: 18px; 
    cursor: ne-resize; 
}

.resize-nw { 
    top: -6px; 
    left: -6px; 
    width: 18px; 
    height: 18px; 
    cursor: nw-resize; 
}

/* =========================================================
   SIZE INDICATOR
   ========================================================= */
.size-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: #cccccc;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    z-index: 30;
    display: none;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
    white-space: nowrap;
}

.video-container.resizing .size-indicator {
    display: block;
}

/* =========================================================
   DELETE CONFIRMATION
   ========================================================= */
.delete-confirm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    opacity: 0;
    animation: fadeIn 0.15s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.delete-confirm-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.delete-confirm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-confirm-btn svg {
    width: 18px;
    height: 18px;
}

.delete-confirm-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.delete-confirm-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.delete-confirm-btn.cancel svg {
    fill: #fff;
}

.delete-confirm-btn.confirm {
    background: rgba(139, 0, 0, 0.6);
    border-color: #b00;
}

.delete-confirm-btn.confirm:hover {
    background: rgba(180, 0, 0, 0.8);
    border-color: #ff4444;
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(180, 0, 0, 0.5);
}

.delete-confirm-btn.confirm svg {
    fill: #ff6666;
}

.delete-confirm-btn.confirm:hover svg {
    fill: #fff;
}

.video-container.confirming-delete .video-controls,
.video-container.confirming-delete .resize-handle {
    opacity: 0 !important;
    pointer-events: none !important;
}

.video-container.dragging .video-controls,
.video-container.dragging .resize-handle {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 600px) {
    .sidebar {
        width: 100%;
    }
    
    .empty-state-container {
        padding: 40px 30px;
    }
    
    .empty-state-icon {
        width: 80px;
        height: 80px;
        border-radius: 20px;
    }
    
    .empty-state-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .empty-state-title {
        font-size: 26px;
    }
    
    .empty-state-text {
        font-size: 14px;
    }
}

@media (max-width: 400px) {
    .empty-state-container {
        padding: 30px 20px;
    }
    
    .empty-state-icon {
        width: 70px;
        height: 70px;
        border-radius: 18px;
    }
    
    .empty-state-icon svg {
        width: 35px;
        height: 35px;
    }
    
    .empty-state-title {
        font-size: 22px;
    }
    
    .empty-state-text {
        font-size: 13px;
    }
    
    .toast-message {
        left: 20px;
        right: 20px;
        transform: translateX(0) translateY(20px);
        padding: 12px 16px;
        font-size: 0.875rem;
    }
    
    @keyframes toastIn {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes toastOut {
        from { opacity: 1; transform: translateY(0); }
        to   { opacity: 0; transform: translateY(20px); }
    }
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}