/* Стили для поля видео по ссылке */

.video-embed-input-container {
    margin-top: 10px;
}

.video-embed-list:empty {
    margin-bottom: 5px;
    min-height: 10px;
}

.video-embed-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    background: #f9f9f9;
    position: relative;
    transition: all 0.2s ease;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    width: 100%;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.video-embed-item:active {
    cursor: grabbing;
}

.video-embed-item:hover {
    border-color: #09f;
    box-shadow: 0 2px 8px rgba(0, 153, 255, 0.1);
}

.video-embed-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0, 153, 255, 0.3);
}

.video-embed-item.drag-over {
    border-color: #09f;
    background: #f0f8ff;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 153, 255, 0.2);
    position: relative;
}

.video-embed-item.drag-over::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px dashed #09f;
    border-radius: 10px;
    pointer-events: none;
    z-index: 1;
}

.video-embed-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #999;
    cursor: grab;
    transition: color 0.2s ease;
    flex-shrink: 0;
    pointer-events: auto;
    z-index: 5;
}

.video-embed-drag-handle:hover {
    color: #09f;
}

.video-embed-drag-handle:active {
    cursor: grabbing;
}

.video-embed-item input,
.video-embed-item button,
.video-embed-item iframe {
    pointer-events: auto;
    cursor: auto;
}

.video-embed-item input {
    cursor: text;
}

.video-embed-item button {
    cursor: pointer;
}

/* Скрываем drag handle на мобильных устройствах */
@media (max-width: 768px) {
    .video-embed-drag-handle {
        display: none !important;
    }
    
    .video-embed-item {
        cursor: grab;
        margin-bottom: 10px;
    }
    
    .video-embed-item:active {
        cursor: grabbing;
    }
    
    .video-embed-item {
        gap: 10px;
        padding: 12px;
        cursor: grab;
        touch-action: pan-y;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        transition: all 0.2s ease;
        position: relative;
    }
    
    /* Разрешаем выделение текста для инпутов */
    .video-embed-item input,
    .video-embed-item textarea {
        -webkit-user-select: text !important;
        -khtml-user-select: text !important;
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        user-select: text !important;
        cursor: text !important;
        pointer-events: auto !important;
    }
    
    .video-embed-item:active {
        cursor: grabbing;
    }
    
    /* Анимация при удержании */
    .video-embed-item.holding {
        transform: scale(0.98);
        opacity: 0.8;
        box-shadow: 0 4px 12px rgba(0, 153, 255, 0.2);
    }
    
    /* Разрешаем touch действия для инпутов */
    .video-embed-item input {
        touch-action: manipulation;
    }
    
    .video-embed-preview {
        width: 100px;
        height: 70px;
    }
    
    .video-embed-info {
        flex: 1;
        min-width: 0;
    }
    
    .video-embed-title-input {
        font-size: 13px;
        padding: 6px 8px;
        touch-action: manipulation;
    }
    
    .video-embed-remove-btn {
        z-index: 10;
    }
}

/* Стили для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .video-embed-item {
        margin-bottom: 15px;
    }
}

/* Стили для jQuery UI Sortable */
.video-embed-item.dragging {
    opacity: 0.8;
    transform: rotate(2deg);
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0, 153, 255, 0.3);
}

.video-embed-placeholder {
    border: 2px dashed #09f;
    background: #f0f8ff;
    border-radius: 8px;
    margin-bottom: 20px;
    height: 80px;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.video-embed-placeholder.active {
    opacity: 0.8;
    background: #e6f3ff;
    border-color: #007ad6;
}

.ui-sortable-helper {
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 153, 255, 0.3);
    z-index: 1001;
}

/* Улучшенные стили для мобильного перетаскивания */
.video-embed-item.dragging {
    opacity: 0.9;
    transform: scale(1.02) rotate(1deg);
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0, 153, 255, 0.4);
    transition: none;
    pointer-events: none;
}

.video-embed-item.drag-over {
    border-color: #09f;
    background: #f0f8ff;
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 153, 255, 0.2);
    position: relative;
}

.video-embed-item.drag-over::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #09f;
    border-radius: 10px;
    pointer-events: none;
    z-index: 1;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Убираем стили для состояния удержания, так как теперь перетаскивание начинается сразу */
.video-embed-item.holding {
    /* Убираем все стили, чтобы не мешать перетаскиванию */
}

.video-embed-preview {
    position: relative;
    width: 120px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.video-embed-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
}

.video-embed-info {
    flex: 1;
    min-width: 0;
}

.video-embed-title-input {
    margin-bottom: 8px;
    font-size: 14px;
}

.video-embed-platform-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.video-embed-platform-badge.youtube {
    background: #ff0000;
}

.video-embed-platform-badge.rutube {
    background: #ff6600;
}

.video-embed-platform-badge.vkontakte {
    background: #4a76a8;
}

.video-embed-platform-badge.ok {
    background: #ee8208;
}

.video-embed-platform-badge.vimeo {
    background: #1ab7ea;
}

.video-embed-platform-badge.dailymotion {
    background: #0066dc;
}

.video-embed-platform-badge.twitch {
    background: #9146ff;
}

.video-embed-platform-badge.tiktok {
    background: #000000;
}

.video-embed-platform-badge.facebook {
    background: #1877f2;
}

.video-embed-platform-badge.soundcloud {
    background: #ff5500;
}

.video-embed-platform-badge.bilibili {
    background: #00a1d6;
}

.video-embed-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.video-embed-remove-btn:hover {
    background: #ff4444;
    color: white;
    border-color: #ff4444;
}

/* Новый drag handle для мобильных устройств */
.video-embed-drag-handle-mobile {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: #999;
    transition: all 0.2s ease;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.video-embed-drag-handle-mobile:hover {
    background: #f0f0f0;
    color: #666;
    transform: scale(1.05);
}

.video-embed-drag-handle-mobile:active {
    cursor: grabbing;
    transform: scale(0.95);
}

/* Скрываем старый drag handle на мобильных устройствах */
@media (max-width: 768px) {
    .video-embed-drag-handle {
        display: none !important;
    }
    
    .video-embed-drag-handle-mobile {
        display: flex !important;
    }
}

/* Скрываем новый drag handle на десктопе */
@media (min-width: 769px) {
    .video-embed-drag-handle-mobile {
        display: none !important;
    }
}

.video-embed-add-form {
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.video-embed-help {
    margin-top: 6px;
}

.video-embed-help small {
    color: #b0b0b0;
    font-size: 13px;
}

/* Анимация добавления */
.video-embed-item {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Адаптивные стили для разных количеств колонок */
@media (max-width: 768px) {
    .video-embed-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 480px) {
    .video-embed-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Состояние загрузки */
.video-embed-loading {
    opacity: 0.6;
    pointer-events: none;
}

.video-embed-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.video-embed-input-group {
    display: flex;
    align-items: stretch;
    border-radius: 16px;
    overflow: hidden;
    background: #f5f6fa;
    box-shadow: none;
    margin-bottom: 0;
}

.video-embed-input-group .form-control {
    border: none;
    background: transparent;
    border-radius: 16px 0 0 16px;
    font-size: 15px;
    box-shadow: none;
    outline: none;
}

.video-embed-input-group .form-control:focus {
    box-shadow: none;
    outline: none;
    background: transparent;
}

.video-embed-input-group .btn {
    border-radius: 0 16px 16px 0;
    background: #09f;
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 0 22px;
    font-size: 15px;
    transition: background 0.2s;
    box-shadow: none;
    outline: none;
    display: flex;
    align-items: center;
}

.video-embed-input-group .btn:hover {
    background: #007ad6;
}

/* Стили для отображения видео на фронтенде */
.video-embed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.video-embed-item-frontend {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.video-embed-item-frontend:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.video-embed-thumbnail {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #000;
}

.video-embed-thumbnail iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.video-embed-info-frontend {
    padding: 15px;
}

.video-embed-title-frontend {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.video-embed-platform-frontend {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: 500;
}

.video-embed-platform-frontend.youtube {
    color: #ff0000;
}

.video-embed-platform-frontend.rutube {
    color: #ff6600;
}

.video-embed-platform-frontend.vkontakte {
    color: #4a76a8;
}

.video-embed-platform-frontend.ok {
    color: #ee8208;
}

.video-embed-platform-frontend.vimeo {
    color: #1ab7ea;
}

.video-embed-platform-frontend.dailymotion {
    color: #0066dc;
}

.video-embed-platform-frontend.twitch {
    color: #9146ff;
}

.video-embed-platform-frontend.tiktok {
    color: #000000;
}

.video-embed-platform-frontend.facebook {
    color: #1877f2;
}

.video-embed-platform-frontend.soundcloud {
    color: #ff5500;
}

.video-embed-platform-frontend.bilibili {
    color: #00a1d6;
}

/* Стили для кликабельных видео */
.video-embed-clickable {
    cursor: pointer;
    position: relative;
}

.video-embed-clickable .video-embed-thumbnail {
    position: relative;
}

.video-embed-clickable .video-embed-thumbnail::after {
    content: "▶";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.video-embed-clickable:hover .video-embed-thumbnail::after {
    opacity: 1;
}

.video-embed-clickable .video-embed-thumbnail iframe {
    pointer-events: none;
}

/* Стили модального окна */
.video-embed-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.video-embed-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
}

.video-embed-modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
}

.video-embed-modal-header:has(.video-embed-modal-close:only-child) {
    justify-content: flex-end;
}

.video-embed-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.video-embed-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.video-embed-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.video-embed-modal-body {
    padding: 0;
}

.video-embed-modal-iframe {
    width: 100%;
    height: 450px;
    border: none;
}

/* Адаптивные стили */
@media (max-width: 1024px) and (min-width: 769px) {
    .video-embed-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    .video-embed-thumbnail {
        height: 200px;
    }
    .video-embed-info-frontend {
        padding: 12px;
    }
    .video-embed-modal-content {
        width: 90%;
        margin: 20px;
    }
    .video-embed-modal-iframe {
        height: 350px;
    }
}

@media (max-width: 768px) {
    .video-embed-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 10px;
    }
    .video-embed-thumbnail {
        height: 200px;
    }
    .video-embed-info-frontend {
        padding: 10px;
    }
    .video-embed-modal-content {
        width: 100%;
        max-width: none;
        left: 50%;
        transform: translateX(-50%);
        top: 50%;
        transform: translate(-50%, -50%);
    }
    .video-embed-modal-iframe {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .video-embed-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 10px;
    }
    .video-embed-thumbnail {
        height: 200px;
    }
    .video-embed-modal-content {
        width: 100%;
        left: 50%;
        transform: translateX(-50%);
        top: 50%;
        transform: translate(-50%, -50%);
    }
    .video-embed-modal-iframe {
        height: 250px;
    }
}

/* Индикатор количества видео в списке */
.video-embed-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #666;
    font-size: 14px;
}

.video-embed-indicator i {
    color: #09f;
} 